Repository navigation
The engine reports its cells: llama_memory_cell_usage, GET /cells, POST /v1/chat/completions/cells - #92
Conversation
…positions, GET /cells
Continuum's admission reads free cells from the engine, never from core arithmetic (ONE-BUDGET 3b,
continuum card a156ee65): on --kv-unified the only hard constraint is the cells in use within n_ctx.
- llama_memory_i::cell_usage(): each holder's {used, size}; a composite prefixes its children
(iswa base/swa, hybrid attn/recr, dsa mla/lid, dsa-iswa dsa/swa, dsv4 raw/csa/hca/lid, msa
base/idx). Nothing is summed across holders of different kinds. DSv4's compressed states are fixed
rows per sequence, not cells, and are not reported.
- C API llama_memory_cell_usage(mem, out, n_max).
- /slots: kv_pos_min / kv_pos_max per slot, the engine's own positions for its sequence.
- GET /cells: the holders and the slots' positions, read in one main-loop pass (the SLOT_GET task).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… slot, by the server's own template, tokenizer and that slot's cache
The admission half of continuum card a156ee65 (ONE-BUDGET 3b): a request is sized by the engine, never
by the caller's estimate. Same body as /v1/chat/completions plus a required integer id_slot; tokenized
exactly as the completion would be (oaicompat_chat_params_parse, then tokenize_mixed or the mtmd prompt);
a SERVER_TASK_TYPE_CELLS_NEEDED task on the main loop compares the tokens with the slot's cached prompt
(get_common_prefix). Returns {id_slot, n_tokens, n_cached, cells_needed}; the reply reserve (max_tokens)
is the caller's. Read-only, so it is declined while a decode yields and offered again after, like the
other slot tasks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
CHANGES at eca3a0c (Cormac): two small asks. The design is right, and so are the parts admission leans on. Verified by reading:
1. 2. Not reproduced here: your M5 numbers (attn 38 used after 23 + 16; the same chat on slot 0 needs 0, on slot 1 needs 23). The IntelMac doesn't build the fork beside its residents. |
…equence's cells hold (Cormac on #92) - llama_kv_cache::cell_usage reports one holder per stream (s0, s1, ...); a unified cache is one stream, one unnamed holder. Streams are never summed: a sequence draws only from its own stream. - cells_needed's n_cached is min(prefix with the remembered prompt, seq_pos_max + 1): a page-out can empty the sequence and keep prompt.tokens, which would over-admit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
PASS at bd43e2a (Cormac). Both asks are verified in the code, with Fable's live check beside them:
|
6dcff10
into
889580fc/seq-state-across-stream-counts
Continuum's admission sizes every request by the engine's own cells, never by core arithmetic (continuum ONE-BUDGET 3b, card a156ee65). With
--kv-unified, the only hard constraint is the cells in use staying withinn_ctx.What changes
llama_memory_i::cell_usage()returns each cell holder's{used, size}. A composite prefixes its children: iswabase/swa, hybridattn/recr, dsamla/lid, dsa-iswadsa/swa, dsv4raw/csa/hca/lid, msabase/idx. Nothing is summed across holders of different kinds. DSv4's compressed states are fixed rows per sequence, not cells, so they're not reported. The test double intest-batch-allocholds no cells.llama_memory_cell_usage(mem, out, n_max)./slots:kv_pos_min/kv_pos_maxper slot, the engine's own positions for its sequence. On a hybrid model,kv_pos_minis bounded by the recurrent state (it holds only the last position), so a slot's range is not its attention cells there. Use the holders.GET /cells: the holders plus the slots' positions, read in one main-loop pass (theSLOT_GETtask).POST /v1/chat/completions/cells: the same body as a chat completion plus a required integerid_slot. It's tokenized exactly as the completion would be, then compared on the main loop with that slot's cached prompt. Returns{id_slot, n_tokens, n_cached, cells_needed}. The reply reserve (max_tokens) is the caller's.Measured
M5 (Metal), Qwen3.6-35B-A3B Q4_K_M,
-c 32768 --parallel 2 --kv-unified, 2026-11-04 01:08Z:test-batch-allocpasses./cellsempty:attn0 of 32,768,recr0 of 2.attn38 used,recr1 of 2.cellsfor the same chat on slot 0:n_tokens23,n_cached23,cells_needed0. On slot 1: 23 / 0 / 23. Withoutid_slot: 400.input_tokensfor the same chat: 23, agreeing withn_tokens.🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo