Files
leleka/docs/upstream-review/cpu-and-platform.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 0ce233cd9b docs: upstream review 41cf05a0..870aedd9, CPU side, platform, protocol and agent sessions
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>
2026-10-30 03:09:13 +01:00

47 KiB

Upstream review: CPU side, platform, protocol and agent-session behaviour (41cf05a0 to 870aedd9)

Branch claude/upstream-review-cpu, from main e92513b7, 2026-10-30. Analyst: CPU and platform area (native CPU experts, worker pool, multi-GPU/pool, Windows/WSL/macOS, tokenizer/templates, Responses/Chat protocol and tool calls, conversation and prefix cache, launch defaults, profile data, telemetry, safety, memory governor, bug fixes). Other areas (CUDA decode/prefill kernels, DeepSeek, Metal, SYCL) are covered by other reviews; where a commit sits in shared code it is listed in section 7 only.

Nothing in this document was measured on a model. No GPU job was run and the server was not touched. The one thing that was executed is a model-free probe of our own control-plane/src/tool_output.rs (section 8). Every number labelled "claimed" is upstream's, on upstream's hardware. Numbers labelled "estimate" are mine, derived from our own documents, and are hypotheses to be measured.

0. What was read

Item Detail
Range git log 41cf05a0..strata-upstream/main (fetched 2026-10-30): 585 commits, 503 non-merge; tip 870aedd9 (2026-10-29, "[Engine] SYCL: the prompt attention batch is budgeted where it is allocated..."). Upstream history is not linear to the pin; the range is the set of commits reachable from main and not from the pin.
Releases in the range 0.2.6 (27a8ed96, Qwen engine stays 0.1.50, so "vanilla 0.2.6" in docs/laptop-vs-vanilla.md is the same engine as our pin), 0.2.7 (a42cc3d7, engine 0.1.52), 0.2.7.1 (1a937829, 0.1.53, DGX Spark / Mac only), 0.2.8 (36f6663c, engine 0.1.54). Release notes: docs/release-notes-0.2.7.md (read in full). There is no 0.2.8 notes file in the tree; 0.2.8 content was taken from the commit messages.
Commit filter git log --no-merges over src include serve strata_control tools data packaging setup.py excluding dsv41/Metal/SYCL/ds4/web paths: 227 commits. Every one was classified from its subject and file list; the ones that matter here (about 60) were read in full (message and diff). The other 276 non-merge commits are DeepSeek (174 by subject), SYCL (23), Metal, desktop app/web, docs and tests; they were skipped except for the release notes and docs/DETAILS.md, docs/TROUBLESHOOTING.md, docs/KVA.md, docs/SPLIT_SERVE.md, docs/BATCHING.md, docs/MULTI_GPU.md, docs/PROMPT_CACHE_TAIL.md diffs.
Our side compared docs/upstream-port-plan.md, docs/upstream-digest-2026-10-25.md, docs/upstream.md, docs/laptop-vs-vanilla.md, deploy/rust-runtime/profiles/rtx3080-16g.json, and a grep of crates/, control-plane/, desktop-core/ for each item (the evidence is in the "Have it?" column).
Not read Diffs of src/core/verify.cpp (772 lines) and src/prefill/prefill.cpp (2,034 lines) beyond the commit messages and the layer-major/KVA entry points; the GPU kernels (other review); apps/, serve/web/; the 1,462-turn drift corpus (not in the tree; only its 49-specimen subset serve/test_tool_corpus.py is).

Upstream is MIT (LICENSE: "Copyright (c) 2026 Niko1221 and the Strata contributors"), so test corpora can be adopted with a provenance line.

Priority legend: P0 correctness defect confirmed in our code, fix first; P1 do next, high expected value; P2 measure or opt-in first; P3 cheap hygiene; P4 later or only if a trigger appears; N do not port (reason given).

