Manuscript Offprint

arXiv:2610.07668

CACHEFORGE: LLM-Guided End-to-End Generative Cache Replacement Policy for Performance and Hardware Efficiency

Kaushal Mhapsekar, Bita Aslrousta, Brijesh Kumar Bhayana, Paula Contreras, Azam Ghanbari, Ethan Goodman, Anna Andriiko, Samira Mirbagher Ajorpaz

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Kaushal Mhapsekar, Bita Aslrousta, Brijesh Kumar Bhayana, Paula Contreras, Azam Ghanbari, Ethan Goodman, Anna Andriiko, Samira Mirbagher Ajorpaz

Department of Electrical and Computer Engineering

North Carolina State University, Raleigh, NC, USA

{ kmhapse, baslrou, bkbhayan, pcontre, aghanba2, ecgoodm2, aandrii, smirbag}@ncsu.edu

Abstract—Modern cache replacement designs saturate because they operate within fixed representational structures, handcrafted and heuristic based feature-engineered predictors, or offline imitation models that cannot generate new decision logic on their own. At the same time, replacement is shaped by the causal interaction of prefetching, thrashing, spatial locality, and access-type behavior, producing an enormous design space that is difficult to traverse manually. Prior approaches typically rely on heuristics, parameter tuning, or imitation of an offline optimal policy, capturing correlations rather than synthesizing new mechanisms. As a result, their performance gains often plateau and they overfit under dynamic workload conditions.

CACHEFORGE is the first framework to evolve cache-replacement policies end-to-end by embedding a large language model inside a governed hardware-aware loop. In each iteration, the LLM proposes new C++ replacement logic, the policy is evaluated under a trace-based CRC-2 ChampSim simulator, and the framework enforces feasibility through reward shaping, structural checks, dynamic mutation, temperature scheduling, and cross-policy crossover. This closed-loop generation-evolution loop specifically designed for cache replacement policy enables the discovery of compact policies that satisfy hardware constraints while exploring algorithmic transformations beyond fixed predictor structures.

Across SPEC CPU2006, CACHEFORGE outperforms all CRC-2 baselines. It improves the total hit rate by 27.36%, 19.69%, 13.72%, 13.15%, 11.83%, and 5.73% over MPPPB, ReD, Hawkeye, SHiP++, LIME, and LRU, respectively. On memory-intensive workloads, it increases IPC by 10.15%, 7.89%, 6.34%, 3.64%, 3.12%, and 2.71% over LRU, MPPPB, LIME, ReD, SHiP++, and Hawkeye.

I. INTRODUCTION

Off-chip DRAM accesses cost hundreds of cycles; consequently, a small number of exposed LLC misses can determine end-to-end performance. Replacement policies therefore remain a critical optimization point: recent work shows that carefully modifying eviction decisions can still yield double-digit IPC gains. For example, Mockingjay [18] improves IPC despite worsening MPKI by suppressing prefetch pollution in specific sets, while PACIPV [15] improves IPC by 1.1–3.3% by retaining lines whose misses would directly stall the core. These results demonstrate that the effectiveness of a replacement policy depends on which misses are exposed to the critical path, not on aggregate hit rate.

Modern processors amplify this effect. Every LLC access interacts with speculation, coherence, prefetching, DRAM scheduling, and instruction-stream behavior [3], [15], [18]. Evicting a line that feeds a dependence chain can introduce a long stall even if total hit rate improves; retaining a line that supports forward progress can eliminate a stall even if MPKI increases elsewhere. Replacement is therefore a causal decision problem influenced by dynamic interactions, rather than a static recency heuristic.

Despite this causal complexity, prior automated designs operate within human-defined representational bounds. The IPV framework [9] searches insertion and promotion vectors, a space of 1617≈3×102016^{17} \approx 3 \times 10^{20} possibilities. Multiperspective Placement Promotion and Bypass (MPPPB [10]) explores over 1011010^{110} combinations across sixteen expert-curated feature families, requiring nearly ten CPU-years of search. PACIPV [15] restricts exploration to 1024 RRIP-derived vectors to make exhaustive search tractable. These efforts demonstrate both the promise and saturation of fixed design spaces: no matter how large the parameter space is, the algorithmic structure is fixed in advance.

Replacement policy design has therefore converged on two classes of approaches. First, manually engineered heuristics such as DIP [17], RRIP [8], SHiP [23], and ReD [5] encode expert insight into compact predictors, but cannot alter their control flow or metadata structures. Second, correlation-driven learning frameworks such as Hawkeye [7], Glider [19], Mockingjay [18] and PARROT [13], imitate desirable behavior from traces, but their eviction logic is frozen and cannot adapt based on new causal feedback. Across both categories, the fundamental limitation is the same: the algorithmic structure of the policy is fixed, and search is confined to parameters within that structure.

This limitation arises because replacement is simultaneously a pattern-recognition problem (predicting reuse, phase changes, and prefetch usefulness) and a causal decision-making problem (determining which evictions alter future exposed misses). Prior approaches strengthen one side of this decomposition, pattern recognition or decision heuristics, but none can evolve both. Even IPV and MPPPB, which perform causal evaluation in simulation, are confined to rigid representations whose algorithmic frames cannot change.

This motivates a natural question: what if a replacement policy could evolve its own algorithmic structure, its decision flow, metadata rules, and control logic, while simultaneously adapting its finer-grain behaviors to the patterns it observes? What if policies were not tuned, but grown?

We introduce CACHEFORGE, a framework that answers this question by treating a replacement policy as mutable code. A large language model generates candidate C++ mechanisms whose logic may differ structurally from their predecessors; a trace-based simulator provides causal performance feedback; and a governed evolutionary loop enforces hardware constraints and prevents unbounded growth. Unlike prior work [10], CACHEFORGE is not restricted to a fixed predictor template: both algorithmic structure and pattern-interpreting logic can evolve.

Our experiments show that a naive LLM cannot accomplish this task on its own. The solution is far from obvious: without explicit governance, the model consistently fails in ways that render autonomous evolution infeasible. It hallucinates code, emits logic that does not compile or violates interface contracts, and frequently produces mechanisms that explode in metadata size or ignore feasibility constraints altogether. When seeded with existing policies, it tends to imitate them too literally and loses exploratory novelty; when unseeded, it repeats the same structural mistakes across generations. Without a structured memory hierarchy, it oscillates or reverts to previously invalid patterns; with naive memory, it collapses into a single design lineage and becomes trapped in local minima. Without carefully shaped rewards, it aggressively maximizes hit rate, occasionally at the cost of IPC by protecting prefetch or writeback lines. Without objective constraints, it invents simplistic but unbounded mechanisms that violate hardware budgets. In short, an unguided LLM either diverges, overfits, collapses, or produces policies that are architecturally meaningless, demonstrating that a governed, hardware-aware evolutionary loop is not optional, but necessary for reliable discovery.

CACHEFORGE resolves these issues by embedding the LLM inside a tightly governed, hardware-aware generate-evaluate-refine loop. Syntax- and structure-aware prompting ensures that every candidate conforms to the ChampSim interface, while static feasibility checks reject hallucinated or unsafe code before simulation. Storage-budget constraints and metadata accounting prevent unbounded growth, forcing the model to trade capacity against performance. A trace-based evaluator provides the causal feedback that imitation-based methods lack, punishing designs that increase hit rate but lengthen exposed stalls. Reward shaping aligns optimization with IPC and IPC-per-KB rather than raw hit rate, steering generation toward demand-critical behaviors. A three-tier memory system: ephemeral, episodic, and summary, retains useful design lessons without collapsing exploration, while dynamic temperature and mutation scheduling maintain diversity while encouraging novelty and prevent local minima. Structural crossover between top-performing but dissimilar policies injects genuine novelty, and model switching breaks late-stage stagnation. Together, these mechanisms convert an otherwise unstable generator into a disciplined architectural search engine capable of producing hardware friendly, feasible, and high-performance replacement algorithms.

A further limitation of prior learning-based replacement policies is the complete absence of explainability and the lack of phase- or workload-awareness. PARROT [13] and Glider [19] attempt to interpret their neural predictors by inspecting attention vectors or LSTM activations, and CHiRP [14] analyzes perceptron and Adaline weights to identify correlated features; however, these signals reflect only statistical associations learned offline from fixed training traces. Once training ends, the model's behavior is frozen: it cannot adapt its interpretation of locality across phases, workloads, or architectural contexts, nor can it reveal the causal reasoning behind its eviction choices. At best, these frameworks expose coarse indicators of correlation, e.g., which PCs were influential in the training distribution, but not the algorithmic principles governing online decision-making. This has significantly limited the use of advanced AI in the field and the trust level needed for implementing these policies in the hardware.

In contrast, CACHEFORGE represents each policy as executable C++ code, making its mechanisms, metadata structures, features, and decision making, explicitly visible and analyzable. Because evolution occurs inside a trace-based simulator, every modification is validated against the current phase behavior and workload dynamics, not a frozen offline trace. Moreover, each evolutionary step is archived in a persistent memory ledger, allowing users to inspect how the policy's logic changes over time, which structures emerge or vanish, and which design ideas survive selection. This yields the first explainable learning-driven replacement framework: the causal logic of the policy is transparent because it is written in code, and its developmental trajectory is transparent because every mutation, crossover, and rationale is recorded. Prior neural approaches reveal correlations after training; CACHEFORGE reveals the algorithm as it is created.

The remainder of this paper formalizes this approach and demonstrates that governed code-space evolution can synthesize compact, high-performance replacement mechanisms beyond the reach of fixed representations.

Contributions. This paper makes four contributions:

• Generative code-space evolution for cache replacement. We introduce CACHEFORGE, the first system that treats a replacement policy as mutable code, allowing the LLM to rewrite control flow, metadata structures, decision rules, and scoring logic, while a trace-based ChampSim evaluator provides causal feedback and enforces feasibility. This moves beyond fixed representations such as IPV vectors, RRIP templates, or MPPPB feature libraries, enabling algorithmic forms no prior framework can express autonomously.

• Autonomous discovery of high-performance and hardware-efficient mechanisms. Governed evolution synthesizes compact policies that surpass all CRC-2 baselines. Across SPEC CPU2006, CACHEFORGE improves IPC by 10.15%, 7.89%, 6.34%, 3.64%, 3.12%, and 2.71% over LRU, MPPPB, LiMe, ReD, SHiP++, and Hawkeye, and raises total hit rate by 27.36%, 19.69%, 13.72%, 13.15%, 11.83%, and 5.73% over MPPPB, ReD, Hawkeye, SHiP++, LiMe, and LRU. It simultaneously reduces metadata overhead by 43% relative to MPPPB and delivers the highest IPC-per-KB efficiency among all evaluated designs.

• Comprehensive analysis of novel policies and sensitivity study. We identify 21 novel design components and several algorithmic hybrids synthesized only through code-space evolution, including SPARC+, TADPIP, RSP-MPPP, and SAGE-MPPPB. Sensitivity studies show how memory, temperature, mutation rate, prompt, and seed diversity shape convergence among 10,687 generated policies.

Paper Organization: Section II provides background and related work. Section III presents the CACHEFORGE design. Section IV describes our evaluation methodology. Section V reports experimental results. Section VII provides sensitivity analysis. Section VIII concludes the paper.

References (25)