Files
leleka/docs/upstream-review/decode.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 420e5cb776 docs: upstream review, decode area (Strata 41cf05a0..870aedd9)
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>
2026-10-30 03:08:58 +01:00

180 lines
36 KiB
Markdown

# Upstream review, area DECODE: speculation, tiers, window kernels (Strata `41cf05a0` .. `870aedd9`)
Date 2026-10-30. Branch `claude/upstream-review-decode`. Read-only analysis: no GPU, no server job, nothing built, nothing run. Every speed number below is
**upstream's claim on upstream's hardware** (source named per row) or **our own estimate** (marked "estimate"). Nothing here is a measurement of ours.
## 0. Scope and method
* Range: `git log 41cf05a0..strata-upstream/main` after `git fetch strata-upstream main` (head `870aedd9`, 2026-10-29, engine 0.1.54 / app 0.2.8).
585 commits: 503 non-merge, 82 merge. `41cf05a0` is an ancestor of the head. Releases in the range: 0.2.6 (`562a0c2e`: the Qwen engine packages stay
0.1.50, only the DeepSeek engine and a comment in `generate.cpp` changed), 0.2.7 (`a42cc3d7`, engine 0.1.52, 0.1.53 `1a937829` for linux-aarch64), 0.2.8 (`36f6663c`, engine 0.1.54).
* Of the 503 non-merge commits (subject-line counts, overlapping): about 130 are DeepSeek-V4.1 (`src/dsv41`, DS4_*), about 130 are Metal / SYCL / Mac / Arc,
about 200 are app / Terminal / setup / serve / docs / tests / packaging. About 50 touch the Qwen3.8-Flash-Next CUDA engine; of those, about 25 touch decode, speculation,
tiers or expert code. These are the rows below. Everything else is listed once in section 3 with the reason it was skipped.
* Paths used for the selection: `src/core`, `src/program`, `src/spec`, `src/ngram`, `src/qwen35`, `src/kernels` (cuda and cpu), `include/strata/{core,program,spec,kernels}`,
`docs/DETAILS.md`, `docs/release-notes-0.2.7.md`, `docs/DGX_SPARK_LINUX.md`, `strata_control/{tune_knobs,speed_switches}.py`. The diffs of every commit in sections 2 and 5 were
read (`git show`), the rest by subject and file list.
* Not in upstream's tree: a changelog file. The release notes of 0.2.7 are `docs/release-notes-0.2.7.md`; there is no 0.2.8 release note in the tree (0.2.8 is visible only as commits).
* Provenance of the existing plan: `docs/upstream-port-plan.md` covers the pin `41cf05a0` (the pin is from the same day as the 0.2.6 commits; the Qwen engine did not change in 0.2.6). So
everything in section 2 is new to that plan. Section 6 lists pin-level features the plan does not cover.
* Gate letters are those of the plan: I identity probe, Q teacher-forced agreement, R replay A/B, L live session.
## 1. Result in six lines
1. **There is no large decode lever in this range.** The single-GPU Qwen CUDA speculation controller (`src/spec/*`, `mtp.cpp`, `generate.cpp` serve loop), the tier code
(`expert_source.cpp`, adaptive swaps, PCIe split on CUDA) and the verify-window kernels changed only by: two new sm_120 defaults (`GR_UP_WIDE`, `GR_V3`), opt-ins, bug fixes
and code for other cards. No commit in the range raises tokens per round on CUDA.
2. The two sm_120 defaults are claimed at +1.9% / +0.7% (`GR_UP_WIDE`, bitwise) and +1.2% (`GR_V3`, rounding level) on an RTX PRO 5000 72 GB with every expert in VRAM. They do not
transfer as measured: our chain kernels already replace the kernel `GR_UP_WIDE` beat, and the 5090 session at 245k is bound by misses and the CPU pool, not by that read.
3. The only upstream change that targets miss-bound decode is the **residency-biased routing** (`STRATA_ROUTE_PRIOR`, kernel older than the pin). It was made default on <= 13 GiB cards in
0.2.7 and **taken back in 0.2.8** (`20a63cf0`) because of repetition loops and weaker agent results (upstream's own check: 4.5 of 10 agent tasks with it, 5.6 without). It is lossy.
We already have one such experiment that failed its gate (route tail skip, p99 d_top1 1.005 against a limit of 0.499).
4. Correctness first: three items worth taking regardless of speed (section 5): window-graph `cuGraphInstantiate` out-of-memory handling (`a8c1d4b7`), the failed-read path of a PLE
reader (`ebe3383a`), and the conversation-cache identity bugs (`f8ff3420`, `c7a0cef1`, `f62589fd`) for the cache owner. For Windows (laptop): NVML free memory (`3100ca05`).
5. Tokens per round is **not** where upstream is ahead of us (our docs: ours 2.05-2.13, vanilla 1.79-1.88 per round at 245k). The measured differences are VRAM hit rate (vanilla 96-99%,
ours 76-83% in the old unpaired runs), the draft and commit order, and per-round host work; those are already being worked on in `docs/experiments/draft-tail-5090.md`.
Details in section 8.
6. Upstream publishes no 200+ tok/s figure at long context on any card that misses experts. Its 200+ figures are: RTX PRO 5000 72 GB, all experts resident, short context (story 211.8, code
244.7 after 0.2.7, `release-notes-0.2.7.md`), and Windows RTX 5090 reports at 128K *configured* context (205-230 tok/s with >= 900 MiB free, `DETAILS.md:1449`; callback-affinity report
142.82 -> 207.75, `DETAILS.md:1394`, a 4K test). The 200-220 tok/s goal at 245k is therefore beyond anything upstream shows; it needs something upstream does not have.
## 2. Table of relevant commits and series
Columns: **Lossless?** = bitwise (gate I) or changes output (gate). **Have?** = in `crates/` or the plan (greps and file names given). **Gain for us** is an estimate unless stated.
Priority: 1 = do first, higher number = later, "-" = do not port. Effort S < 2 d, M 2-5 d, L > 5 d (includes PTX re-seal and sm_86 companions where a kernel changes).
| ID | SHAs | What it does | Claimed gain (source) | Lossless? / gate | Have it? | Applicability (Qwen3.8-Flash-Next, 5090 / 3080) | Effort | Expected gain for us | Prio |
|---|---|---|---|---|---|---|---|---|---|
| R1 | `d18d8ba0` (kernel, opt-in), `d39e2a75` (default on cc 12.0) | `STRATA_GR_UP_WIDE`: hyper-connection up projection, one warp per row, 1,280 blocks instead of 160 (`fused_gr.cu`, `sm120_series.hpp`) | story 197.6 -> 201.3 tok/s (+1.9%), code 243.5 -> 245.1 (+0.7%); RTX PRO 5000 72 GB, all experts in VRAM, IQ3_S, 5 interleaved pairs of fresh engines, token ids identical in 6 pairs (commit messages) | bitwise (same dot, xor tree, epilogue and cross-stream sum order); gate I byte compare | Partly. The kernel it beats is the Original's `mtp_scalar_gr_up` (160 blocks). Ours: `chain_gr_up16` (160 blocks) / `chain_gr_up8` (320 blocks), hoisted loads; `chain_gr_up8` is 5.7 us at 4 rows (`original_verify_window_gr.rs:566`, plan 2.1/2.2). Not wide. | 5090 (170 SMs) has the same under-occupancy argument as upstream's 110-SM card; sm_86 laptop: upstream gates the set to cc 12.0 only, so no claim for the 3080 | S-M (one kernel, seal, sm86 companion; the q8_1 tail needs 16-column blocks, so wide is used only without a q8_1 image) | 0.3-1% (estimate: 80-96 reads x 5.7 us = 0.45-0.55 ms of a ~15 ms round; halving the up read saves <= 0.3 ms). The upstream figure is against the slower Original kernel, not ours | 5 |
| R2 | `54d9363c` (default), kernel `fused_gr.cu` ~608 (pin, opt-in `STRATA_GR_V3`) | Hyper-connection read split over two kernels (stream-split); now default on a discrete cc 12.0 card with > 13 GiB | +1.2% decode, identical tokens (RTX PRO 5000); measured slower on sm_86: -3.0% / -5.9% (2x RTX A4000), +1.0% / -3.4% (RTX 3060) (`sm120_series.hpp` comment) | Changes summation order ("rounding level"); needs gate Q | No equivalent. Our chain GR read is a different decomposition (split + down + up8). | 5090: maybe; 3080: no (upstream measured it slower on sm_86) | M-L | 0-1%, unproven for our read | - (revisit only if R1 shows the HC read still matters) |
| R3 | `2395c8a5`, `f1dadd17` | One-kernel persistent HC read ported from HIP to CUDA (`STRATA_HC_PERSIST=1`) | **negative**: story 201.4 -> 190.6 (-5.4%), code 245.6 -> 249.6 (+1.6%), 3 interleaved pairs (commit message) | opt-in, not default | No | No | - | none | - (do not try) |
| R4 | `0049fa73` | `STRATA_GRAPH_PRIO=1`: node priorities in the window graph (side-mixer branch highest, shared expert lowest), `cudaGraphInstantiateFlagUseNodePriority` | +1.8% (CMP 170HX, IQ3_S, 3K context, `--spec 3`, interleaved); +1.3% in a combined pair (PR #3779 author, "theirs, not measured here" per the commit) | bitwise by construction (same launches, only dispatch order) | No. Our driver already loads `cuGraphInstantiateWithFlags` (`original_gpu_schedule_ffi.rs:158`); our window is one stream except the opt-in SIDE_MIXER GDN half (`LELEKA_SM120_SIDE_MIXER`, "pending") | Only matters with parallel branches. Useful as the companion of SIDE_MIXER, not alone | S | 0-1% (estimate; zero without side branches) | 8 |
| R5 | `c30656aa` (on at 2.0, <= 13 GiB), `7c4c2079` (CUDA-discrete only), `0afaaa39` (2.0 -> 1.5), `20a63cf0` (**off again**, 0.2.8); docs `44b88bc9`, `7e1a7cb9`, `8191cb91`, `c41bd44d`, `1b890431`; kernel `route_prior.cu` is older than the pin | Residency-biased routing: top-10 is picked with a logit bonus `lambda` for experts already in VRAM; weights stay the router's (`route_prior_k`: selection on biased logits, weights renormalised over the 10 picked) | RTX 3060 12 GB IQ3_XXS: story 44.2 -> 60.9 (+37.6%), code +35.2% at 2.0; at 1.5 story +15%, code +37% (commit messages, release notes). RTX PRO 5000 (all resident): -1.9% / -0.5%. 2x A4000: -4.2% / +11.0% | **Lossy.** Pin docs: `ROUTE_PRIOR=0.5` on an RTX 3060 KL 0.0126 against a floor of 0.0012 (`DETAILS.md`, table row "0.1.45 ... sm_86 and sm_60 bitwise sets"). 0.2.7 check: 80 tasks, no copy/code defect at 1.5; agent check 4.5/10 passed with it, 5.6/10 without (4 and 7 runs); #4402 reports repetition loops in long agent sessions. Needs gates Q + agent-task completion | No (grep of `crates/` and docs: no `route_prior`). We have route tail skip (plan 3.1), failed its gate | The mechanism fits our miss-bound decode (ours serves 16-23% of routed entries from CPU/PCIe, `decode-gap-5090.md` section 3). The failure mode (loops in long agent sessions) is exactly our workload | M (new router top-10 variant in the sealed set, per-layer residency table upload after every swap, off at high residency) | Unknown. Order of magnitude (estimate only): CPU callbacks are 3.9 ms of 15.3 ms per round (`draft-tail-5090.md` section 1); if bias halves the non-VRAM entries, about -1.5 ms/round, about +10%. Expect to fail the Q gate (tail skip at +15.2% failed at 2.5x the control) | 7 (experimental flag, never default) |
| R6 | `f4612b1a`, `499e9635`, `447460e8`, `ca17d0f5`, `4c7bce3a` | `STRATA_SPEC_PROB=1`: gated proposal for **sampled** speculative decode (rejection sampling with the confidence gate part of the proposal law, `gated_proposal.hpp`, `spec_proposal.hpp`, `DraftPolicy::observe_committed/defer_cost/apply_costs`, window-invariant CPU arithmetic) | none claimed: "a correctness change, not a speed change" (`DETAILS.md`); on a 3060 coupled/rejection sampling was inside noise (`DETAILS.md`, row `STRATA_SPEC_COUPLED` / `STRATA_SPEC_PROB (0.1.40.2)`) | changes the sampled distribution to the correct one; opt-in | Not needed. Our sampled path accepts a draft only when it equals the target's own sampled token (`docs/adaptive-spec.md`, "Sampled requests"); the emitted token is always the target's draw, so no gate/proposal mismatch exists. | N/A. It also requires `--lookup-chain 0 --adapt-swaps 0 --pcie-frac 0` and no SPEC_COST, i.e. none of our tiers | - | none | - |
| R7 | `9a398bd5`, `85444201`, `e6fd9146`, `f262b81b`, `a4c41a92` | sm_121 (GB10, DGX Spark) default table: `PF_FUSED`, `PREFILL_NVFP4=w4a4`, `HC_UPMIX`, `SPEC_COST` | first run +5.4% (`HC_UPMIX`) and +4.7% (`SPEC_COST`) decode; **the later paired check read decode 0.996x (0.97-1.02) on IQ3_S and the page says "this check did not see it"** (`docs/DGX_SPARK_LINUX.md`) | not bit-exact (fused prompt path) | `SPEC_COST` (cost-aware window): our adaptive controller is a superset (`original_spec_adaptive.rs`, +5.1% over fixed measured). `HC_UPMIX` is wired only in `prefill.cpp` at main (S23), no decode call site | N/A (GB10 only). Note for the record: the "decode" claim of `HC_UPMIX` has no decode call site in the source | - | none | - |
| R8 | `7d1016f3`, `789d8390`, `11b04902` | `STRATA_QFUSE` bugs: fused q8_1 producers divided with IEEE `/` while the consumer quantiser (`native_mmvq.cu`, `--use_fast_math`) uses `div.full.f32`: a code differs by one at ~1 element per 10^6; and `commit()` skipped the commit graph for a one-token window that did not self-commit | explains acceptance 0.755 vs 0.79 and different text on RTX 3080 (#3948) | fix of an opt-in path | **Not affected** (checked from source): we have no QFUSE. Our one fused q8_1 producer is `chain_swiglu_quant_kernel` (`chain_window.cu:701`), built `--fmad=true --ftz=false` like the Original's `quantize_q8_1_kernel` (`iq_kernels.cu`, not in the fast-math list at `CMakeLists.txt:531-545`). No one-token self-commit in our window (plan: `ONE_TOKEN_COMMIT` missing) | Lesson only | - | - | - |
| R9 | `b434a8aa` | `STRATA_SELECT_LONG=1`: multi-CTA decode top-k + shuffle-free scorer, second graph set past 65,536 cells | +2.9% on 4 GP100 at 115K context (contributor) | bitwise ids | **N/A**: the kernels are inside `STRATA_EXPERIMENTAL_SM60` (`qsa_select.cu`); we already ship the cluster top-k (plan 2.5, 183 -> 19.5 us at 245k) | No | - | none | - |
| R10 | `91aebae6`, `269c6d3e`, `25796351` (sm_80), `bdecbffc`, `2299c8f7`, `663ec80a` (sm_89), `8b95bffb`, `c2d3fe50` (`MMVQ_IL_PF`, Q6_K, table read only on sm_80) | MMVQ-IL row tables and load-hoisted variants for other architectures | CMP 170HX only (+1.4%) | bitwise | N/A | No (sm_120 uses the existing tables; sm_86 3080 unaffected) | - | none | - |
| R11 | `9d3c8c36`, `b119f40f` | Verify / batch windows up to 16 rows, build option `STRATA_WINDOW_MAX_T = auto, 8 or 16`; auto = 16 for HIP, 8 for CUDA | 32 slots on four cards (batch serving) | window <= 8 rows runs the same kernels (3096 of 3097 identical on gfx1201) | No: our `kVerifyMaxT = 8` is sealed (`docs/adaptive-spec.md`, "Wider windows than 6") | No gain for single-stream decode; upstream's tuner bound says `--spec` >= 6 is 4-16% slower (notes under the table) | - | none | - |
| R12 | `a8c1d4b7`, `2a9a67c1` | A window graph whose `cudaGraphInstantiate` runs out of memory frees the graphs of other window sizes and retries (`pick_window_victim`); a failed `cudaGraphUpload` is a warm-up failure, not an engine error; commit graph instantiate now reports its own status | robustness (#3702: engine ended with 68 MiB free on a later card) | n/a (no output change) | No. `original_gpu_schedule.rs:416` does `a.instantiate(graph)?` and propagates the error. Our decode reserve is 300 MiB (130 MiB is opt-in, `981c7aad`, `eef6f598`), so the free margin at instantiate time is small | Real: we push VRAM to the limit for slots (free VRAM at decode 316-563 MiB in our own account, `981c7aad`) | S-M | avoids a crash at the edge; no speed | 2 |
| R13a | `cfa197e2` | Auto expert-cache sizing leaves `kLateAllocMib = 256` for what the load allocates after the cache (cuBLAS workspaces ~164 MiB at the prompt path, ~80 MiB at the verifier) | card ended ~240 MiB under the requested reserve (A4000, A6000) | placement only | Our planner already sizes against free VRAM minus a reserve, with a per-call-site ledger (`bea07c3d`, `LELEKA_VRAM_LEDGER`) | Vanilla 0.2.8 therefore has ~135 fewer slots (~1% on a 5090, estimate from 256 MiB / 1.94 MiB per slot) than 0.2.6 | S (check only) | none; it narrows the slot comparison with a 0.2.8 vanilla arm | 9 |
| R13b | `3100ca05` | `STRATA_VRAM_FREE=device`: free VRAM from NVML for the whole card, Windows + NVIDIA, opt-in | CUDA read 30,994 MiB free where NVML read 24,348 (6 GiB held by another process, RTX 5090 WDDM); a card filled to 0 MiB free decoded 80-115 tok/s where the same text ran at 205-230 with >= 900 MiB free (`DETAILS.md:1449`) | placement only | Our budget reads `cuMemGetInfo` (`leleka-memory` governor/inventory/ledger, `cuda-driver` `ffi.rs`); NVML is read for status only (`docs/windows.md:266`). Same hazard by reading, not measured | Laptop 3080 on Windows with display and browser on the same GPU: relevant. 5090 Linux server: no | S | laptop: avoids a 2x decode cliff when the card is shared (upstream's measurement) | 4 |
| R13c | `07d5ecfa`, `4a7e373d` | Wait up to 20 s for RAM before loading the expert arena; `--adapt-decay` outside 0..1 falls back to 0.7 | robustness (#4051, #1284) | n/a | `LELEKA_ADAPT_DECAY` is read with default 0.7 (`original_serve_residency.rs:470`); a range clamp and the arena RAM wait were not checked | marginal | S | none | 9 |
| R14 | `2b13a449` (`STRATA_RAM_ADAPT`), `a3bb38ec` (`PIPE_ADAPT_EVERY`), `17878ac5` (`PIPED_MTP`) | RAM-tier follows the conversation (copies from the stage buffer, 4 pairs a layer); adaptive tier in pipelined multi-GPU groups; MTP drafts in pipelined batch groups | #2010 / #4121: +12-15% two-stream on 2x A6000 (author) | rounding/placement | N/A: the 5090 profile holds the whole 50 GB bank page-locked (`rtx5090-32g.json`), so there is no partial RAM tier; no multi-GPU groups | No | - | none | - |
| R15 | `3b34b6c7`, `472de9cd`, `bc5f84fd`, `587a4744`, `3e2f45e2` (PLE residency policy `STRATA_PLE_AUTO_RAM`); `17b08c96`, `d6428bf2` (PLE compact upload, copy stream); `884e37df` (`EMBED_VRAM`); `ebe3383a`, `8dd297d0` (reader fix, `PLE_CHECK`) | Keep the 26.8 GiB PLE table resident in RAM when table + arena + 8 GiB fit; prompt-path PLE upload variants | R9700: 8K prompt PLE 845 -> 132 ms | n/a | N/A: our PLE is the KAR level-2 archive (50-byte rows) in a sealed memfd with a GPU row cache. The reader fix is in section 5 | Prompt path only | - | none | - (fix: section 5) |
| R16 | `f8ff3420`, `c7a0cef1`, `8c030148`, `3478382e`, `f62589fd`, `01e404c1`, `cea3ed40`, `0f7224d1`, `f73b3c86`, `ca378670`, `85e3dde5` | Conversation cache / checkpoint / parking series (opt-in async checkpoints, parked K/V in VRAM, ready pool; identity and OOM fixes) | e.g. root checkpoint re-read 323 ms -> 4130 ms regression fixed (`c7a0cef1`) | n/a | Different design (cross-session prefix cache with request-end checkpoints, `docs/prefix-cache.md`). The bug classes are checked in section 5 | Out of this area: hand to the cache / prefill reviewer | - | - | - |
| R17 | `45c9e623`, `91d4d7ff`, `3a267530`, `2251053b`, `a0fc88ab` | Tools: `STRATA_LOGITS_DUMP` (post-window logits tap for KL), `STRATA_TRACE` one clock, serial decode timing includes adaptive waits, timings on `/v1/responses` | n/a | n/a | We have `STRATA_LOGPOS` top-k rows and the DBG window lines | Low | S | none | 9 |
| R18 | `a3ab37fc` | Master switches `STRATA_DEFAULTS=026` / `DS4_DEFAULTS=026`: every default changed since 0.2.6 behaves as 0.2.6; explicit variables still win | n/a | n/a | n/a | **Use it for the vanilla arm of any A/B built from 0.2.8**: it makes a 0.2.8 binary route and sum as 0.2.6 did (GR_UP_WIDE, GR_V3, IMMA, PLE policy, cache reserve off) | S | removes a hidden 1-3% (upstream's claims) from the vanilla baseline | 1 (process) |
| R19 | `d7ad4a27`, `1d00c018`, `8d56d417`, `13c4aebe`, `3fd5a748`, `1d380fad`, `e5cfa4bb`, `2465b937` (gfx12 decode split 0.15 and four decode switches) | AMD R9700 tuning, HIP only | R9700: +9.9% at 8K, +25.6% at 32K decode (`8d56d417`) | text can differ (4 of 6 prompts within 64 tokens) | N/A (HIP). The idea "start the miss split lower where the CPU is strong" is covered by our measured DMA share and the PcieAuto plan row 3.3 | No | - | none | - |
Notes on rows that are not code: the upstream tuner (`strata_control/tune_knobs.py`, in the tree since before the pin, range commit `e0d47034` only changes preset handling) records bounds
measured by upstream that bear on our speculation settings: `--spec` choices 3 or 4 only (wider "4% to 16% slower", a 2-token window "4% to 11% slower" on Flash-Next), `--lookup-chain`
"3% to 8.5% slower", `--spec-min-p` 0.3-0.7 tried values 0.7 and 0.5, `--adapt-every` 1-4, `--adapt-swaps` 80-160, `--adapt-decay` 0.7-0.97, `--pcie-frac` at most 0.55, a 3% win margin per round. Our
adaptive window (8 rows, `spec_min_p` 0) is measured better than fixed 4 on our workloads (`docs/adaptive-spec.md`), so these are not reasons to change ours, but they say upstream's best
CUDA setting is `--spec 4 --spec-min-p 0.5` (setup default, `setup.py:9851`, `strata_cli/launch/adopt.py:93`).
## 3. Reviewed and skipped (one line each)
| Group | SHAs (examples) | Why skipped |
|---|---|---|
| DeepSeek-V4.1 engine, Engram, DSpark | about 130 commits, e.g. `0c5b157f`, `bdde6972`, `a266bdfe`, `e4328457`, `e83b82af` | other model. Looked at for transferable ideas (Q8 drafter head `a266bdfe`, 8 head columns a pass `e4328457`, drafter confidence cut `e83b82af`): they are DSpark / DeepSeek head changes, no transfer to the Qwen MTP block identified |
| Metal / Mac / SYCL / Arc / DGX Spark | about 130, e.g. `611530d9`, `8d3c9761`, `bf8d88b9`, `a6fd7885`, `f262b81b` | other backends; SYCL `--pipeline-windows 2` (two cards, windows run on neighbouring cards) needs two cards; Metal "keep the GPU busy while the CPU lane runs" (`8d3c9761`, decode +25-35% on Metal) is the same idea as our CPU-callback overlap and not applicable to CUDA graphs |
| Prefill: layer-major, KVA, fused int8 prompt experts, GDN TC, dequant side stream, PLE compact | `ffe40c16`, `6eff377a`, `f4012d63`, `750ca8c3`, `e3450e45`, `10c8cc62`, `8c2a8469`, `dc390c38`, `c47c6994`, `dd97421d` | prefill area (other reviewer). KVA ships OFF in 0.2.7 final (`e3450e45`), layer-major is multi-GPU only |
| Pascal / GP100 / sm_75 / sm_80 / Ada | `6a6d58ad`, `9067cc64`, `5dbd8774`, `a3389901`, `f213f78b`, `38b06316` (Gyro-L TQP5-7 types) | other cards / other quantisations |
| Qwen3.6-35B-A3B engine | `6c01f85a` (penalty index past a short row), `src/qwen35/*` | other model; the same hazard is checked in section 5 (B6) |
| App, host, Monitor, Terminal, setup, Docker, updater, installers, web chat, MCP, serve tool-call recovery, `tool_call_recovery` default on (`3fcb2106`), stop ids (`43f32b30`) | the remaining ~200 | not decode. `3fcb2106` / `d7113273` / `b72f56e0` (tool-call recovery) are gateway items for the protocol reviewer |
| Split serving, pipelined batch | `690172c4`, `3813a459`, `3480bf2b` | upstream measured it slower than the layer split on two identical cards; needs two different cards |
## 4. Defaults that changed upstream (Qwen3.8-Flash-Next, CUDA), pin -> 0.2.8
Net of reverts. "Off switch" is what upstream gives; `STRATA_DEFAULTS=026` returns all of them to 0.2.6 behaviour (`defaults_026.hpp`).
| Default | Where it applies | Net state at 0.2.8 | SHAs | Output changing? |
|---|---|---|---|---|
| `STRATA_GR_UP_WIDE=1` | cc 12.0 CUDA (RTX 50, RTX PRO Blackwell) | **on** | `d39e2a75` | no (bitwise) |
| `STRATA_GR_V3=1` | cc 12.0 CUDA, discrete, > 13 GiB | **on** | `54d9363c` | yes, rounding level |
| `STRATA_PROMPT_ATTN_IMMA=1` | CUDA cc >= 8.0 | **on** (prompt) | `54d9363c` | yes, rounding level (prompt only) |
| `STRATA_MMVQ_IL_89`, sm_80 wide dequant + MMVQ-IL tables | cc 8.9 / cc 8.0 only | on there | `663ec80a`, `269c6d3e`, `91aebae6` | no (bitwise) |
| `STRATA_ROUTE_PRIOR` | CUDA discrete <= 13 GiB | on at 2.0, then 1.5 in 0.2.7; **off again in 0.2.8** (`route_prior_default()` answers 0 everywhere) | `c30656aa`, `0afaaa39`, `20a63cf0` | yes (when set) |
| `STRATA_KVA` (approximate late-layer prompt read) | one CUDA/HIP device, cold prompt >= 4096 | on for a few hours (`750ca8c3`), **off in 0.2.7 final** (`e3450e45`) | | yes |
| `STRATA_PLE_AUTO_RAM` | table + arena + 8 GiB fits in RAM | on | `3b34b6c7`, `472de9cd`, `587a4744` | no |
| Auto expert cache keeps 256 MiB for late allocations | `--expert-cache auto` | on, not under `STRATA_DEFAULTS=026` | `cfa197e2` | placement |
| Decode miss split start 0.15 | gfx12 (HIP) only | on | `8d56d417` | placement |
| Layer-major prefill, pipelined two-card batch groups | two or more CUDA cards | on | `37e4832a`, `ec8e4059` | rounding / scheduling |
| sm_121 table (`PF_FUSED`, NVFP4 w4a4, `HC_UPMIX`, `SPEC_COST`) | GB10 only | on | `9a398bd5` | yes (prompt) |
| `--adapt-decay` out of range -> 0.7; arena RAM wait 20 s | all | on | `4a7e373d`, `07d5ecfa` | no |
| Unchanged and worth recording | setup default `--spec 4 --spec-min-p 0.5`; route tail skip 7 (CUDA, < 90% cached, lossy); PcieAuto (CUDA, one GPU); sm_120 bitwise set (`SIDE_MIXER=2`, `ATTN_DAILY`, `GR_UP75`, `GR_DOWN_TG=1`, `GU_SWIGLU`) | | pin | |
## 5. Bug fixes we should take (correctness first)
"Affects us" is stated only where it was checked from the source; everything else is a question for the owner of that code.
| # | SHAs | Upstream bug | Do we have it? | Action | Effort |
|---|---|---|---|---|---|
| B1 | `a8c1d4b7`, `2a9a67c1` | Window graph instantiate out of memory ended the engine ("verify: instantiate: out of memory"); `cudaGraphUpload` failure left a pending error that killed the next kernel call | Same hole by reading: `original_gpu_schedule.rs:416` propagates `instantiate` errors, no eviction of other window sizes. We run the card to ~300 MiB free (reserve 130 MiB opt-in) | On instantiate OOM, drop the graph of the largest other window size (never the one being captured) and retry; treat upload failure as non-fatal. Test with a forced low-VRAM budget | S-M |
| B2 | `ebe3383a` | After a failed read the PLE reader's worker parked but `issue()` kept queueing, so the next `collect()` waited forever | Not checked in our reader (`crates/model-format` `ple_reader`, KAR PLE `read_rows` threads). The plan row 0.4 covered a different PLE bug (`36381540`) | Add the test "reader after a failed read: issue/collect return the error, never block" | S |
| B3 | `f8ff3420`, `c7a0cef1`, `8c030148`, `3478382e`, `f62589fd` | Cache retained a K/V image by token count, not by conversation (another conversation answered from the wrong history); parking dropped the richer checkpoint; a checkpoint copy OOM ended the engine; leaked copy streams | Unknown. Our cache is keyed by token content (prefix cache), a different design, but the plan (results of 2026-10-27) records `driver error: HostAllocation` when a second stack was opened with a 20,000 MiB prefix cache on a loaded host | Hand to the cache reviewer: (a) can a retained image outlive the conversation it belongs to, (b) does a checkpoint-copy allocation failure skip the checkpoint or end the request | S (review) |
| B4 | `7d1016f3`, `789d8390` | Fused q8_1 tails divided differently from the consumer quantiser; one-token window skipped the commit graph | **No** (section 2, R8) | none; keep the check in mind if a fused quantiser is added | - |
| B5 | `6c01f85a` | Penalty applied to a history token outside the draft-vocab row (host out-of-bounds write) | **No**: `coupled_penalize_kernel` maps through `id_to_sub` and skips an index outside 0..nv (`mtp_original_full_coupled.cu`) | none | - |
| B6 | `3100ca05` | CUDA free-memory query overstates free VRAM on WDDM when another process holds memory; a card filled to 0 MiB free decodes at 40-50% of speed | Possible on the Windows laptop path (unverified) | Use NVML `memory.free` for the budget on Windows/WSL | S |
| B7 | `4a7e373d`, `07d5ecfa` | `--adapt-decay` outside 0..1; arena load with too little RAM stalls the host in reclaim | `adapt_decay` clamp not checked; arena wait not present | Clamp with a log line; optional bounded wait | S |
| B8 | `45c9e623` | `STRATA_LOGITS_DUMP` tap (not a bug) | n/a | If we want a vanilla 0.2.8 reference for KL, use this instead of `--dump-logits` (plan 0.2) | S |
## 6. Outside the range, not in the existing plan's rows (pin-level, for completeness)
These exist at `41cf05a0`; the plan's rows 2.1/2.2/3.3/3.4 and the digest do not list them (grep of `docs/` and `crates/` finds no hit unless stated). Claims are from `docs/DETAILS.md` of the head.
| ID | Switch | What | Claimed gain (source) | Output | Comment | Effort | Prio |
|---|---|---|---|---|---|---|---|
| P1 | `--draft-vocab en` (`data/draft_vocab_en.bin`, left out of our tree by `docs/upstream.md`) | MTP head proposes only from an English + code subset of the vocabulary (default subset includes CJK) | `--mtp-draft-vocab draft_vocab_en.bin` "+2.7 to +3.1% decode for English text" (release notes 0.2.7); ~110 MiB less VRAM (`DETAILS.md:321`); `fr` subset 141 -> 158 tok/s in French on an RTX 5090 (`DETAILS.md:1345`, the reporter's number) | verification keeps the output exact, but acceptance changes window shapes, so rounding class changes; needs gate Q with the run-to-run control | We already carry subset machinery (`rt/draft_vocab.bin`, `id_to_sub`, `set_subset`). Data file must stay outside Git: frozen server directory, sha256 in a manifest. 110 MiB is ~55 slots | S | 3 |
| P2 | `STRATA_QSA_SPLIT_ATTN=1` | decode attention split across up to 20 blocks per query on the int8 tensor-core kernel (int8 KV, sm_80+), merged with log-sum-exp | +2.8% / +3.5% decode after a 30K prompt (RTX 3060 / A4000), KL 0.0016 against a floor of 0.0012 (`DETAILS.md:1430`) | rounding level (not bitwise) | Directly on the 245k path (attention over selected cells, 12 QSA layers a window). Our decode attention is the Original chunk kernel (`leleka_qsa_decode_chunk`) or opt-in ATTN_DAILY (no e2e gain, `a741f8e5`). Probe model-free first | M-L | 6 |
| P3 | `STRATA_EXPDEC=1` | gate/up of resident experts with the window's q8_1 rows staged in shared memory (`docs/EXPERTDEC.md`); in the gfx12 default set | +0.5% / +1 to +5% (`DETAILS.md:1430`) | bitwise | Overlaps `GU_SWIGLU` (ported, default off, no e2e gain). Low | M | - |
| P4 | `STRATA_HC_REQ8=1` | hyper-connection projections as int8 + scale per 32 to free VRAM for slots | -0.2% / +2.2% (`DETAILS.md:1430`) | rounding level | Our dense weights are 4,578 MiB against vanilla 3,485 MiB (`decode-gap-5090.md`); another route to slots, lossy | M | - |
| P5 | `STRATA_B6_MMVQ_ROWS`, `STRATA_QSA_ROWS` | exact multi-column MMVQ / block scores with queries in registers | +0.2-2% / -0.3% (`DETAILS.md:1430`) | bitwise | sm_86 defaults; our laptop switch audit is `docs/experiments/2026-10-28-s3-5-sm86-switch-audit.md` | S-M | - |
| P6 | `gdn_step_commit_layers` (fused commit, 109 us) and `prefetch_ple` during the draft | vanilla commits in one kernel and prefetches the draft's PLE rows | no number; it is why vanilla's draft is 0.93 ms against our 1.7 ms (`draft-tail-5090.md`) | bitwise (commit), identical (PLE) | Already identified in `draft-tail-5090.md` as "examined, not done"; keep there | M | - |
| P7 | PcieAuto, `ADAPT_LAG`, `ADAPT_NOWAIT` | pcie_frac from the CPU speed; lagged / non-waiting swaps (sm_86 default) | 3060 x1.300 (PcieAuto); A4000 -6.3 points when ADAPT_* removed (`nv_defaults.cpp` comments) | placement | Plan row 3.3 (todo). Relevant to the 3080 laptop more than to the 5090 (measured share 0.55 there) | M | 9 |
| P8 | `STRATA_EXCHANGE_ROTATE=1` | removes the host memcpy of an expert exchange with the RAM complement | 164 -> 188 tok/s on a Windows RTX 5090 with ~30 swaps a window (`DETAILS.md:1396`) | bitwise | N/A: our 5090 bank is fully pinned, swaps are GPU slot rewrites only | - | - |
| P9 | `--pool-affinity measure` | times `all` and `p-cores` pool layouts at start | 148 -> 188-191 tok/s on an i7-13700K | bitwise | Hybrid P/E CPUs only; neither the 9950X3D nor the i9-11900H is hybrid | - | - |
## 7. Recommended order
1. **R18 (process, S)**: when a 0.2.8 vanilla binary is used as the baseline, start it with `STRATA_DEFAULTS=026` (or state GR_UP_WIDE / GR_V3 explicitly) and record the choice in the run
metadata. Without it the vanilla arm silently carries two new sm_120 defaults whose claimed gain (+1-3% on an all-resident card) is the size of our run-to-run spread.
2. **B1 graph-instantiate OOM fallback, B2 reader failed-read test, B3 cache-identity review (S-M, no GPU needed).** Correctness before speed. B1 matters because the slot work keeps lowering the
free-VRAM margin.
3. **P1 `draft_vocab_en`** (S): lossless wrt verification, ~55 more slots, claimed +2.7-3.1%; one paired A/B on the frozen corpus plus a q_pair control run. Cheapest candidate with a claimed gain.
4. **B6 / R13b NVML free memory for the Windows laptop** (S): upstream measured a 2x decode cliff when the card fills; relevant to the 3080 target, not to the 5090 server.
5. **R1 `GR_UP_WIDE`** (S-M): model-free probe first (byte-compare against `chain_gr_up16`/`up8`, time at T = 1..8 on 170 SMs); port only if the probe shows more than ~3 us per read.
6. **P2 `QSA_SPLIT_ATTN`** (M-L, rounding level): the only upstream kernel idea aimed at attention at depth that we have not looked at. Model-free probe at 245k cells first; lossy gate Q.
7. **R5 route prior as an experimental flag** (M): only after the lossless items. Expect it to fail the Q gate; if it passes Q it still needs an agent-task completion gate because upstream saw
loops in long agent sessions with it. Never in a profile before that.
8. **R4 `GRAPH_PRIO`** together with the SIDE_MIXER GDN half (S): only if SIDE_MIXER shows an e2e signal; alone it has nothing to schedule.
9. R13a/R13c, P7 (laptop), R17 as housekeeping.
Do not port: R2, R3, R6, R7, R9, R10, R11, R14, R15, R19, P3 to P6 (P6 stays in `draft-tail-5090.md`), P8, P9.
## 8. What may explain upstream's tokens per round and round time against ours
Sources: `docs/experiments/decode-gap-5090.md`, `vanilla-decode-5090.md`, `draft-tail-5090.md` (all state that the early numbers are unpaired and superseded by the speed-train paired A/B; used here only for shape).
* **Tokens per round are not higher upstream.** 245k session: ours 2.05-2.13 per round (adaptive, `spec_min_p` 0), vanilla 1.79-1.88 (`--spec 4 --spec-min-p 0.5`). Upstream's short-context all-resident figures imply about 2.4
tokens per round (arithmetic from two upstream claims, not measured: story 192.0 tok/s with a 11.80 ms verify round plus ~0.9 ms draft). No commit in the range changes this.
* **Round time (old unpaired runs, 245k):** vanilla 11.81 ms (tail skip off, timed) / ~12.3 ms (untimed, from 154.5 tok/s at 1.9 tokens) against ours 15.2-15.35 ms (seed-off runs; 19.2 ms in the first seed-on table). Parts: verify window 10.65 vs 12.5-13.3 ms;
draft 0.93 vs 1.7 ms; adaptive tier 0.21 vs 0.69 ms. Vanilla's VRAM hit rate is 96-99% (12,575 slots, global ranked profile, 3-8 swaps a window); ours 76-83% (11,280 slots, ~4.0 non-VRAM
entries per layer-window against 0.7-0.9, 18 swaps a round; these are the old seed-on runs). After "seed off + upstream ranked profile" the paired A/B read 134.9 (ours) against 135.4 (vanilla) tok/s, vanilla varying 20% between runs.
* **In the range:** nothing changes vanilla's tier, controller or CPU pool on CUDA. The only things 0.2.7/0.2.8 add for a 5090 are `GR_UP_WIDE` and `GR_V3` (claimed +1.9%/+0.7% and +1.2% with every expert resident)
and a 256 MiB smaller cache (about -1% slots). So a 0.2.8 vanilla can be ~0-3% faster than the 0.2.6 vanilla of 133 tok/s that we compare against, which is why R18 is first.
* **Lossy defaults in vanilla:** route tail skip 7 is on by default (CUDA, < 90% cached). Our attribution attempt found no share of the gap in it at 256k on the 5090 (`decode-gap-5090.md` section 3, unpaired), while
our own port of it gave +15.2% on the 9e3 replay and failed its quality gate. If the paired result confirms "no share", the vanilla advantage is lossless.
* **What upstream cannot explain:** a figure of 200-220 at 245k. With ~2.05 tokens per round that is a 9.3-10 ms round, below vanilla's 11.8 ms on the same card; with a 14 ms round it needs ~3 tokens per round. Upstream
shows neither. Its tuner says wider windows (>= 6) are slower and its `lookup-chain` is slower; the remaining untested upstream-side speculation lever is the DFlash2 drafter (`src/core/dflash2.cpp`), which is
opt-in, has no published number, and is not documented in `docs/` (nothing in the range changes it except a compile guard, `4c7bce3a`).
## 9. Not verified, limits
* No GPU run and no build. Effort and gain estimates are mine; gains marked "estimate" are arithmetic from our own per-kernel microseconds or ledger, not measurements.
* Diffs read in full: R1-R9, R12, R13a-c, R18, `ebe3383a`, `f8ff3420`, `c7a0cef1`, `6c01f85a`. The rest by commit message and file list. The 82 merge commits were read by subject only.
* Upstream numbers were not reproduced; several are explicitly "theirs, not measured here" in the commit message (PR #3779 series), and upstream withdrew one of its own (`DGX_SPARK_LINUX.md`: the GB10 decode gains of `HC_UPMIX` and
`SPEC_COST` were not seen in the later paired check).
* "Have it?" was decided by grep of `crates/`, `docs/` and by reading the files named; a missing hit is not proof that an equivalent does not exist under another name.
* The existing plan rows this review touches: 2.1/2.2 (R1 and P3/P5 add to the diff list), 3.3 (P7), 3.4 (R6, R7 closed as not applicable; DFlash2 still unmeasured), 3.1 (R5 is the same family).