1. Summary

  1. A confirmed silent-corruption bug in our tool-call parser, and four ways a Codex turn dies that upstream now survives. Upstream #4078 (77794e34, b72f56e0): a string argument that itself contains a tool call (a file that documents the call format, a heredoc, a test) ends at the first quoted </parameter>. Our control-plane/src/tool_output.rs does exactly that: the probe in section 8 shows a write call emitted with its content cut mid-text and the rest published as plain text, whole and streamed. The other cases (call without </function>, call inside the reasoning, undeclared or mangled tool name, slightly broken JSON array) end in Err and so in a failed response, or in a string where the schema wants an array. These are the top of AGENTS.md priority 1 (protocol correctness, tool-call integrity). Items A1 to A6, all lossless, mostly S effort.
  2. Layer-major prefill (#3976/#1670, ffe40c16 and 17 more) is the one upstream speed idea in my area that can move the laptop's 256k TTFT by more than a few percent. It reads each layer's streamed experts once per super-chunk (default 32,768 tokens when on) instead of once per chunk. Upstream measured 5x TTFT on two 16 GB cards, but against a 512-token chunk; our chunk is already 6,144 (laptop) / 8,192 (5090). The laptop's moe.ring is I/O bound (docs/laptop-vs-vanilla.md gaps 4, 6, 8) so there it should still pay (estimate below); on the 5090 the ring is compute bound (port plan, rest-dma-diag) so the gain is small. Effort L, rounding-level change (upstream KL 0.0007 to 0.009), needs a gate.
  3. No change since the pin in the things that explain most of our laptop gap: STRATA_ROUTE_TAIL_SKIP=7 is still on by default in upstream main, PcieAuto, the sm_86 9-switch table, STRATA_PREFILL_CPU_SHARE, the adaptive tier constants, the expert-profile data files, the chat template and the tokenizer: all unchanged in 41cf05a0..870aedd9 (section 5). The x86 CPU expert kernels changed only for an opt-in sampling mode (D1). So the laptop decode gap documented in docs/laptop-vs-vanilla.md (tail skip worth 30-40 % of vanilla decode, PcieAuto) is not something upstream has since moved.
  4. A refreshed vanilla baseline will be a little faster than the one we measured, from new defaults on both our machines (section 3): STRATA_GR_V3, STRATA_GR_UP_WIDE on the 5090; STRATA_PROMPT_ATTN_IMMA on both; STRATA_PLE_AUTO_RAM where RAM allows; 256 MiB less auto expert cache. Compare against STRATA_DEFAULTS=026 or the old pin, not against "latest".
  5. Upstream reversed two lossy defaults inside the range (route prior, KVA) because of long agent sessions. That is evidence for our policy of not enabling lossy modes by default.
  1. A1 quoted call values, A2 missing </function>, A3 reasoning edge cases, A15 corpus as fixtures (one change set, all lossless, S+S+M).
  2. A5 drift recovery behind a config switch and A6 aliases (M), with the owner's decision on the undeclared-name policy.
  3. C1 device-wide free VRAM through NVML on Windows (S), C4 wait for the previous engine's memory on restart/reconfigure (S, check first).
  4. E3 measure WDDM event cost in the laptop ring (S), then decide on sparse events (M).
  5. E1 layer-major prefill as an experimental flag on the laptop first (L), after the cheap items.
  6. D1 window-invariant CPU rows as a test mode for the quality gate (M), F-items hygiene (S each).

2. Items

Columns: SHAs are upstream 8-character SHAs in the range. Claimed gain is upstream's, with its source. Lossless? says whether output can change and which gate applies under AGENTS.md. Have it? is what a grep of our tree found. Applies is 5090 server | 3080 laptop. Effort S (up to 1 day), M (2-5 days), L (more).

A. Protocol and tool calls (our top priority)

Our parser is control-plane/src/tool_output.rs (strict: any malformed or undeclared call is Err) and its callers in control-plane/src/responses.rs (1560 parse_complete, 2750 Incremental, 1648 reasoning). Err there becomes a failed response. Upstream's is serve/frontend.py (OutputParser, param_end, parse_tool_call).

ID SHAs What it does Claimed gain (source) Lossless? Have it? Applies (5090 / laptop) Effort Expected gain for us, priority
A1 77794e34 (10-25), b72f56e0 (10-28) A parameter value that quotes a whole call (<function=NAME> + <parameter=/</function> opener, counted against the closers before it) or repeats its own </parameter><parameter=NAME> stays exact; a bare <function= in prose does not count. Correctness, issue #4078 (serve/test_quoted_call_values.py, 6 value shapes x whole/streamed x 1/7/all bytes). Lossless (parsing only). Gate: unit tests; upstream's file as fixture. No, and the bug is confirmed. Our find_parameter_end (tool_output.rs:263) ends at the first </parameter> followed by <parameter= or </function>. Probe (section 8): the call is emitted with truncated content and the rest comes out as Text, in parse_complete and in Incremental. Both. Any agent that writes a file containing the call format (editing this repo's own parser tests, docs, fixtures) hits it. S Removes a silent wrong write (no error is raised). P0.
A2 d7113273 (part of #4427) A </parameter> followed by </tool_call> ends the value, so a call whose </function> was dropped is still a call; same for a call written inside the thinking and one ending on </function> at the end of output; a following <tool_call><function= confirms an omitted </tool_call>. Issue #4427 reporters' examples (serve/test_tool_corpus.py). Lossless. No. Probe: ...</parameter>\n</tool_call> (no </function>) gives Err("tool parameter is incomplete"). Both S Turns a failed response into a call. P0/P1.
A3 d7113273 (#4427, #4077) After the reasoning ended at </think>, a second </think> at the start of a line in the answer is dropped (model quoted the tag while thinking) and the answer's code/fence tracking restarts, so a following call is not mistaken for a quote. A tool call inside an unterminated reasoning block is accepted at end of turn. The final streamed event of a call announced early carries the parsed arguments. #4077/#4427 reporters. Lossless for the call; the reasoning between the two tags was already sent as answer text upstream ("a stream cannot take it back"). No. decode_generation (responses.rs:1648): reasoning enabled, no </think>, finish not Length -> Err("reasoning ended without </think>"), i.e. a failed response; a call written inside the reasoning is never read. Our Incremental only emits completed calls, so the "empty arguments in the final event" defect does not exist here. Both (thinking is the default for agent work) S-M Fewer failed turns. Frequency in Codex sessions unknown: the debug capture STRATA_DEBUG_FAILED_OUTPUT=1 (debug_failed_output(), responses.rs:1145, used at 2751) can count it on real sessions before and after. P1.
A4 d7113273 (#4427) _Lenient JSON reader: an array/object argument with a trailing or doubled comma, single quotes, Python literals, a bare string between members, brackets left open is read as written; counted (strata:tool_args_repaired_total) and logged. Never guesses a value; string-typed parameters untouched. #4427: reporter's todo_write array. Changes what the model asked for (repairs). Not lossy in the numeric sense, but it is an interpretation. Needs an explicit decision and a counter; keep off by default or log every repair. No. Probe: [{'a': 1,},] for an array parameter is delivered as a string (client schema failure). Both S-M Fewer schema failures; P2 (owner decides whether repair is acceptable).
A5 3fcb2106 (on by default 10-29), opt-in since 5bc479d9 (10-07, before the pin) tool_call_recovery: a declared tool's call written as <parameter=NAME> opener, JSON inside <tool_call>, a bare <function=NAME> block without <tool_call>, a second call in one wrapper, or an envelope drifted by a token (<=NAME>, <function:NAME>, <NAME>) is read as the call; only for declared tools; anything else stays text. "98.3 % of 1,462 agent turns read as intended with it, 92.9 % without" (docs/DETAILS.md, row "Signalnine/q27's drift corpus", Qwen3.8 under Claude Code, a reporter's corpus, not Codex and not ours). Lossless for declared tools; changes whether text becomes a call, so it needs the owner's policy. No (grep for tool_call_recovery/drift in control-plane finds nothing). Probe: a bare <function= block is published as text. Both M Up to 5.4 points of turns by upstream's corpus; ours unknown. P1, behind a config switch, measured on our own failed-output captures.
A6 805ebe17 (#3796), fd8d37e9 (#3972) Aliases of a declared tool name: namespace__member, namespace=member, namespace_member, bare member (exactly one declared tool has it), and mcp__a__b written mcp_a_b; unambiguous only; an undeclared name stays text and the reply names it (strata_rejected_tool_calls). Reporters on OpenCode, Pi, LibreChat, Open WebUI (#3796); Codex MCP spellings (#3972, "Qwen3.8-Flash-Next also writes namespace=member"). Lossless; undeclared calls are never executed. Partly different. We lower a namespaced tool to ns_<24 hex of sha256(namespace/name)> (response_tools.rs:14-36), described as namespace.name; the model has to reproduce a 24-hex alias exactly. An undeclared name is Err("undeclared function in tool call") (tool_output.rs:144), i.e. a failed response; the only precedent for a soft path is our apply_patch rewrite. Both (Codex namespaces) M Risk that the hex alias is mistyped is a hypothesis; test with the real model on a Codex MCP namespace before deciding. Policy question for the owner: fail closed (now) or return the text and mark it. P1.
A7 11237f83 (#3395) Chat Completions tool results are returned in call order when ids match. Reporter PR. Lossless. Yes. responses.rs:2106-2150 restores call order per call id for Responses; Chat and Messages lower to it (chat.rs:283-290); test parallel_results_replay_by_call_identity_not_arrival_order. n/a none none
A8 43f32b30 (#4576) End-of-turn ids: only a one-token `< im_end >/< endoftext >` is a stop id. DeepSeek reply cut at "Neraz". n/a
A9 9c2d35d9 (#4036), a0fc88ab (#3291), 8a3ca07c Responses accepts max_output_tokens 0/-1 as "no cap"; timings on Responses; empty messages is a 400. Compatibility. n/a We reject 0 (responses.rs:680) and a -1 fails Option<u32> deserialisation (400). Empty-messages behaviour on Chat not checked. Both S Codex does not send these; P4.
A10 9ea04496 (#3200), 2cc6ea16 (#2893), e0469a58, 7c9b6f3a, web chat commits logprobs/allowed_token_ids on Chat; LaTeX-safe structured JSON recovery (opt-in); MCP chat; web UI. Features. n/a Not needed for Codex. no - N
A15 d7113273 tests: serve/test_tool_corpus.py (49 specimens, whole / 1,3,7-byte pieces / cut at every byte, streamed or not), test_tool_routes.py, test_tool_name_alias.py, test_quoted_call_values.py The specimens are plain text + expected calls. n/a n/a n/a Both S Port the specimens (MIT, keep the provenance line) as tool_output.rs fixtures before changing the parser; they pin the "valid output unchanged" half. P0, with A1.

B. Conversation cache, prefix cache, session state

ID SHAs What it does Claimed gain (source) Lossless? Have it? Applies (5090 / laptop) Effort Expected gain for us, priority
B1 f8ff3420 (#1503) Parking reused the earlier conversation's retained K/V because the reuse tracked a count, not whose tokens; now it records ids and reuses only the shared prefix. Correctness (a restore answered from another conversation's history). Lossless. Not applicable by design. Our prefix store is keyed by the hash chain of the token prefix and verifies tokens on every match (docs/prefix-cache.md lines 44-56). Add one regression test: two conversations diverging after a shared prefix never share a node past the divergence. Both S P3 (test only).
B2 01e404c1, cea3ed40 (#2526), c7a0cef1 (#4420), 7a34c60d family Batch-slot parking / give-back checkpoint rules. Batch mode. n/a Ours is single-stream (NO_PARKING, port plan 0.5). no - N
B3 f62589fd (#3350) A checkpoint copy that runs out of memory is skipped instead of ending the engine ("snapshot running-state copy: out of memory", 21 exits in 4 h for one reporter). Reliability. Lossless. Check. Our admission refusals are non-fatal and logged (docs/laptop-vs-vanilla.md section 14), but a device allocation failure inside a checkpoint save was not traced. Both S (read the save path, add a test with an injected allocation failure) P3.
B4 3478382e (#3350, #3470), 8c030148 (#2409), a8c1d4b7 (#3702), 2a9a67c1 Leaked per-thread copy streams, restore guard, window-graph eviction, later-card VRAM audit. C++ engine robustness on layer splits. n/a Specific to the C++ thread-local streams and graph capture; our driver API returns errors per call. no - N
B5 0f7224d1, f73b3c86, ca378670, 85e3dde5, 0e63d59c Opt-in async checkpoint/park copies card-to-card then to host on a thread. Reporter, CMP 170HX on PCIe Gen2 x4: checkpoint 104 -> 34 ms; independent RTX 3090 on x16: 73.2 -> 62.4 ms (docs/DETAILS.md "Conversation cache copies on a slow host link"). Lossless (same bytes). No; our checkpoints are at grid points and request end (docs/prefix-cache.md). The state copied is 118 MB per checkpoint (same doc). Both (PCIe 4/5) M On a fast link upstream's own data shows ~15 %; our checkpoint cost is not on the measured critical path. P4.

C. Memory governor, Windows and WSL

ID SHAs What it does Claimed gain (source) Lossless? Have it? Applies (5090 / laptop) Effort Expected gain for us, priority
C1 3100ca05 (#1911) STRATA_VRAM_FREE=device: free VRAM = min(CUDA, NVML for the whole card). Under WDDM cudaMemGetInfo answers for the calling process only, so memory held by other processes (browser, another engine, image encoder) is not in it. Reporter, RTX 5090 Windows: CUDA said 30,994 MiB free, NVML 24,348 MiB with 6 GiB held elsewhere, so the auto cache was sized too large (commit message). Opt-in upstream. Lossless (can only shrink the cache). No. We size from cuMemGetInfo_v2 (cuda-driver/src/ffi.rs:711, leleka-memory governor/ledger); crates/cuda-driver/src/nvml.rs already loads nvmlDeviceGetMemoryInfo for telemetry (used, total) but it is not used for sizing. Linux 5090: no (no WDDM). Laptop (native Windows, Optimus, desktop compositor, docs/laptop-vs-vanilla.md gap 7: free VRAM is the knob for the 8192 chunk and the cache): yes. S Prevents over-sizing when another process holds VRAM; no speed claim. P2 (cheap, safe).
C2 cfa197e2 (#4474) The auto expert cache keeps kLateAllocMib = 256 for what is allocated after it (cuBLAS handles/workspaces, lazy modules, verifier buffers: -164 MiB at the prompt path, -80 MiB at the verifier on A4000/A6000). Free VRAM was 459 MiB at --vram-reserve-mib 700, under the 512 MiB serve warning. Cache ~100 slots (1.8 % on 16 GB) smaller. Lossless (placement only; fewer slots). Our profile uses a fixed gpu_budget_bytes (16,106,127,360 for the laptop) and a hand-set margin. Not checked whether our post-cache allocations (cuBLAS, sm86 companion modules) are inside it. Both S (read the VRAM-left line of the engine log after warm-up on each machine) P3. Vanilla keeps 459 MiB free on the laptop (laptop-vs-vanilla table) and warns.
C3 472de9cd, 587a4744 (#4518), 3b34b6c7, bc5f84fd PLE residency: keep the 26.8 GiB PLE table locked in RAM when RAM holds table + expert arena + 8 GiB; give the lock back if it starves the conversation cache; 472de9cd fixes ERROR_WORKING_SET_QUOTA (1453) on a 64 GB Windows PC where the locked table plus a 51 GiB pinned arena exceeded lockable memory. R9700 Linux 125 GB: 8K prompt 2,047 -> 2,505 tok/s, PLE 845 -> 132 ms (release notes 0.2.7). Lossless (same bytes). Different design: KAR level-2 PLE rows with read-ahead, own file objects on Windows, 1 s per turn (docs/laptop-vs-vanilla.md gap 2). Not applicable to the pack. The Windows lesson (locked/pinned memory counts against the working-set quota) is only a risk if we VirtualLock large ranges: libc-shim maps mlock to VirtualLock and ignores setrlimit. 5090: vanilla would lock PLE where RAM allows (affects the comparison, section 3). Laptop (47.7 GB): the rule declines. S (audit who calls mlock on Windows) P3.
C4 07d5ecfa, 01d6f7b9 (#4051) Before an arena load wait up to 20 s for RAM to come back (0.25 s polls, STRATA_ARENA_RAM_WAIT_S); after killing an engine an earlier run left, wait up to 120 s (was 10 s) for it to give its pinned memory back; warning names MemoryHigh=. Reporter: loading a 40 GiB arena into 10 GiB available sent a 60 GiB host into reclaim until reset. Lossless. Check. Memory note "reconfigure bricks engine" and the governor shed/reject states (leleka-memory/src/governor.rs) suggest the restart/reconfigure path races its predecessor's memory release. Not confirmed here. Both; the laptop has the smaller margin (pinned 7 GiB + 18 GiB left to the desktop) S P2 (read control-plane reconfigure/restart sequencing; add a bounded wait on the predecessor's RSS/pin).
C5 ebe3383a, 8dd297d0 (#3602) PLE direct reader: after a failed read, issue() kept queueing and the next collect() waited forever (fixed); STRATA_PLE_CHECK=1 re-reads any row whose decoded value is non-finite or > 1e5 from the file and says whether the delivered bytes are the file's. The reporter's all-logits NaN with --ple-io direct on IQ3_S on Windows with two GGUF shards was not reproduced and not explained upstream. Audit + stress test (ple_reader_stress_test.cpp); no fix for the NaN. Lossless. The hang class was closed for our reader in port plan 0.4; our Windows PLE read-ahead (ee4cb59, unbuffered reads through ReOpenFile) has LELEKA_PLE_AHEAD_VERIFY (1.36 M rows compared, 0 mismatches). No plausibility check on decoded rows in production. Laptop (Windows unbuffered reads). S A cheap finite/magnitude guard on gathered PLE rows would catch the upstream-unexplained failure class early. P3.
C6 085dcded (#4066), b3db5a1c, dc1fd367, e2e99ae5: Monitor/lifeline/process/DACL housekeeping Poll the GPU tool every 3 s only while a model runs (30 s otherwise); child-process identity; orphan engines. "Stops the Windows stutter" (release notes 0.2.7). n/a Our telemetry reads NVML in process; only the WSL/container fallback spawns nvidia-smi, at most every 2 s (leleka-memory/src/smi.rs:20). Laptop under WSL only S P4: raise the fallback interval while a request is decoding.
C7 7025a997, Windows uninstaller commits (36c6dd9e, af197f96, 4b9e05a2) WSL on AMD, uninstaller. n/a n/a n/a no - N
C8 docs/TROUBLESHOOTING.md (restored entries) Known hazards: nvcc 13.2.0/13.2.1 miscompile some sm_120 kernels (IQ2_S, IQ3_S products wrong), 13.2.2 (nvcc 13.2.86) fixes it; on Windows a full VRAM makes WDDM page GPU memory and decode falls 100 -> 14 tok/s; NVIDIA driver 610.88 wedge (0x141/0x116). Doc. n/a We build PTX with nvcc 13.2.86 (scripts/q8/rebuild_quantizer_ptx.sh) and three sealed files with 13.0.88: consistent. The laptop BSOD 0x19C is a different code (memory project-laptop-gpu-freeze-bsod). Both none Keep the nvcc >= 13.2.2 rule in docs/build-validation.md. P3 (doc line).

D. CPU expert kernels and pool

ID SHAs What it does Claimed gain (source) Lossless? Have it? Applies (5090 / laptop) Effort Expected gain for us, priority
D1 499e9635, 447460e8 (#3416) NativeArithmetic::WindowInvariant: each token's CPU expert rows get the bits of the one-token call whatever the window width (IQ gate/up types 18/21/22 via iq512_reference_gu_rows, IQ4_NL down via iq4nl_reference_rows, ggml's one-token dot otherwise; kernels that already match stay grouped). Used upstream only for STRATA_SPEC_PROB sampling. Upstream shows the grouped Default call differs from the token alone in 700 to 12,000 of ~18,000 output floats for IQ gate/up and IQ4_NL (commit message). Test native_arithmetic_parity (8 ctest configurations), bit for bit at widths 1..8. Default path unchanged (hashes identical, 61 lines x 10-13 environments). The invariant mode is bit-exact to the one-token result, slower (no shared weight decode). Not in crates/native-cpu-expert. Our own docs say the port is not bit-deterministic between processes (port plan header: 13.5 % of rows identical across two runs) and that fixed windows with one CPU worker are bit-identical (job up3h-det). That is consistent with upstream's finding that CPU rows depend on group width; it is an inference, not a measurement, that window-width-dependent CPU rounding is a main part of our run-to-run band. 5090: yes (CPU pool is the decode bottleneck). Laptop: yes. M Not a speed item. As a test-only mode it would let the quality gate compare arms without the run-to-run band from adaptive windows, i.e. a tighter noise floor for q_tail_gate.py. Estimate only. P2.
D2 7a80b3a9 Message and strata doctor warning: the Q2_0 canonical pack needs AVX-512 (VNNI+VBMI); IQ/NVFP4/Unsloth packs (with native_experts.txt) run on AVX2. Usability. n/a We dispatch AVX2 / AVX-512 at run time (port plan, "CPU tiers"). The laptop CPU (i9-11900H) has AVX-512 F/BW/VL/DQ/VBMI/VNNI (docs/laptop-vs-vanilla.md section 7). no - N
D3 a4c41a92, f262b81b, e3d8823e, 75638030 ARM64/Apple CPU build: cpu_relax.hpp, portable stand-ins; adds a load fence after the host spin on a GPU-raised flag for ARM. DGX Spark port; x86 objects byte-identical before/after. n/a x86-only for us. no - N
D4 5bc1e246, 38b06316 kq_cpu_bench fix; Gyro-L TQP5/6/7 trellis types. Tools / other pack family. n/a n/a no - N
D5 (negative result) No commit in the range touches STRATA_PREFILL_CPU_SHARE, PcieAuto, ROUTE_TAIL_SKIP, ADAPT_LAG/ADAPT_NOWAIT, the worker-count rule, the IQ3_S/IQ4_NL AVX2/AVX-512 row kernels (other than D1), the pool scheduler, or data/expert-profile*.bin. git log -S over src include serve docs setup.py strata_control returns nothing for them. - - Our port-plan rows 2.3, 3.1, 3.3 stand as written. both - -

E. Prefill streaming and expert-tier policy (shared with the prefill review)

ID SHAs What it does Claimed gain (source) Lossless? Have it? Applies (5090 / laptop) Effort Expected gain for us, priority
E1 ffe40c16, a6df0023, fca1936c, 162dec34, 6eff377a, 18c53576, 37e4832a, 9e203190, 945a63be and 9 more (#3976, #1670) Layer-major prefill: a super-chunk of S tokens runs layer by layer (attention half per sub-chunk of the normal chunk size, then the layer's experts once for all S rows, each routed expert staged once, one MMQ group). Expert traffic falls by about S / chunk. Residual rows of the super-chunk in VRAM or pinned host memory (`STRATA_PREFILL_LM_R=vram host auto). STRATA_PREFILL_LAYER_MAJOR=1 is honoured on one GPU; the **default** is on only for a CUDA layer split of 2 or more stages (prefill_layer_major_default, sm120_series.hpp`), super-chunk 32,768 and VRAM margin 512 MiB when on by default. Declines: HIP, image prompts, DFlash2 taps, KVA, peer GPU, fused layout, no VRAM/pinned RAM. A near-tail checkpoint is not taken mid-super-chunk. Two RTX A4000 16 GB, IQ3_XXS with experts streamed, 5 interleaved pairs, medians: TTFT 8K 2.8x, 20K 4.8-5.7x, 32K 5.1-5.5x (141 s -> 26-28 s), decode 38.6 vs 38.4 tok/s, needles 12/12 (commit 37e4832a, release notes 0.2.7). First-token KL 0.0007 to 0.009. The baseline was --prefill auto = 512-token chunks. Rounding-level change (another summation order of the routed experts): experimental flag until the Q gate passes (AGENTS.md). No. Our ring streams every non-resident expert once per chunk (port plan: 15,534 entries / 32.4 GB per 8192 chunk on the 5090; laptop: all experts the GPU does not hold, ~37 GiB per 6144 chunk, docs/laptop-vs-vanilla.md gap 6). 5090: small. rest-dma-diag showed removing all expert DMA did not shorten a chunk; the saving can only come from fewer launches, fewer gaps and bigger MMQ groups (estimate 5-10 % of moe, i.e. ~2-4 % of a chunk). Laptop: potentially large. moe.ring was 14.3 s of ~23 s per 6144 chunk (laptop-vs-vanilla section 2/3, before the PLE fix, so re-measure) and is I/O bound at ~3 GB/s. A 24,576-token super-chunk (4 x 6144, a multiple of the checkpoint grid) cuts the bytes per token 4x.
E2 162dec34, fca1936c (#3976, #1670) STRATA_PREFILL_WARM=1: a background thread hands the file-tier source the whole layer list at once (and the next layer's from the previous chunk) so page-ins queue deeper than the stager's few threads with 128 KiB faults. Opt-in; "the A/B arm"; no number. Lossless (warms pages only). Related to our laptop gaps 6/8 (page-fault touch, PrefetchVirtualMemory, adaptive prefetch policy prefetch_policy.rs). Not the same code. Laptop S-M P3 (idea to test with LELEKA_STAGE_PRIORITY).
E3 a11f8b0a, f217b23b (#4005) STRATA_PREFILL_COPY_EVENT_EVERY=N, STRATA_PREFILL_COPY_WAIT_DEDUPE=1: record the copy-done event every N-th entry and skip duplicate waits in the streamed prompt walk. Reporter: "under WDDM every cudaEventRecord and cross-stream wait is a submission of its own (~80 / ~45 us each on an RX 6900 XT, Windows 11)". No end-to-end number; opt-in, threaded issuer only. Lossless (same copies into same slots). Review fix in f217b23b for a stale-event race. Our ring records one event and waits one event per expert (CUPTI anatomy in the port plan counts 769 copy-wait gaps on Linux). Never measured on WDDM. Laptop is WDDM + NVIDIA (the claim is AMD). 5090/Linux: no. S to measure (count cuEventRecord/cuStreamWaitEvent per chunk and time them on the laptop), M to implement Hypothesis: at ~15-18k entries per chunk x (80 + 45) us the cost would be ~2 s per chunk, if NVIDIA/WDDM behaves like the reporter's AMD/WDDM. Measure before anything else. P2.
E4 f4012d63, 011e5bec, c5cf218e, 750ca8c3, e3450e45, bda30050 and others KVA: approximate late-layer prefill (builds only recurrent/KV state of layers 36-47, skips attention output and MoE for them; exact 2,048-token tail). Shipped off after being on by default for a day (750ca8c3 -> ae03ef63/e3450e45). docs/KVA.md: P100 +12 % at 14K, +20 % at 30K; RTX 5070 +11 % / +18 %; R9700 27K prompt +28 % but decode -11 % (tokens/round 4.08 -> 3.33). Split 24 dropped records and failed agent loops (RTX 5070 0 of 10 agent runs vs 4 and 7 exact). Lossy. Upstream's own evidence: dropped list records, wrong arithmetic in agent answers at split 24; split 36 "cleanest" (585 of 606 facts = exact; agents 6/10 vs 4 and 7). No. Cold prompts only, one GPU, first read at position 0 (our turn 1 = 45k tokens; later turns are exact on top of the approximated cells). L N for 256k agent sessions: lossy, decode slower on fast GPUs, reversed by upstream's owner. Re-open only with its own quality gate on our workload.
E5 54d9363c STRATA_PROMPT_ATTN_IMMA (int8 tensor-core prompt attention) on by default for CUDA cc >= 8.0. +1.1 to +1.8 % prompt on RTX PRO 5000 (sm_120) and 2x A4000 (sm_86) (commit message). Another summation order: gate Q. Ours is the Original's int8-KV prompt_attn_i8_kernel v2 (crates/cuda-driver/src/qsa_prompt_attention_select.rs, mma-based per the port plan's Maya table); upstream's IMMA kernel (prompt_attn_i8v3, mentioned in 3a3f35c6's allowance table) is not ported. Both (cc 12.0 and 8.6) M (kernel + seal) Estimate: 1-2 % of the QSA share of a chunk, i.e. under 1 % of a chunk. P4, belongs to the kernel review.
E6 3a267530, 91d4d7ff, 14d076ee STRATA_TRACE prints elapsed ms per request step and a process-wide clock. Diagnostics. n/a We have PREFILL-PROFILE, PREFILL-COPY, DBG spec-stats. no - N

F. Safety, tools, telemetry, hygiene

ID SHAs What it does Claimed gain (source) Lossless? Have it? Applies (5090 / laptop) Effort Expected gain for us, priority
F1 3a3f35c6 (#2683) tools/check_cuda_spills.py + ctest cuda_spill_guard: fails the CUDA test build when a Strata kernel spills or keeps a per-thread array in local memory (reads cuobjdump --dump-resource-usage, allowance table re-measured). Tooling; 0 violations on sm_86 and sm_120 at the time. n/a No for our sealed PTX. scripts/q8/* splice and pin sealed text but nothing checks local-memory use. Both S A spill introduced by a re-seal would otherwise show only as a slowdown. P3.
F2 4a7e373d (#1284) --adapt-decay outside 0..1 falls back to 0.7 with a line (above 1 the usage counts grow to inf and the swap gains turn NaN). Reporter bug. Lossless. Partly. LELEKA_ADAPT_DECAY accepts any finite value (original_serve_residency.rs:466-471); our sorts use total_cmp, so no panic, but a value above 1 still makes counts diverge. Both (env knob only) S P4.
F3 45c9e623 STRATA_LOGITS_DUMP: post-window logits tap for KL measurement. Tooling. n/a We have STRATA_LOGPOS top-k rows (port plan 0.2). no - N
F4 6c01f85a (#3911) Penalty applied to a history token outside a short logit row (draft vocabulary) no longer indexes past the row. Reporter bug (host OOB read/write). Bit-identical for full rows. Yes. sampler-ref/src/chain.rs:165-171 filters ids outside [0, n_vocab). n/a none none
F5 41188ec7, e0d47034, c0845b7f, 80073010 calibrate drops only the dying candidate; presets keep out-of-range values with a warning; bench report facts. Tooling. n/a Not our tooling. no - N

G. Installer and launch (strata launch/setup.py)

No Qwen-NVIDIA launch flag default changed in setup.py or strata_cli/launch in the range. Changes there are DeepSeek, Mac, DGX Spark (arm64), Strix Halo, four-card AMD, Arc B-series --spec 2, feed handling, CUDA 12 driver floor taken from the package (84c7f433), CMake default CUDA architecture is sm_120 when none is given (3cd33d50, #4029), IPv6 --host :: (eba3106c). Nothing to port; our deploy profiles (rtx5090-32g, rtx3080-16g) are independent of them.

3. Defaults changed upstream since the pin (what a "latest vanilla" does that the pin did not)

All values are the state of 870aedd9. "Switch" is the off switch. STRATA_DEFAULTS=026 turns every default changed since 0.2.6 back (a3ab37fc, include/strata/core/defaults_026.hpp).

Default SHAs Applies to 5090 (cc 12.0, 32 GB) Applies to laptop (cc 8.6, 16 GB) Output changes? Effect on our comparisons
STRATA_GR_UP_WIDE on (HC up read, one warp per row) d39e2a75, d18d8ba0 yes no (sm_120 only) no (bitwise, claimed) claimed +1.9 % story / +0.7 % code on RTX PRO 5000 (sm120_series.hpp)
STRATA_GR_V3 on (stream-split HC read) for discrete cc 12.0 with more than 13 GiB 54d9363c yes no yes (another summation order) claimed +1.2 % decode on RTX PRO 5000; measured -3.0/-5.9 % on 2x A4000 and +1.0/-3.4 % on RTX 3060, which is why it is sm_120-only
STRATA_PROMPT_ATTN_IMMA on for cc >= 8.0 54d9363c yes yes yes claimed +1.1 to +1.8 % prompt
STRATA_PLE_AUTO_RAM (PLE table locked in RAM if RAM holds table + arena + 8 GiB) 3b34b6c7, 472de9cd, 587a4744 yes if RAM allows no (47.7 GB declines) no changes PLE I/O of the vanilla we compare with on the server (claimed R9700: PLE 845 -> 132 ms)
Auto expert cache keeps 256 MiB more free cfa197e2 yes yes placement only about 100 slots (1.8 % on 16 GB) fewer
Route prior (STRATA_ROUTE_PRIOR=1.5) on for discrete cards of 13 GiB or less in 0.2.7, off again in 0.2.8 c30656aa, 0afaaa39, 20a63cf0 (#4402) no no (16 GB card is above the 13 GiB line) yes (lossy) net change from the pin: none. Upstream's reason for reverting: repetition loops and weaker results in long agent sessions; its own check passed 4.5 of 10 agent tasks with it on vs 5.6 off
KVA (approximate prompt) 750ca8c3 -> e3450e45 off off yes (lossy) net change from the pin: none
tool_call_recovery on in the server 3fcb2106 n/a n/a the parsed text see A5
Layer-major prefill on for 2+ CUDA stages 37e4832a no (one GPU) no yes (rounding) none for us; one GPU keeps the old path
Two-NVIDIA-card batch pipelined by default ec8e4059 no no no none
sm_80 / sm_89 / sm_121 / gfx12 / gfx1151 tables 663ec80a, 25796351, 9a398bd5, 3fd5a748, c77292f0 no no (the sm_80 tables key on cc 8.0 exactly; sm_86 is untouched) mixed none
CMake CUDA default arch sm_120 3cd33d50 build only build only no none
Unchanged: route tail skip default 7 on CUDA serve, PcieAuto, sm_86 9-switch table (STRATA_SM86_PERF), STRATA_PREFILL_CPU_SHARE, adaptive tier constants - - - - see section 5

4. Bug fixes we should take (correctness first)

# Upstream fix SHAs Our status Action Prio
1 Quoted tool call inside a string argument truncates the argument 77794e34, b72f56e0 Present in our parser, silently (section 8) A1 + fixtures P0
2 Call without </function>; call inside reasoning; stray </think>; damaged JSON array d7113273 Present: Err or string argument A2, A3 (A4 by owner decision) P0/P1
3 Mangled or namespaced tool names fail the turn 805ebe17, fd8d37e9 Present as Err("undeclared function"); hex-alias scheme for namespaces A6, owner policy P1
4 Control-token text in messages becomes real special tokens c16f31f8, 98b7ea94, 0d613031 (before the pin) Done (port plan 0.1; strata-desktop-core still renders unmarked text, per that row) finish desktop-core tracked
5 Checkpoint copy out of memory ends the engine f62589fd Not traced B3 P3
6 PLE reader hangs after a failed read ebe3383a Not affected (port plan 0.4) none -
7 Windows direct PLE read -> all-logits NaN (#3602), unexplained upstream ebe3383a, 8dd297d0 We use the same idea (unbuffered, own handles) on Windows; verify mode exists, no production guard C5 P3
8 Free VRAM under WDDM is per process 3100ca05 Present (sizing from cuMemGetInfo_v2) C1 P2
9 Old engine's pinned memory not yet released when the next loads 07d5ecfa, 01d6f7b9 Unknown; memory note "reconfigure bricks engine" C4 P2
10 --adapt-decay above 1 diverges 4a7e373d Present for the env knob F2 P4
11 Cross-conversation retained K/V reuse f8ff3420 Not possible in our design (hash-chain keys) test only (B1) P3
12 Penalty index past a short logit row 6c01f85a Not present none -
13 Tool results out of call order 11237f83 Not present (Responses restores call order) none -
14 --dump-logits header, spec window past max_cells, PLE gather_batch ordering, cancelled-between-windows, one-token prompt before the pin Done (port plan 0.2-0.5) none -

5. Checked and found unchanged (negative results)

Evidence: git log --no-merges 41cf05a0..strata-upstream/main -S<string> over src include serve strata_control docs setup.py returned no commit, and git diff --stat over the paths shows no change.

  • STRATA_ROUTE_TAIL_SKIP (default 7 on CUDA serve, src/core/expert_source.cpp:4907 at main), PcieAuto (pcie_frac_auto, src/program/generate.cpp:762), STRATA_PREFILL_CPU_SHARE, ADAPT_LAG, ADAPT_NOWAIT, STRATA_RING_BYTES, STRATA_CPU_PREFETCH, STRATA_IO_PREFETCH: no commit.
  • The sm_86 table (src/core/nv_defaults.cpp: ADAPT_NOWAIT, ADAPT_LAG=2, CPU_IQ_ALL_EXACT1, SIDE_MIXER=2, ATTN_DAILY, GR_UP75, GU_SWIGLU, QSA_ROWS, B6_MMVQ_ROWS) is unchanged and still applies to the laptop's 3080.
  • data/ (expert profiles, draft vocabularies): git diff --stat 41cf05a0 strata-upstream/main -- data tests/data is empty. How the Qwen profile is generated is unchanged.
  • serve/chat_template.jinja, serve/chat_golden.json, serve/dsml.py, LICENSE, serve/mcp_fake_server.py, tools/mtp_rt.py: no diff (so the include_str! files our crates embed are still identical to the pin's; that was the only check in docs/upstream.md that could break).
  • x86 CPU expert row kernels: only 499e9635/447460e8 (D1, opt-in mode, default path hash-identical by the commit's own test).
  • Qwen end-of-turn ids and tokenizer behaviour: unchanged (43f32b30 keeps Qwen's).

6. Why the laptop numbers differ from upstream (profile rtx3080-16g)

Already documented in docs/laptop-vs-vanilla.md and still true at upstream main: vanilla's lossy tail skip (30-40 % of its decode), PcieAuto share 0.20 -> 0.40 -> 0.30 -> 0.35, the nine sm_86 switches, 7 pinned workers, chunk 8192 with a 96-slot ring borrowing cache slots, packed one-blob-per-expert experts.bin. The new upstream material that bears on the laptop is:

  1. Expert streaming once per layer instead of once per chunk (E1). Vanilla on the laptop streams per 8192-token chunk, as ours does per 6144; neither uses layer-major. This is the only upstream change in the range that attacks the I/O-bound moe.ring (14.3 s of a chunk in docs/laptop-vs-vanilla.md section 2). It is opt-in on one GPU, so a vanilla laptop run does not use it unless STRATA_PREFILL_LAYER_MAJOR=1.
  2. WDDM submission costs (E3, a11f8b0a): a reporter measured ~80 us per event record and ~45 us per cross-stream wait on Windows. If our ring or vanilla's pays this per expert, it is a laptop-only cost that the Linux CUPTI work could not see. Unmeasured.
  3. Per-process free VRAM under WDDM (C1, 3100ca05): cudaMemGetInfo/cuMemGetInfo ignore what other processes hold. The laptop's cache size, the 8192-chunk loan (gap 1) and the "459 MiB free" of vanilla all depend on it. Vanilla does not use the device-wide figure by default either.
  4. The cfa197e2 reserve: vanilla (0.1.50, same as the pin) ends 240 MiB under its --vram-reserve-mib (459 MiB free at 700 on a 16 GB A4000, below the 512 MiB line its serve check warns about). The laptop log shows 459 MiB free for vanilla too; a 0.2.8 vanilla would leave about 100 slots (1.8 %) fewer in the cache and more free VRAM. Part of a paired comparison, not a gap.
  5. STRATA_PROMPT_ATTN_IMMA default (E5): a 0.2.8 vanilla on cc 8.6 has it on (claimed +1.1 to +1.8 % prompt).
  6. Nothing in the CPU path (pool, kernels, prefetch, profile) changed upstream, so no upstream CPU change explains our decode gap; the remaining explanations are the ones in the laptop document (tail skip, PcieAuto, page-in).

7. Out of my area: GPU/shared-code commits seen in the file lists (not reviewed in depth)

Listed so nobody assumes they were missed. They belong to the CUDA kernel review.

b434a8aa (STRATA_SELECT_LONG, multi-CTA decode top-k; we already ported the cluster top-k), 8b95bffb/c2d3fe50/91aebae6/269c6d3e/663ec80a/2299c8f7/bdecbffc (MMVQ-IL tables sm_80/sm_89, Q6_K prefetch), 8c2a8469 (STRATA_GDN_TC, chunked GDN scan on tensor cores, sm_80), 10c8cc62/bdcc34df/c47c6994 (fused prompt expert variants), dd97421d (swiglu_quant fused), 5dbd8774/9067cc64/6a6d58ad/f213f78b/a3389901 (GP100/Pascal), 0049fa73 (STRATA_GRAPH_PRIO, node priority in the window graph: +1.8 % on CMP 170HX claimed), dc390c38 (STRATA_DEQUANT_SIDE), 17b08c96/d6428bf2 (PLE rows uploaded as raw IQ4_NL and dequantized on device: 1,440 B per token instead of 10,240 floats; opt-in), 884e37df (STRATA_EMBED_VRAM), d18d8ba0/2395c8a5/d39e2a75 (HC read variants), 7d1016f3/789d8390/11b04902 (STRATA_QFUSE, off), f4612b1a/ca17d0f5 (STRATA_SPEC_PROB, changes sampling, opt-in), 9d3c8c36 (16-row windows, HIP only), 17878ac5/a3bb38ec/ec8e4059 (batch/pipelined groups), 690172c4 (split serving), DeepSeek (174 commits), SYCL (23), Metal, desktop app and web. The PLE_COMPACT idea (upload packed PLE rows, expand on the device) may be worth a look in the KAR PLE path review: our rows are 50 bytes (KAR level 2) and the laptop input.ple is already 1 s per turn, so the expected gain is small.

8. Reproduction of the parser findings

No model, no GPU. A scratch crate (not in the repo) includes control-plane/src/tool_output.rs through #[path] (it depends only on serde_json), toolchain 1.99.0, cargo run --offline, on commit e92513b7's file. Tools declared: write(path: string, content: string), todo(todos: array).

Input (model output) Result with our parser
write call whose content is example transcript: + a complete quoted <tool_call>...<function=write><parameter=path>x.txt</parameter></function></tool_call> + after block Ok([Call write {content: "example transcript:\n<tool_call>\n<function=write>\n<parameter=path>\nx.txt", path: "probe.txt"}, Text("after block\n</parameter>\n</function>\n</tool_call>")]): truncated argument, remainder as text. The same through Incremental fed one character at a time.
...</parameter>\n</tool_call> (no </function>) Err("tool parameter is incomplete")
<function=bash> when only write is declared Err("undeclared function in tool call: bash")
todos (array) = [{'a': 1,},] delivered as a string "[{'a': 1,},]"
<function=write>...</function> without <tool_call> Ok([Text(...)]), the call is plain text

The same shapes are in upstream's serve/test_quoted_call_values.py and serve/test_tool_corpus.py. Not tested: the reasoning case (read from responses.rs:1648: a missing </think> with finish other than length is an Err).

9. What this review did not establish

  • No measurement. E1 (layer-major) and E3 (WDDM events) gains are estimates/hypotheses and need the laptop (CPU/GPU idle, charger, OEM performance mode; the 0x19C freeze note applies to long GPU jobs).
  • Whether the hex namespace alias (A6) is mistyped by the model in practice.
  • How often Codex sessions hit A2/A3/A5; the existing failed-output capture can answer it.
  • Whether C4 (restart waits for the predecessor's memory) is a real race in our control plane.
  • The 0.2.8 release notes (not in the tree); DeepSeek/Metal/SYCL content; GPU kernel diffs.