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.
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, andOPEN-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, ando4-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.
- 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