updated 2026-11-26·6 min read
Overview
Context-budgeted AST subgraph slicing, specificity-damped spectral diffusion, and local Gemma 4 defect localization.
Perron started as a competition entry chasing a graph retrieval trick for small 2B and 4B open-weights code models (Gemma 4 E2B and E4B), until the first clean benchmarks came back and hit the same wall: turns out, graphs don’t help small models. A negative result is a valid finish line, albeit an unsatisfying one, so I kept pushing the draft through ablations to see why graph expansion chokes under 4-bit NF4 VRAM budgets (6698.9 MB on E2B, 9648.4 MB resident on E4B due to unquantized Per-Layer Embeddings).
Pairing memory-mapped CSR diffusion with specificity hub-damping and candidate horizon pruning turns that autopsy into a fast local retriever across 344 held-out SWE-bench Verified tasks (named after Perron-Frobenius / Oskar Perron mostly just for nice math flavor, I guess).
Why Code Graphs Kept Breaking on Small Models
On paper, walking a repository’s call graph sounds like free recall. In practice, running random walks over real Python repos on a single GPU kept breaking in four specific ways:
- Disconnected components: Real codebases aren’t clean, irreducible Markov chains. Dangling sinks and 14 disconnected components mean the second eigenvalue sits at (not , as an early draft assumed), forcing ~86 power iterations to converge. I also tried an Ihara-Bass non-backtracking operator to fix edge bounce, then dropped it pretty fast when it broke probability conservation (
sum = 0.6545) on directed graphs and ran 50 to 100x slower. - The
logging.getLoggersink: Unweighted Personalized PageRank pours probability mass straight into shared utilities (logging.getLogger,utils.check_type), eating up to 90% of top-10 slots and leaving a0.0%Hub Suppression Index. - The class-method shortcut: A lot of what looked like “multi-hop reasoning” was actually
(class, method)containment edges, which accounted for72.99%of 1-hop additions (26.59%of all graph edges) and pointed inside the exact same file90.74%of the time. - Small-model ceilings: Unassisted 2B models lose discrimination once you leave obvious lexical seeds (
AUCdrops from0.7966to0.6596, below Bamber’s0.830break-even line for a 25-item pool). Asking Gemma 4 for listwise JSON rankings didn’t save it either, for JSON syntax collapsed on90.8%(119/131) of tasks.

How the Retriever Works
To keep memory under 3 MB and stop utility hubs from flooding the context window, Perron runs five steps straight over memory-mapped .npy arrays:
- Memory-Mapped CSR Matrices
Compile call (0.50), inherit (0.25), import (0.15), and caller (0.10) layers into uncompressed .npy CSR arrays loaded via mmap_mode="r" in under 1.0 ms.
- Sharp Softmax Seed Prior
Map candidate cosine similarities with temperature tau = 0.15 using float64 log-sum-exp normalization to build a sharp query teleport vector p_0.
- Sparse Personalized PageRank
Iterate power-method steps with damping beta = 0.85 for 86+ iterations until L1 residual drops below 1e-6.
- Specificity Hub-Damping
Divide query stationary mass by (pi_global(v) + eps)^0.70 while masking test nodes, reaching 99.5% HSI@10 without hard blocklists.
- Token-Budgeted AST Packing
Partition budgets across connected components (up to 3,480 prompt tokens) and pack target-first AST breadcrumbs.
Diffusion & Specificity Equations
Given multiplex edge weights and row sums , the sparse iteration and post-walk specificity score are:
Quickstart and MCP Integration
Python API
import perron
result = perron.diffuse_with_provenance(
query="Fix username validation regex boundary condition",
repo_path="./my_repo",
top_k=5,
)
for candidate in result:
print(f"[{candidate.score:.4f}] {candidate.identifier} ({candidate.call_path})")
MCP Stdio Server
{
"mcpServers": {
"perron": {
"command": "perron-mcp",
"args": ["--repo", "${workspaceFolder}"]
}
}
}
perron/mcp_server.py exposes three JSON-RPC tools: retrieve_context, inspect_symbol_breadcrumbs, and build_code_graph. Cold-starting perron-mcp takes 2.38 s, after which warm CSR queries settle into 1.89 to 5.10 ms.
Hardware Regimes (Where Things Actually Landed)
Across 344 Verified tasks, the hardware ceiling determines which interventions are worth running:
| Tier | Hardware Envelope | Key Intervention | Empirical Outcome |
|---|---|---|---|
| CPU Pre-Filter | 1.89 to 5.10 ms warm, under 3 MB RAM | CSR diffusion () + selective routing | 99.5% HSI@10; cuts LLM candidate budget 31.4% at 58.4% recall |
| Edge (2B) | gemma-4-e2b-it (6698.9 MB / 6.7 GB VRAM) | Inline provenance comments (E1, thinking off) | Lifts reachable Top-1 from 12.07% to 25.86% (; thinking hurts 2B) |
| Workstation (4B) | gemma-4-e4b-it (9648.4 MB VRAM) | Pointwise log-odds on A4[:15] () | 22.90% Acc@5, 12.21% Top-1, MRR 0.1740 (beats listwise C1 at 15.27%, ; matches depth BM25 23.66%) |
| Cluster MoE | gemma-4-26b-a4b-it (52.0 GB FP16) | Fused 3D expert tensors bypass 2D NF4 hooks | Exceeds Dual T4 (29.1 GB); sets the commodity GPU boundary |

Specification Map
Inventory of perron/, benchmarks/, scripts/, tests/, and the 14 retrieval baselines.
Function Acc@K, File Acc@K, Coverage@4k, HSI@10, Bamber bounds, and GoldPatchParser.
Subset H vs N results, HEADLINE macro-averaging, and N = 344 Verified attrition bounds.
8-node toy graph sanity checks, dev_val post-audit reruns, and caught evaluation bugs.
Gebru et al. datasheet for 707 strata annotations, 12 CSR multigraphs, and 27,411 Parquet rows.
Split quarantine rules, frozen hyperparameters, and what actually failed or came back inconclusive.
Continue to Repository Map & Modules, Evaluation Metrics, or Hub-Gold & SWE-bench Benchmarks. For dataset provenance and what happened to the preregistered tests, see Dataset Datasheet, Preregistration v1 (Lite), and Preregistration v2 (Verified).