MOSAIC: Memory-Organized Search with Anti-Imitation Crossover for Training-Free Microarchitecture Optimization

Kaushal Mhapsekar, Bita Aslrousta, Paula Contreras, Azam Ghanbari, Samira Mirbagher AjorpazarXiv 2026

TL;DR

When asked to write hardware optimization code, Large Language Models (LLMs) tend to act like parrots—regurgitating slight tweaks of textbook algorithms that overfit to training benchmarks and fail in the wild. MOSAIC breaks this imitation cycle without updating a single LLM weight. By remembering concise lessons instead of raw code and mating structurally different solutions when progress stalls, it discovers genuinely novel CPU cache and prefetching policies that generalize to unseen workloads.

What Problem Does This Paper Address?

Inside your processor, the last-level cache acts as a high-speed staging ground for data. When it fills up, a cache-replacement policy decides what to evict. Guess right, and the CPU hums along; guess wrong, and it stalls waiting for main memory.

Recently, researchers have used LLMs in closed-loop evolutionary searches (like FunSearch and AlphaEvolve) to automatically write C++ code for optimization tasks. You generate candidates, test them in a simulator, and feed the winners back into the next prompt.

However, when applied to hardware microarchitecture, these search loops hit a wall the authors call the parrot problem. Because LLMs were trained on famous, published cache policies (like RRIP and Hawkeye), and because standard search loops repeatedly paste high-scoring code back into the prompt, the search rapidly converges on slight parameter tweaks of textbook designs. These tweaked policies look great on the specific workload used during the search, but their performance plummets on held-out, unseen programs.

Figure 2: Code similarity over 50 iterations. The vertical axis shows cosine similarity to the nearest refer- ence policy (LRU, SHiP++, Hawkeye). Red (≥0.78) and green (< 0.55) mark high- and low-similarity ranges for generated code; mechanism-level novelty is evaluated separately (Appendix B.9). The AlphaEvolve- , FunSearch-, and Graph-of-Thought-adapted configurations enter the high-similarity range at approximately iterations 7, 11, and 15. MOSAIC remains in the 0.50–0.66 range; crossover events C1–C4 occur at iterations 12, 22, 34, 42.

Methods

MOSAIC (Memory-Organized Search with Anti-Imitation Crossover) keeps the LLM weights completely frozen, upgrading the search controller around a standard hardware simulator (ChampSim) through key interventions:

  • Summary Memory over Code Replay: Instead of stuffing the prompt with top-scoring C++ snippets, an LLM distills past simulator runs into a compact, 32-row notebook of natural-language lessons categorized into PRINCIPLES, DONTS, KNOBS, and OPEN-Q.
  • Novelty Pressure: Prompts deterministically nudge the LLM to inspect what mechanisms have already been tried in memory and propose something structurally distinct.
  • Anti-Imitation Crossover: When performance plateaus, MOSAIC stops single-parent tweaking. Instead, it grabs a top-scoring policy and searches the archive for a second high-performing parent with the most different code embedding (lowest cosine similarity), prompting the LLM to hybridize their distinct mechanisms.
  • Model Rotation: Upon stagnation, the controller rotates through a pool of four foundation models (gpt-oss-20b, Qwen3-Coder, Gemini 2.5 Pro, and o4-mini), benching whichever model has been acting the most like a textbook parrot.

Datasets

  • Evaluation Benchmarks: Evaluated using the ChampSim simulator on 10 memory-intensive SPEC CPU 2006 workloads (traces where standard Least-Recently-Used caching gets <80% hit rates, ensuring cache decisions actually matter), tested via strict leave-one-out and 7/3 train-test cross-validation splits.
  • New Corpus: The authors introduce a dataset of 10,687 generated policies, complete with evolutionary lineage, prompt logs, memory states, and simulator outcomes to help researchers study code-search dynamics.

Key Insights and Ideas

  • Smarter search beats bigger models: Swapping in a stronger reasoning model (o4-mini) improved held-out hit rates by just 0.4 percentage points. Meanwhile, MOSAIC’s stagnation-triggered crossover contributed 21.8 percentage points to generalization. How you organize memory and parent selection matters vastly more than raw model scale.
  • Replay buffers breed overfitting: Feeding top-scoring code back as in-context examples traps the LLM in a local optimum—driving cosine similarity to canonical policies up to 0.78–0.84 within 15 iterations. Abstracting feedback into text lessons breaks this loop.
  • Zero-retuning task transfer: Because the controller's logic is domain-agnostic, simply swapping the interface contract and reward signal allowed MOSAIC to pivot from cache eviction to data prefetching (predicting and fetching data before the CPU asks for it) right out of the box.

Key Results

  • Superior Generalization: MOSAIC reaches a 51.1% peak hit rate on the primary search workload (omnetpp) and maintains a 47.9% mean hit rate on held-out workloads—dropping only 3.2 points, whereas AlphaEvolve and Graph-of-Thought adaptations drop 11.5 to 12.5 points.
Figure 4: Held-out gap under the five-workload, four-fold leave-one-held-out protocol. Each row is one method; the filled disc is peak hit rate on the search workload (omnetpp); the four open circles are peak hit rates on the held-out folds (bzip2, hmmer, soplex, gobmk); the connector spans the gap and ∆reports the mean train-vs-test drop. MOSAIC drops 3.2 points and exceeds MockingJay on every fold; AlphaEvolve and GoT drop 11–13 points into a band that ties or trails MockingJay. The complementary wide-catalogue stress test against nine LLM-driven configurations (P1–P9) is reported in Appendix B.10, Figure 11.
  • Beating Human & Learned Baselines: Across the 10-workload suite, MOSAIC is the only LLM search method to outperform MockingJay (the strongest published machine-learning baseline) on every single workload, achieving the highest held-out instructions-per-cycle (IPC) with a tiny 0.31% train-test gap.
  • Hardware Realistic: Using an estimator called HARCOM, MOSAIC's winning policies stay comfortably inside strict silicon budgets ($\le 20\text{ KiB}$ storage, $\le 25\text{ mW}$ power, $\le 400\text{ ps}$ latency).
  • Prefetching Speedup: When applied to data prefetching, MOSAIC achieved a 4.8% mean speedup over the standard LRU reference configuration while respecting a strict 32 KiB metadata limit.

Limitations and Future Work

  • Single-Core Scope: All simulator evaluations in the main study use a single-core configuration; multi-core cache contention dynamics are not evaluated here.
  • Operator-in-the-Loop Memory Edits: While memory updates are automated, the controlled "memory edit" interventions (like forced forgetting of a specific mechanism or rewriting over-generalized DONTS) required human operator intervention before resuming automatic search.
  • Planned Releases: For future work, the authors plan to publicly release their 10,687-policy lineage corpus alongside the HARCOM hardware-cost estimator and calibration scripts to enable hardware-budget-aware program synthesis.

Summary updated

Abstract

Large language models can generate cache-replacement policies. The central challenge is to retain performance on workloads excluded from the search. In our adaptations of published search methods, generated code resembles established policies, with cosine similarities of 0.78-0.84. The wider comparison also shows held-out harmonic-mean instructions-per-cycle (IPC) losses of 1.0-2.4%. We present MOSAIC, a search controller that improves policies without updating language-model weights. It stores concise lessons from previous evaluations rather than repeatedly copying high-scoring code. When improvement stops, it selects two high-scoring policies whose code embeddings differ and asks the model to combine their mechanisms. Novelty prompts and model rotation support this search; controlled memory edits test how the stored lessons affect later proposals. We evaluate cache replacement using intervention-level cross-validation and a wider comparison on ten memory-intensive SPEC2006 workloads. MOSAIC reaches a 51.1% peak hit rate on the primary search workload and a 47.9% held-out mean in the intervention study. Removing crossover reduces these values by 7.8 and 21.8 percentage points, respectively, whereas the tested stronger model improves the held-out mean by 0.4 points. In the wider IPC comparison, MOSAIC has the smallest held-out gap (0.31%) and the highest held-out IPC among the evaluated LLM configurations. Adapting the same controller to data prefetching gives a 4.8% mean speedup over the LRU reference configuration. The accompanying corpus contains 10,687 generated policies with lineage and per-iteration prompt logs.
BibTeX
@misc{mhapsekar2026mosaic,
  author = {Kaushal Mhapsekar and Bita Aslrousta and Paula Contreras and Azam Ghanbari and Samira Mirbagher Ajorpaz},
  title = {{MOSAIC: Memory-Organized Search with Anti-Imitation Crossover for Training-Free Microarchitecture Optimization}},
  year = {2026},
  eprint = {2611.31733},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.31733},
}
Figure