Skip to content

The embedder holds its need: a window-bounded context, a floor set by grants and lowered by releases - #5996

Merged
joelteply merged 2 commits into
canaryfrom
fable/the-embedder-holds-its-need
Nov 14, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fable/the-embedder-holds-its-need

Conversation

@joelteply

@joelteply joelteply commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Serves residents' recall (perception/RAG relevance) and the one memory budget (plan line 3/3b). When the embed lane is refused, embeddings drop to no-relevance and minds lose recall.

Receipts (the M5, 64 GB unified, canary 958ea30, 2026-11-14)

  • embed.vram.refused fired 12 times since boot. At 03:35Z: requested 14,205,059,072 B (13,547 MiB) against 13,915,160,576 B available, followed by embedding.neural.failed.
  • At 01:22Z and still at the tail of continuum-probes.jsonl: requested 186,908,672 B against available=0 (the device-room half, fixed by The boot counts the device room, the embed floor outside it #5993).

Cause

  1. 13.5 GiB context. backends/llamacpp/embedding_batch.rs, EmbeddingBatch::tokenize (canary L88-97) planned every text against model.n_ctx_train(), which is 32,768 for Qwen3-Embedding-0.6B. The context is sized to the widest piece (L113-115, n_ctx = n_batch = n_ubatch = widest, L119-125). At the measured rates (KV 28 MiB and device compute 150.25 MiB per 256 tokens, L45-47), a 19,456-token text costs 2,128 + 11,419 = 13,547 MiB = 14,205,059,072 B, the receipt's exact request. Nothing upstream chunks: callers (memory/mod.rs:206,341, recall_faculty.rs:399, tool_embedding.rs) embed texts whole. The window plan inside EmbeddingBatch is the only chunker, and its span was the trained context. It was not a copy of the serving lane's window.
  2. Floor ratchet. inference/embed_lane_memory.rs L38: floor.fetch_max(part) and then daemon.reserve(embed, pool, floor) ran before lease_part. So a request, granted or refused, raised the standing floor permanently, and serving's boot sizing (room_beside_others, The boot counts the device room, the embed floor outside it #5993) kept 13.5 GiB out for the embedder for the rest of the process.

Fix, at the owners

  • EmbedWindow (embedding_batch.rs): the window is min(n_ctx_train, 2,048), where 2,048 is the top of the range the cost rates were measured over (256 to 2,048, ~/.continuum/evidence/replicate-2026-11-10/). A longer text is embedded in windows of it, every text token once, combined by the existing token-weighted mean. The widest context is now at most 1,426 MiB on the device.
  • Frame: windows carry the model's special tokens on the side the model puts them. The Qwen3-Embedding GGUF on the M5 reads add_bos_token False, add_eos_token True, so tokenize("") is [EOS], which no text begins with. The old prefix-only window (tokens.starts_with(prefix)) refused every Qwen3 text that needed windows. That was a latent defect above 32,768 tokens; with a 2,048-token window it would have broken every long text.
  • EmbedNeed (embed_lane_memory.rs, from LlamaCppBackend::embed_need): weights (the model file's length, placed like a context) plus the window's context. A request larger than the window's context returns EmbedLeaseError::Oversized before anything is reserved.
  • Floor = working set: weights + the contexts the lane is granted, set at a grant and lowered at the release (EmbedLease's Drop). A refusal never touches it. EmbedLeaseError { Oversized, Refused, Ungoverned } replaces the Result<_, String> in this module.

Dyno, from these receipts

before after
19,456-token text: device context 14,205,059,072 B (whole, 32,768 limit) 1,495,269,376 B (2,048-token windows)
a refused 13.5 GiB request: floor raised to 13.5 GiB (fetch_max) Oversized, floor unchanged
capacity refusal: floor raised to the request unchanged
release: floor never lowered back to the weights
embedder's whole claim beside the 661,410-token engine (38.3 GB of 55.66 GB device, dyno 14) no fit at 13.5 GiB with host free 0.1 GB weights 0.64 GB + 1.49 GB fits

Pinned tests (what this catches on each)

  • embedding_batch::tests::an_embed_context_derives_from_the_window_never_the_trained_context: the receipt's 14,205,059,072 B before, the window after.
  • embedding_batch::tests::a_tail_framed_text_is_windowed_with_its_tail: Qwen3's trailing EOS.
  • embed_lane_memory::tests::a_refused_request_leaves_the_floor_unchanged: oversized and capacity refusals.
  • embed_lane_memory::tests::a_release_lowers_the_floor: both ways, and the fit beside the engine.
  • Existing window and combiner tests updated to the framed plan.

Not run locally: this machine serves live minds, so CI is the compiler.

Known tradeoffs

  • The weights in the floor are physically resident and unleased. available_for of other consumers therefore withholds them once more beyond physical_used: about 0.6 GB, on the conservative side. Follow-up: have the embedder declare measured residency (set_measured) so the floor is met by it.
  • Between embeds the floor is the weights only (as asked: nothing holds what it isn't using). A boot sizing at that instant can size into the next context's ≤1.4 GiB. Watch embed.vram.refused after deploy.
  • How windowing texts of 2,048 to 32,768 tokens affects recall ranking is not measured.

Lines

+456 / -95 across 7 files (+~200 of that is tests). All touched files are under 1,000 lines (embedding_batch.rs 451, embed_lane_memory.rs 370). Removed: the fetch_max floor statics, two Result<_, String> signatures and one map_err(format!) in embed_lane_memory. Added one .map_err(|e| e.to_string()) at the adapter's String trait seam and one map_err(format!) for the weights' file metadata in LlamaCppBackend::load (already Result<_, String>). Net stringly sites: -1.

Live check after deploy (owner: whoever deploys this; deadline: the first hour on the M5)

embed.vram.refused = 0 and embedding.neural.failed = 0 in ~/.continuum/probes/continuum-probes.jsonl, plus embed.vram.leased bytes ≤ 1,495,269,376 on the device.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

… grants and lowered by releases

The M5 (canary 958ea30, 2026-11-14 03:35Z): embed.vram.refused 12 times since boot, one embed
lease asking 14,205,059,072 B (13,547 MiB) beside 13,915,160,576 B, embedding.neural.failed, recall
lost the item. Two causes:

- embedding_batch.rs planned each text against the model's trained context (n_ctx_train, 32,768 for
  Qwen3-Embedding-0.6B), so a 19,456-token text sized a 13,547 MiB context. The window is now
  EmbedWindow: min(trained context, the 2,048 tokens the cost rates were measured over); a longer
  text is embedded in windows, every token once.
- embed_lane_memory.rs raised the standing floor to every REQUEST with fetch_max before leasing, so
  that one refused request reserved 13.5 GiB for the rest of the process. The floor is now the lane's
  working set: its weights plus the contexts it is granted, set at a grant and lowered at the
  release (EmbedLease's Drop); a refusal never touches it. A request past the window's context is a
  typed refusal (EmbedLeaseError::Oversized) before any reservation.

Windows are framed by the model's special tokens on the side the model puts them (Frame): the
Qwen3-Embedding GGUF has add_bos_token false and add_eos_token true, so tokenize("") is [EOS], which
no text begins with. The old prefix-only window refused every Qwen3 text that needed windows.

Pinned: an_embed_context_derives_from_the_window_never_the_trained_context (dyno: the receipt's
14,205,059,072 B before, a 2,048-token window after), a_tail_framed_text_is_windowed_with_its_tail,
a_refused_request_leaves_the_floor_unchanged, a_release_lowers_the_floor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit 92bcee6 into canary Nov 14, 2026
58 of 61 checks passed
@joelteply
joelteply deleted the fable/the-embedder-holds-its-need branch November 14, 2026 05:52
joelteply added a commit that referenced this pull request Nov 14, 2026
…er-outcome wait

Keeps #5996's typed lease (EmbedLeaseError, floor raised on grant and lowered on release).
The wait answers with the authority's own outcome: Published (the only retry), StillShort
on its next board (typed Refused), AuthorityClosed (new typed terminal variant). No timeout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Nov 14, 2026
…en embeds, cleared only when it unloads (#6006)

The M5 (canary 7f875cc, engine -c 551865, booted ~07:52Z 2026-11-14): after #5996 the embed requests
are small (186,908,672 and 373,817,344 B), but by 08:16Z embed.vram.refused = 13 and
embedding.neural.failed = 11, all at available=0. #5996's floor fell to the weights between embeds, so
the engine's pool and the other claims took the next context's room.

EmbedResidency (embed_lane_memory.rs) is the embed lane's resident claim: weights plus one window
context (~2.1 GB on the device at most), reserved per pool from the first embed and held by the
backend (LlamaCppBackend::embed_residency). It is cleared only in its Drop, when the embedder unloads.
Leases are granted inside it and never move it. #5993's room_beside_others counts the reservation, so
a boot or a regrowth sizes beside it. The LaneFloors grant/release bookkeeping is deleted.

Pinned: an_embed_after_an_idle_gap_is_granted_beside_an_engine_that_fills_the_room,
a_refused_request_leaves_the_floor_unchanged, unloading_the_embedder_clears_its_floor.


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Co-authored-by: Claude Opus 5.5 <[email protected]>
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