Attention, Distillation, and Tabularization: Towards Practical Neural Network-Based Prefetching

Pengmiao Zhang, Neelesh Gupta, Rajgopal Kannan, Viktor K. Prasanna

Abstract

While neural networks (NNs) demonstrate superior accuracy in predicting complex memory access patterns, their integration into real-time hardware prefetchers is hindered by high inference latency. This paper introduces DART (Distilling Attention-based neuRal network to Tables), a framework designed to bridge the gap between the predictive power of Transformers and the strict timing constraints of CPU caches. By distilling a complex attention-based model into a compact hierarchy of fast table lookups, DART eliminates expensive matrix multiplications. Experimental results show that DART reduces arithmetic operations by 99.99% and achieves a 170× speedup over standard NN inference, resulting in a 37.6% improvement in Instructions Per Cycle (IPC) and significantly outperforming state-of-the-art heuristic and neural prefetchers.

Introduction

In modern computer architecture, the "memory wall"—the widening performance gap between fast processors and relatively slow main memory—remains a primary bottleneck. Data prefetchers mitigate this by predicting future memory addresses and fetching data into the cache before it is explicitly requested.

Traditional prefetchers rely on simple hardware heuristics, such as spatial locality or stride detection. While efficient, these methods struggle with the irregular and complex access patterns found in modern, data-intensive workloads. Machine learning models, particularly those based on the Attention mechanism (Transformers), have shown remarkable ability to learn these patterns. However, the computational cost of NNs—specifically the massive volume of matrix multiplications—is incompatible with the nanosecond-scale decision windows required at the cache level. DART addresses this by converting neural inference into a series of efficient table lookups.

The DART Framework

The authors propose a three-stage pipeline to transform high-performance neural models into hardware-ready components:

1. Attention-Based Teacher Training

The process begins by training a high-capacity "Teacher" model. This model utilizes an attention mechanism to capture long-range dependencies in memory access traces, establishing a high baseline for prediction accuracy.

2. Knowledge Distillation (KD)

To reduce the model's complexity, the Teacher's knowledge is distilled into a smaller, shallower "Student" model. A key contribution in this phase is the introduction of the T-Sigmoid function. Unlike standard activation functions, T-Sigmoid is optimized for multi-label classification, allowing the model to predict multiple potential future memory deltas simultaneously, which is critical for high-coverage prefetching.

3. Tabularization via Product Quantization

The core innovation of DART is the conversion of the Student NN into a hierarchy of tables. This is achieved through Product Quantization (PQ), which decomposes the high-dimensional input space into smaller subspaces.

  • Inference as Lookup: By quantizing the input space, the results of matrix multiplications can be precomputed and stored in tables. During runtime, the prefetcher performs a simple lookup rather than an expensive calculation.
  • Layer-wise Fine-tuning: To mitigate the approximation errors that typically occur during quantization, the authors employ a specialized fine-tuning strategy. Each layer is retrained to mimic the actual output of the preceding tabularized layer, preventing error accumulation across the network.

Experimental Evaluation

The researchers evaluated DART using memory access traces from the SPEC CPU 2006 and SPEC CPU 2017 benchmark suites. Simulations were conducted using ChampSim, an industry-standard simulator for computer architecture research, focusing on the Last Level Cache (LLC).

Performance and Efficiency

DART demonstrates that it is possible to achieve NN-level accuracy with hardware-level efficiency:

  • Computational Reduction: DART reduces the number of required arithmetic operations by 99.99%.
  • Inference Speed: The framework achieves a 170× acceleration in inference time compared to the original attention model.
  • System-Level Gains: DART achieved a 37.6% IPC improvement, outperforming the state-of-the-art rule-based Best-Offset (BO) prefetcher by 6.1%.

Comparison with Existing NN Prefetchers

When compared to other neural-based solutions, DART shows significant advantages in timeliness:

  • TransFetch: DART outperforms it by 33.1%.
  • Voyager: DART outperforms it by 37.2%.

While models like Voyager are accurate, their high inference latency often results in "late" prefetches—the data arrives after the CPU has already requested it. DART’s tabularized approach ensures that predictions are delivered fast enough to be useful in real-time execution.

Discussion and Future Work

The Latency-Accuracy Trade-off

The performance of DART is configurable based on the hardware budget. Increasing the number of prototypes ($K$) and subspaces ($C$) in the tables improves accuracy but increases storage requirements. The authors provide a "Table Configurator" to help designers navigate this trade-off. In the paper's variants, storage requirements ranged from 30KB to 3.75MB.

Limitations

Despite its speed, the storage overhead may still be a concern for highly area-constrained cache controllers. Additionally, the current DART model is trained offline. Future research could investigate dynamic table updates to adapt to changing application behaviors during runtime, or further consolidate multiple NN layers into single tables to further shorten the critical path.

Conclusion

DART represents a significant step toward making neural network-based prefetching practical for real-world hardware. By reimagining neural inference as a tabular lookup process, it maintains the sophisticated pattern-matching capabilities of Transformers while meeting the extreme low-latency requirements of modern CPU architectures.

Summary updated

BibTeX
@inproceedings{zhang2024attention,
  author = {Pengmiao Zhang and Neelesh Gupta and Rajgopal Kannan and Viktor K. Prasanna},
  title = {{Attention, Distillation, and Tabularization: Towards Practical Neural Network-Based Prefetching}},
  booktitle = {IPDPS},
  year = {2024},
  url = {https://openreview.net/forum?id=e8GpWqbFpB},
}
Figure