Design only, CPU-only analysis; nothing measured on the server. Finds that the 55.3 GB sealed memfd is read only for the 16.0 GB of PLE rows
and that ~39 GB of it is an unread level-2 re-encoding of shard 0 (estimate, census task T1).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Behaviour changes only on failure paths: a verifier graph that runs out of device
memory now costs the widest windows instead of the engine; a PLE source that panics
is a failed read instead of a ticket that waits forever; a restored conversation's
retained K/V never serves another conversation.
NOT exercised on a GPU (server down): the instantiate-OOM fallback. The merge is
acceptable because it changes behaviour only on the failure path. Tests in WSL
(mock driver): leleka-runtime 618 pass / 2 known backing:: failures, leleka-cuda-driver
(--features cuda-driver) 418 pass / 0 fail, leleka-model-format 139 pass / 3 known
sec_uc143_*/retained_fd failures (all /mnt/c, same as base).
Adds a narrow .gitattributes (text=auto eol=lf for crates/**/*.rs and
scripts/gpu-bringup/**/*.py) to keep CRLF out of these LF files.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Ten files touched by this branch had been rewritten with CRLF line endings
(base versions are LF), inflating the diff against the merge-base to
13685/13039 lines. Content is otherwise unchanged: the diff ignoring line
endings was and remains 661 insertions / 15 deletions.
.gitattributes: crates/**/*.rs and scripts/gpu-bringup/**/*.py are text=auto
eol=lf, so CRLF cannot re-enter these LF files at commit time. text=auto leaves
files that are already CRLF in the index untouched.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merges the decode, kernels and CPU/platform reviews of Strata 41cf05a0..870aedd9 into one ranked
port list for Qwen3.8-Flash-Next IQ3_S + KAR + MTP on the 5090 and the 3080 (correctness and
hygiene 4.x, decode 5.x, prefill 6.x, laptop 7.x), with the state of each row from main and the
local branches (upstream-fixes, draft-vocab, models-move), the contradictions between the reviews
resolved, a paragraph on what upstream does not give (no 200+ tok/s at 245k), and the next ports
in order with the GPU they need. Every number is marked measured, claimed by upstream, estimate
or unverified. Old rows updated: 2.1 (default OFF, no e2e gain), 3.1 (not the cause of the 5090
gap), 3.3 (pa-pcie35 slightly worse), 2.6 (closed), 2.2, 3.2, 3.4 (pointers).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Adds Options::recovery to tool_output and an opt-in setting, `tool_call_recovery` (config key) / STRATA_TOOL_CALL_RECOVERY=1
(environment, wins over the file; 0/false turns it off; anything else stops the start). It is off unless set, is read once at
start, logs "tool_call_recovery is ON (experimental)" at start, and logs every call it accepts. It is NOT part of the default
contract and has not passed a quality gate (docs/api-contract.md, "Tool-call recovery (experimental)").
With it on, a call for a DECLARED tool written next to the template form is read as the call (upstream 3fcb2106, #3441):
* <parameter=NAME> where <function=NAME> belongs; <=NAME>, <function:NAME>, <function =NAME> or <NAME> after <tool_call>;
* {"name": ..., "arguments": {...}} inside <tool_call>, also in a Markdown fence, arguments possibly a JSON string;
* a bare <function=NAME> ... </function> at the start of a line outside a code fence and inline code (a stray </tool_call>
after it is dropped); the Markdown state is tracked over the text that has left the stream buffer, so streamed and whole
readings agree;
* a second call in the same <tool_call>;
* for array/object arguments, brackets left open at the end and a bare string where an object member belongs (dropped).
An undeclared name stays an error in every form. Streaming: a batch is delivered when its </tool_call> arrives, a bare call when
the text after it shows it is over or at the end.
With the option off the reading is byte for byte the step-3 reading. The corpus test now reads every specimen twice (off and on)
and lists the failures of each; every streamed cut agrees with the whole reading in both. Recovery rate on the 41 Qwen specimens:
off 24/41 (58.5 %), on 30/41 (73.2 %); the 6 specimens that need recovery: off 0/6, on 6/6. That is code reach on upstream's
failure corpus, not a rate for real sessions. strata-control lib 339 passed (new: 3 recovery tests, 1 config test), corpus and the
quoted-value shapes pass with the option on and off.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Four shapes that ended in response.failed (or 502 tool_call_parse_failed) are now calls, each logged on stderr as
"tool call accepted beyond the template form (closers supplied: N, arguments repaired: M, ...)":
* </function> left out: a </parameter> followed by </tool_call> ends the value and the call, but only when no </parameter>
followed by <parameter= or </function> ends the value (upstream d7113273, #4427/#4077). A streamed response delivers such
a call when the generation ends, not at its </tool_call>: only the end can tell it from </parameter></tool_call> quoted
inside a value.
* </tool_call> left out: the call is whole when the next <tool_call><function=NAME> follows its </function>, or when its
</function> ends a generation that stopped by itself (finish stop). A generation cut by the token limit never gets this.
* A call inside the reasoning (no </think>): a normal stop whose text ends on whole calls of declared tools, the first at
the start of a line outside a code fence and inline code, is reasoning (completed) followed by those calls (upstream
805ebe17/d7113273, #804). The calls' markup was already streamed as reasoning deltas; the final reasoning item ends before it.
* Damaged array/object arguments of a parameter declared array or object (not a union with string): a trailing or doubled
comma, single quotes, Python True/False/None, extra closing brackets, and an array written as a JSON string of itself are read
as written (upstream _Lenient, A4). Nothing is invented or dropped; open brackets and bare strings are not repaired here.
Undeclared tool names: upstream returns the call as text and counts it. That is NOT adopted. Text without a call ends an
agent's turn as if it were the answer, while a failed response is retried by the client (docs/e2e-run.md records a session that
survived one such failure), and native_tools_sdet / backend_worker_http pin the refusal. An undeclared tool is still an error;
it is never run and never published.
API: tool_output::{Options, Notes, Parsed, parse_with, calls_at_end}, Incremental::{with_options, finish_after, notes};
parse_complete and Incremental::new keep their strict default reading. Documented in docs/api-contract.md ("Tool-call
parsing") and docs/tool-call-corpus.md.
Corpus: 24 of 41 specimens read as upstream expects (13 before this commit). New unit tests cover each shape whole and
streamed; strata-control lib 334 passed, native_tools_sdet 14 passed, existing tests unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
tool_output::find_parameter_end ended a value at the first </parameter> followed by <parameter= or </function>, so a write
whose content quoted a whole call (a file that documents the format, a heredoc, a test) was published with content cut at the
quote and the rest as plain text, whole and streamed, without any error (upstream #4078, fixed there in 77794e34 and b72f56e0).
It now follows upstream's quote rule: a close inside a call the value itself quotes (more quoted <function=NAME> openers
followed by <parameter= or </function> than </function> closers before it) is part of the value. One forward pass over the
value. Incremental also stops re-trying candidate call ends it has already rejected.
A call whose value quotes an opener and never closes it is now unterminated (an error) instead of being cut at the first
plausible close, so a long write that quotes a call and is itself cut by the token limit is not published truncated.
Deliberately not taken from upstream: a value that reopens its own parameter (</parameter><parameter=content> inside content).
Upstream reads it as text; here it is byte for byte a parameter written twice, which desktop-core's
native_tools_sdet::unknown_incomplete_duplicate_or_late_invalid_call_refuses_entire_output requires to be refused, and merging
the two into one argument would hide a malformed call. It stays an error (duplicate tool parameter), listed as known failure.
Regression tests: specimens 4078-nested-call and 4078-heredoc and the quoted-value shapes "quoted call", "quoted call at the
end" and "heredoc" of the ported corpus failed on the previous commit and pass here (13 of 41 specimens, 5 of 6 shapes), plus a
unit test for the cut outer call. The 8 existing tool_output tests and the 14 native_tools_sdet tests pass unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Characterization test, no code change: A, B, A (restored, K/V retained), C (resume 0) and back to A, B, C, each restore checked cell by cell by the harness. The production serve stack binds no parking (NO_PARKING in original_serve_conversation.rs), so retain() is unreachable there; the library path clears the retained image with limit_reuse(read_from) at every request start.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The failed-read path of the reader itself already releases every ticket (upstream ebe3383a does not apply: the worker keeps running, issue after a failure queues nothing, collect reports the error), now pinned by tests with several tickets in flight at io_threads 0/1/2/default. The one remaining way to leave a ticket pending was a panic in PageSource::read_at: the worker thread died with the job's ticket still counted and the caller's collect blocked for ever. run() now turns a panic into the same sticky read error.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
cuGraphInstantiateWithFlags answering out of memory used to poison the whole CUDA context (every call after it failed, so the engine was lost; upstream a8c1d4b7 / 2a9a67c1). The refusal is not sticky and changes no state, so now:
- the instantiate step does not poison the context on that one code (every other failure still does), the half-built graph is destroyed, and a line is logged;
- a failed cuGraphUpload (a warm-up) is skipped with a line;
- OriginalVerifier::record_all names the graph that did not fit (Error::GraphOutOfMemory { window }, 0 = commit graph);
- the serve stack repeats the assembly with the windows that fit (assemble_with_window_fallback; owners come back from each failure), logs each step, and narrows the settings, controllers and MTP draft cap of every arm to the window it ended with, for the later requests too. No cap below T=2: a failure with nothing left is returned as before, but with the context intact.
Test hook for a card with room: LELEKA_TEST_WINDOW_INSTANTIATE_OOM_AT=N fails the N-th window instantiation once.
CPU tests: poison decision, error classification, cap computation, retry loop (terminates, stops at the floor, no retry on other errors), settings cap. Not verified on a GPU.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* scripts/e2e/decode/draftvocab-ab.sh: speedtrain3-ab shape, one binary in every arm, counterbalanced
base/en order, arms dv-base, dv-en, dv-en-eqslots; spec-stats give tokens per round, accepted/offered and
the accepted-length histogram; validity rejects fallback, missing or unexpected draft-vocab log lines
* scripts/e2e/decode/draftvocab-id.sh: teacher-forced replay with LELEKA_ORIGINAL_SERVE_RT_DIR set (the older
identity jobs draft over the full head), A/A floor, en against default, optional LELEKA_SPEC=3 control
* docs/experiments/2026-10-30-draft-vocab-en.md: what upstream does (format, digests, selection, default off),
our status, the port, expectations, what is not verified
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The MTP draft head projects over the rows listed in rt/draft_vocab.bin (106,299 ids). Upstream ships
draft_vocab_en.bin (40,525 ids, 65,774 head rows fewer: ~110 MiB of VRAM and a shorter draft GEMV, at the
price that CJK/Cyrillic tokens can never be proposed). LELEKA_DRAFT_VOCAB=en|cyrillic|fr|<path> picks one;
unset (or 0/off/default) keeps rt/draft_vocab.bin and reads, logs and changes nothing.
* a selected file must have the sha256 of a recorded upstream subset (a name: that name's digest);
another digest, a symlink, a wrong size or a too-large file is refused (the arm fails to load)
* a file that does not exist falls back to rt/draft_vocab.bin with one `FALLBACK` log line
* the startup VRAM reserve follows the selected file's size, so the freed VRAM reaches the expert slots
* one `leleka-serve draft-vocab: ... subset=en ids=40525 sha256=... file=...` line per bind when set
* sha2 becomes a dependency of leleka-cuda-driver (already in the workspace)
Unit tests (CPU only): setting parsing, table consistency, default reads/logs nothing, missing file
falls back, wrong digest refused for a name and a path, accepted digest reads the selected ids and the
reserve probe sees its size, malformed/oversized/symlink refused, subset index <-> full id round trip
and ids outside a subset. A real-file test runs when LELEKA_TEST_DRAFT_VOCAB_DIR names a directory
with the upstream draft_vocab*.bin (digests, counts, en ascending and inside the default list).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Read-only analysis of the sealed PTX (sm_120 and sm_86): the fused kernel and swiglu_entries_kernel + quantize_q8_1_kernel of mtp_original_full_head_iq (the window's routed-expert path) all use div.rn.f32; the fast-math quantizer copies (native_head_iq / native_head_native, div.approx.ftz.f32) are not used for this pair. CPU tests compare the numeric instruction multiset, flavour for flavour, and check a fast-math quantizer would be flagged. No kernel changed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
CUDA 13.2.0/13.2.1 miscompile some sm_120 kernels (IQ2_S/IQ3_S products wrong). validate_ptx (used by compile_assets and seal_pins) now reads the nvcc build from the PTX header and rejects those builds. A tree-wide test checks that every sealed PTX names a good build (today: none bad).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Adds the 49 specimens of Strata upstream's serve/test_tool_corpus.py (MIT, provenance and licence in
control-plane/tests/fixtures/tool_corpus/NOTICE.md; reporter handles removed) and the six quoted-call value shapes of
serve/test_quoted_call_values.py as control-plane/tests/tool_corpus.rs. 41 specimens are Qwen-form and run against
tool_output (whole through parse_complete, streamed through Incremental in pieces of 1/3/7 and cut at every character);
the 8 DSML specimens are skipped, there is no DSML parser here.
On main 11 of 41 specimens and 2 of 6 quoted value shapes are read as upstream expects. The rest are listed in
KNOWN_FAILURES / KNOWN_QUOTED_FAILURES (strict both ways: a listed specimen that starts passing fails the test) and in
docs/tool-call-corpus.md. No parser change in this commit.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Above 1 the usage counts grow without end (inf after a few hundred adaptations) and swap gains turn NaN, which breaks the swap sort; below 0 the counts flip sign (upstream 4a7e373d). Experiment knob only; the default is unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Desk review of the 145 engine commits in the range that touch CUDA kernels, prefill, KV,
memory planner, sm_120/sm_86 switches and build flags, with the port decision per series,
defaults changed upstream, bug fixes to take, and the order of work. Nothing was built or run.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Item table (SHAs, claimed gain with source, lossless/lossy, whether we have it,
applicability to the 5090 server and the 3080 laptop, effort, estimate, priority),
defaults changed upstream, bug fixes to take, negative results, and a model-free
probe showing that control-plane/src/tool_output.rs truncates a string argument that
quotes a tool call. No model or GPU run.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Table of every relevant upstream commit or series in speculation, tiers, window
kernels and routing, with claim sources, losslessness and gate, whether we have
it, effort, estimated gain and priority; defaults that changed; bug fixes to
take; pin-level features missing from the plan; recommended order; what may
explain upstream's tokens per round and round time. Read-only analysis, nothing
built or run.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Rewrite the 5090 server model paths in 30 repo files (scripts, tools, docs) from the old
locations (/home/para/leleka-gates, $HOME/leleka-gates, /data/models) to
/home/para/work/leleka/models/..., add the AGENTS.md workspace rule and the move record
docs/experiments/models-move.md. Not merged: the smoke test is pending.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A removed unowned folder turned the 245k corpus into a ~300-token session
without any error; inputs are now frozen, hashed and checked at run start.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Needed for the slot gain: the slabs save physical bytes the Context never charged, so the
budget must rise by about that much. Smoke with this budget: ~11,568 slots, lowest free VRAM
1,035 MiB. Also the systemd unit template, the config and reconfigure tests, and the docs.
Preflight now needs 31,299 MiB free at start (was 30,720; idle 5090 reports 32,110).
Revert by restoring 32212254720. Owner confirmation required before merge.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The reserve cut was not the cause (the budget was) but it is unproven on the card; per the conservative rule only the slab ships by default. The job runs
both arms with E2E_GPU_BUDGET 31,300 MiB (the slab's savings need budget headroom; the base is card-bound at either value) and RUN_TAG lets a rerun sit beside the
earlier run directories.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>