TransforMAP: Transformer for Memory Access Prediction

Pengmiao Zhang, Ajitesh Srivastava, Anant V. Nori, Rajgopal Kannan, Viktor K. PrasannaarXiv 2022

Abstract

Data Prefetching is a technique that can hide memory latency by fetching data before it is needed by a program. Prefetching relies on accurate memory access prediction, to which task machine learning based methods are increasingly applied. Unlike previous approaches that learn from deltas or offsets and perform one access prediction, we develop TransforMAP, based on the powerful Transformer model, that can learn from the whole address space and perform multiple cache line predictions. We propose to use the binary of memory addresses as model input, which avoids information loss and saves a token table in hardware. We design a block index bitmap to collect unordered future page offsets under the current page address as learning labels. As a result, our model can learn temporal patterns as well as spatial patterns within a page. In a practical implementation, this approach has the potential to hide prediction latency because it prefetches multiple cache lines likely to be used in a long horizon. We show that our approach achieves 35.67% MPKI improvement and 20.55% IPC improvement in simulation, higher than state-of-the-art Best-Offset prefetcher and ISB prefetcher.

Introduction

In modern computing, the "memory wall"—the performance gap between fast processors and relatively slow memory—remains a primary bottleneck. Data prefetching addresses this by predicting future memory needs and loading data into the cache ahead of time. While traditional prefetchers excel at simple, linear patterns, they struggle with the irregular access patterns common in complex modern workloads.

Machine learning (ML) models, particularly LSTMs, have been proposed to bridge this gap. However, they face three significant challenges: "class explosion" due to the vast 64-bit address space, the lack of a single "correct" next address (unfixed labeling), and high inference latency that can negate the benefits of prefetching. TransforMAP is designed to overcome these hurdles using a Transformer-based architecture.

Methodology

TransforMAP introduces a novel encoder-decoder framework tailored for hardware efficiency.

Binary Input Representation

Instead of absolute addresses or deltas, TransforMAP processes the raw binary bits of memory addresses. This reduces the vocabulary size to just two (0 and 1), eliminating the need for large embedding tables and preventing information loss inherent in delta-based methods.

Bitmap Labeling and Multi-line Prediction

To address unfixed labeling, the model uses a bitmap to represent all future block offsets within a memory page. This allows the model to learn both temporal and spatial patterns simultaneously. By predicting a set of offsets rather than a single sequence, TransforMAP can prefetch multiple cache lines in one pass, effectively hiding its own inference latency through a longer prediction horizon.

TransforMAP Architecture and Workflow

Experimental Results

The researchers evaluated TransforMAP using the ChampSim simulator against SPEC CPU 2006 and 2017 benchmarks. The model was compared against two state-of-the-art baselines: the Best-Offset (BO) prefetcher and the Irregular Stream Buffer (ISB).

TransforMAP demonstrated superior performance across all key metrics:

  • Accuracy: Achieved an average accuracy of 66.72%, outperforming BO (41.29%) and ISB (61.79%).
  • MPKI Reduction: Reduced Misses Per Kilo-Instruction (MPKI) by 35.67%.
  • IPC Improvement: Delivered a 20.55% improvement in instructions per cycle (IPC), the primary metric for actual speedup.
Performance Comparison across Benchmarks

Conclusion

TransforMAP successfully leverages the Transformer architecture to provide high-accuracy, multi-line memory access predictions. By utilizing binary representations and bitmap labeling, it solves the class explosion and latency issues that have previously hindered ML-based prefetchers. Future work will focus on implementing efficient online retraining mechanisms to ensure the model remains accurate as program access patterns evolve over time.

Summary updated

Abstract

Data Prefetching is a technique that can hide memory latency by fetching data before it is needed by a program. Prefetching relies on accurate memory access prediction, to which task machine learning based methods are increasingly applied. Unlike previous approaches that learn from deltas or offsets and perform one access prediction, we develop TransforMAP, based on the powerful Transformer model, that can learn from the whole address space and perform multiple cache line predictions. We propose to use the binary of memory addresses as model input, which avoids information loss and saves a token table in hardware. We design a block index bitmap to collect unordered future page offsets under the current page address as learning labels. As a result, our model can learn temporal patterns as well as spatial patterns within a page. In a practical implementation, this approach has the potential to hide prediction latency because it prefetches multiple cache lines likely to be used in a long horizon. We show that our approach achieves 35.67% MPKI improvement and 20.55% IPC improvement in simulation, higher than state-of-the-art Best-Offset prefetcher and ISB prefetcher.
BibTeX
@misc{zhang2022transformap,
  author = {Pengmiao Zhang and Ajitesh Srivastava and Anant V. Nori and Rajgopal Kannan and Viktor K. Prasanna},
  title = {{TransforMAP: Transformer for Memory Access Prediction}},
  year = {2022},
  eprint = {2205.14778},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2205.14778},
}
Figure