Skip to content

fix(cognition): shared single-flight embed resolver — kills the per-persona 1.2GB model-load storm - #2106

Merged
joelteply merged 1 commit into
canaryfrom
fix/shared-embed-resolver-single-flight
Aug 2, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/shared-embed-resolver-single-flight

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

The bug (BigMama's Windows spin, taken on per Joel: "take on her hard challenges")

102 llama_context creations × ~1200 MiB with zero IPC deltas — an internal storm eating memory out from under the governor. resolve_recall_embedder runs once per persona registration (re-run on every respawn), and each call constructed a fresh LlamaCppAdapter: full embed-GGUF load into a new context + probe + ~16 calibration passes. The "already cached by the resolver" comment at the call site was false — only content vectors were cached, never the resolution. Nine personas = nine resident embed contexts on EVERY node (M5 included); respawn churn on Windows made it a storm.

The fix

Testing

#225 (embed weights as governor ResourceConsumer) remains the accounting follow-up; this removes the multiplication.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

… model-load storm (BigMama's 102-context spin)

Glass-boxed live on the Windows node: 102 llama_context creations x
~1200 MiB with ZERO IPC deltas, eating memory out from under the
ResourceGovernor. Root cause: resolve_recall_embedder runs per persona
REGISTRATION (and registration re-runs on every respawn), and every call
built a FRESH LlamaCppAdapter — a full ~1.2 GB embed-GGUF load into a
new context, a probe, and ~16 calibration passes. The call-site comment
claimed "already cached by the resolver"; only content vectors were
cached, never the resolution. Nine personas = nine resident embed
contexts; respawn churn = the storm.

Fix: rung 1 (the in-process embed model) resolves through ONE
process-global cell. Success memoizes permanently and resolution is
single-flight (concurrent spawns share one load). Failure is never
memoized permanently — the #71 lesson: a late-arriving embed model must
still be adoptable — but re-attempts are rate-limited by a 60s cooldown,
capping the worst case at ~1 load/minute instead of one per respawn.

Regression test pins the invariant: three back-to-back failed resolves
cost at most ONE load attempt.

Also repairs two test call sites of PersonaInstanceManagerModule::new
that PR #2105 missed (its signature change compiled clean under `cargo
check` but broke `cargo test` builds — check does not compile test code).

Governor accounting follow-up stays #225 (register embed weights as a
ResourceConsumer); this fix removes the drift MULTIPLICATION.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply enabled auto-merge (squash) August 2, 2026 11:22
@joelteply
joelteply merged commit d800270 into canary Aug 2, 2026
@joelteply
joelteply deleted the fix/shared-embed-resolver-single-flight branch August 2, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant