[Paper Review] Improving Branch Prediction By Modeling Global History with Convolutional Neural Networks
This paper proposes using convolutional neural networks (CNNs) as helper predictors to improve branch prediction accuracy for hard-to-predict branches (H2Ps) in modern CPUs. By modeling global history with CNNs, the approach tolerates positional variations in branch history sequences, reducing mispredictions by 36.6% on average across 47% of H2Ps in SPECint 2017, with a deployable 2-bit quantized CNN design improving 24% of H2Ps by 14.4% on average.
CPU branch prediction has hit a wall--existing techniques achieve near-perfect accuracy on 99% of static branches, and yet the mispredictions that remain hide major performance gains. In a companion report, we show that a primary source of mispredictions is a handful of systematically hard-to-predict branches (H2Ps), e.g. just 10 static instructions per SimPoint phase in SPECint 2017. The lost opportunity posed by these mispredictions is significant to the CPU: 14.0% in instructions-per-cycle (IPC) on Intel SkyLake and 37.4% IPC when the pipeline is scaled four-fold, on par with gains from process technology. However, up to 80% of this upside is unreachable by the best known branch predictors, even when afforded exponentially more resources. New approaches are needed, and machine learning (ML) provides a palette of powerful predictors. A growing body of work has shown that ML models are deployable within the microarchitecture to optimize hardware at runtime, and are one way to customize CPUs post-silicon by training to customer applications. We develop this scenario for branch prediction using convolutional neural networks (CNNs) to boost accuracy for H2Ps. Step-by-step, we (1) map CNNs to the global history data used by existing branch predictors; (2) show how CNNs improve H2P prediction in SPEC 2017; (3) adapt 2-bit CNN inference to the constraints of current branch prediction units; and (4) establish that CNN helper predictors are reusable across application executions on different inputs, enabling us to amortize offline training and deploy ML pattern matching to improve IPC.
Motivation & Objective
- Address the performance bottleneck caused by systematic mispredictions in a small set of hard-to-predict branches (H2Ps), which account for 14.0% IPC loss on Intel SkyLake and up to 37.4% when scaled.
- Overcome the limitations of existing branch predictors, which fail to capture complex patterns in global history data, especially when iteration counts vary.
- Develop a machine learning-based solution that can be deployed within the tight area and latency constraints of a branch prediction unit (BPU).
- Enable reusability of trained ML models across different inputs and executions to amortize training costs and support post-silicon customization.
- Demonstrate that CNNs can model global history with tolerance to positional distortions caused by variable-iteration control structures, outperforming traditional pattern-matching techniques.
Proposed method
- Map global history data—consisting of instruction pointer values and branch directions—into a 2D tensor representation suitable for convolutional processing.
- Design a two-layer CNN with 32 filters in Layer 1 and 16 filters in Layer 2, using 7-bit IP encoding and 1-bit direction bits to model temporal and spatial patterns in branch history.
- Quantize the CNN to 2-bit weights (ternary CNN) to reduce complexity and enable efficient inference using only table lookups and popcount operations.
- Translate the CNN inference process into a sequence of serial table lookups and a popcount operation, minimizing latency and fitting within BPU resource constraints.
- Train the CNN offline on runtime traces from multiple inputs of each benchmark, then evaluate generalization to unseen workloads using k-fold cross-validation.
- Integrate the CNN helper as a secondary predictor that complements a baseline TAGE-SC-L predictor, with final predictions made via a statistical corrector mechanism.
Experimental results
Research questions
- RQ1Can convolutional neural networks effectively model global branch history data to improve prediction accuracy for hard-to-predict branches (H2Ps) that resist conventional predictors?
- RQ2To what extent do CNNs tolerate positional variations in branch history sequences caused by variable-iteration control structures, compared to traditional pattern-matching predictors?
- RQ3Can a quantized 2-bit CNN be designed to meet the strict area and latency constraints of a real-world branch prediction unit while preserving significant accuracy gains?
- RQ4Does the trained CNN helper generalize across different inputs of the same application, enabling amortized training and reuse in production environments?
- RQ5What is the performance impact of using CNN helpers in terms of IPC improvement, and how much of the remaining misprediction opportunity is captured compared to scaling existing predictors?
Key findings
- Full-precision CNN helpers reduce mispredictions by an average of 36.6% on 47% of H2Ps in SPECint 2017, demonstrating significant accuracy gains for systematically hard-to-predict branches.
- The 2-bit quantized CNN (TP-CNN) improves prediction accuracy for 24% of H2Ps by an average of 14.4%, capturing roughly half the gain of full-precision models while remaining deployable.
- Even when TAGE-SC-L is scaled to 64KB, 21% of H2Ps still benefit from CNN helpers, reducing mispredictions by 12.3% on average, showing that improved pattern matching provides a fundamental advantage over scaling alone.
- The CNN approach generalizes across different inputs of the same application: training on one workload and testing on others yields consistent gains, enabling reusability and amortized training costs.
- The gap between full-precision and quantized CNNs indicates that both positional pattern matching and handling of potentially stale data are critical for accuracy, suggesting room for further optimization in on-BPU design.
- The method achieves high performance gains—up to 14.0% IPC improvement on Intel SkyLake and 37.4% on a 4×-scaled pipeline—by targeting just a small fraction of branches, highlighting the potential of ML-driven customization in microarchitectural design.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.