Skip to content

A queued mind waits her turn; an embedding leases what its own context allocates - #5906

Merged
joelteply merged 3 commits into
canaryfrom
fable/wait-your-turn-and-lease-what-you-use
Nov 10, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fable/wait-your-turn-and-lease-what-you-use

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Serves the residents' health (path step 1, fast, and their recall). Two places where a short resource turned into a failure instead of a wait or a fit.

What changes

A queued mind waits her turn (capacity/mind_window.rs, window_grant.rs)

  • Before: a mind queued for room had her turn refused and her whole view re-rendered, every publisher beat.
  • Now: queued, reclaiming, or engine relaunching (Ungranted::awaits_room) waits for a later evaluation, with her demand standing and her view measured once.
  • Any other reason still refuses within one cadence, named.

An embedding leases what its own context allocates (backends/llamacpp/embedding_batch.rs, llamacpp_adapter.rs)

The touched adapter leaves clean

  • The two lease attempts are explicit, and a refusal carries the availability it measured.
  • The media item is matched, not unwrapped.
  • Absent lists are flattened instead of defaulted.
  • Display defaults and the TTL say why they hold.

Measured

  • Windows, before (M5, 26960c0, 60 min): 186 delib.window.refused with "Queued { position: 2, of: 2 }" (Aiko 64, Atlas 61, Benchy 50, Aris 11). Each was a settle.inference_failed, about 10 s apart.
  • Embeddings, before (M5, 26960c0, 3 h): 76 leased against 758 failed, 1,526 embed.vram.refused with 1.5–1.7 GiB governed-available.
  • Per-token cost (engine-c, Qwen3-Embedding-0.6B Q8_0, flash attention on, 2026-11-10): context buffers at n_ctx = n_batch = n_ubatch of 256, 512, 1,024 and 2,048.
    • Metal KV is 28, 56, 112 and 224 MiB.
    • Metal compute is 150.25, 300.74, 602.48 and 1,200.96 MiB.
    • CPU compute is 2.13 to 24.05 MiB.
    • Output is 0.58 MiB.
    • That is linear within 0.1%. A short text leases about 182 MiB.
  • Live (M5, 2d9ce06, deployed 10:47Z on the stacked branch): the 15-minute read follows in a comment.
  • Local tests on the stacked branch: continuum-engine 1,527 passed and continuum-cognition 985 passed (serving-down window, 10:40Z).
  • Not yet tested locally: the windowing integration on this canary base. CI compiles it, and it gets a local window before merge.

Follow-ups

  • A text over the model's context is windowed at the model's 32,768-token limit. By the measured cost that context is about 23 GB, so its lease is now refused honestly; canary leased 1,792 MiB and risked an out-of-memory decode. Windowing at what memory allows is the fix (card to file with this PR).
  • The per-token constant belongs to the fork: a context-measure API in the fork (llama_context_measure) would report it before a context exists.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 3 commits November 10, 2026 04:48
On the M5 (26960c0) a mind queued behind others for room had her turn refused and
re-measured every publisher beat: 186 settle.inference_failed an hour, each one a full view
render. Queued, reclaiming, and an engine relaunching (Ungranted::awaits_room) now wait for a
later evaluation with her demand standing; any other reason still refuses within one cadence,
named.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
The embed lane leased a fixed 1,792 MiB (a 2,048-token context) for every call; with
1.5-1.7 GiB free on the M5, 758 of 834 embeddings in 3 h were refused (26960c0), so her
recall ran mostly dark. EmbeddingBatch tokenizes first and leases its padded window times the
measured per-token cost (engine-c, Qwen3-Embedding-0.6B, linear within 0.1% at 256-2,048
tokens): a short text leases ~182 MiB. The standing floor is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…padding has one owner

- The lease's two attempts are explicit: a second refusal carries the availability it measured,
  never a defaulted 0.
- The media path matches its one item instead of unwrapping it; genes and stop sequences flatten
  an absent list instead of defaulting it; display defaults and the trained-ceiling default say
  why; the lease TTL says it is a SIGKILL backstop only.
- llama pads every context to 256 tokens (GGML_PAD in llama-context.cpp): ContextParams::
  allocated_n_ctx in the llama crate is that fact's one owner, where EmbeddingBatch prices it.
- The queued-mind test's closure moves the id it captures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Measured live (M5, 2d9ce06, stacked branch, deployed 10:47:37Z; read 15.5 min)

  • delib.window.refused: 0 (before: 186 in 60 min on 26960c0).
  • Embeddings: 22 leased, 2 refused, 1 failed (before: about 6 leased and 63 failed per 15 min).
  • First act after the restart: 37 s. Acts across four residents: 39 (before: about 26 per 15 min).
  • over_window: none.

@joelteply
joelteply merged commit fb5dea2 into canary Nov 10, 2026
31 checks passed
@joelteply
joelteply deleted the fable/wait-your-turn-and-lease-what-you-use branch November 10, 2026 11:10
@joelteply

Copy link
Copy Markdown
Contributor Author

Not yet verified on CUDA or Windows. CONTEXT_BYTES_PER_TOKEN (742,426 B/token) was measured on Metal only. On CUDA, measure the embed context's buffers with the recipe in ~/.continuum/evidence/replicate-2026-11-10/REPLICATE.md (M5). If CUDA's per-token cost is larger, the lease under-asks there. Handed to Codex on airc; card 9bddda93 tracks moving the number into the fork.

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