Files
leleka/docs/upstream-review/kernels.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 aa70d622b8 docs: upstream review of GPU kernels and prefill (Strata 41cf05a0..870aedd9)
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>
2026-10-30 03:12:45 +01:00

266 lines
46 KiB
Markdown

# Upstream review: GPU kernels and prefill (Strata `41cf05a0` .. `870aedd9`)
Date 2026-10-30. Branch `claude/upstream-review-kernels` (from `main` `e92513b7`). Area: CUDA kernels, prefill pipeline, KV, memory planner, sm_120/sm_86
specifics, WSL/laptop, build flags. Other reviewers own the CPU experts, the expert tier / speculation and the serve layer.
**This is a desk review.** Nothing was built or run, no GPU, the server was not touched. Every number is one of:
* **M** measured and written in a log or document of this repository (path named);
* **C** upstream's claim, with its source (commit message, `docs/*.md` of `strata-upstream/main`), on upstream's hardware, not ours;
* **E** my estimate from numbers in this repository, with the arithmetic or the bound given; low confidence unless said otherwise;
* **U** unverified.
Provenance: remote `strata-upstream`, `git fetch strata-upstream main` gave `870aedd9` (2026-10-29, "SYCL: the prompt attention batch is budgeted ...").
Our pin is `41cf05a0` (an ancestor; the range is linear). The range holds 585 commits, 503 without merges, 145 of them touch `src/` or `include/` or
`CMakeLists.txt` outside the DeepSeek / SYCL / Metal trees. Each of those 145 has a row below (grouped by series; the appendix lists the SHAs and the
coverage check). The other 358 non-merge commits are app, serve (Python), packaging, docs, DeepSeek, Metal and SYCL work; I scanned their subjects
(`git log --no-merges`) and read the ones that carry Qwen/CUDA measurements (`docs/DETAILS.md`, `docs/release-notes-0.2.7.md`, `docs/KVA.md`,
`docs/TROUBLESHOOTING.md`). Releases in the range: 0.2.6 (`27a8ed96`, 2026-10-25, engine 0.1.51), 0.2.7 (`a42cc3d7`, 2026-10-26, engine 0.1.52),
0.2.7.1 (`1a937829`, engine 0.1.53, ARM64 / DGX Spark), 0.2.8 (`36f6663c`, 2026-10-29, engine 0.1.54).
Terminology trap: upstream's **layer-major prefill** (`ffe40c16`) walks a *super-chunk* of several 512-token sub-chunks layer by layer. The "layer-major Original
prompt transaction" in our `crates/leleka-runtime/src/qwen_forward/session_original_prompt.rs` is only the layer loop *inside one chunk*. We do not have the
upstream feature.
---
## 1. Bottom line
1. **Nothing in this range gives the 5090 a lossless decode gain above about 2 %.** The decode-side commits are bitwise opt-ins of 0.5-1.9 % on a card that holds
every expert (RTX PRO 5000), P100/GA100/Ada/Spark tables, or they are lossy (route prior). The 141 -> 200-220 tok/s target does not come from this range; the
in-repo analysis puts the gap in expert placement, VRAM footprint and the draft (`docs/experiments/decode-gap-5090.md`, `parity-audit-5090.md`,
`vram-footprint-5090.md`; their numbers are marked superseded/unpaired there).
2. **The one structural TTFT item is old (pin era) but still open in our plan (row 3.2): the fused int8 prompt experts with grouping on the GPU.**
Upstream's own header says the MMQ path needs "a host sync to group the (token, k) pairs by expert, a gather of each expert into a 16-expert group buffer,
then ... five passes over per-slot buffers", and the fused path groups on the GPU "so the host never waits for the routing"
(`engine/strata/include/strata/prefill/moe_fused.hpp:1-16`). Our CUPTI anatomy of one 8192-token chunk (port plan, "GPU idle-gap anatomy") lists exactly those
host-side gaps. Vanilla runs this path by default on a 5090. Nobody has run vanilla with `STRATA_PF_FUSED=0` (`docs/experiments/2026-10-28-s0-7-vanilla-arms.md`
row 5 leaves it out of the arms), so the share of the old 41 s vs 55 s gap that belongs to it is **U**. Measure that first (section 8), it costs no code.
3. **Layer-major prefill (super-chunk) is the biggest lever for the 3080 laptop**, where the expert ring is copy-bound (`docs/laptop-vs-vanilla.md` section 2:
`moe.ring` 11.8 s at chunk 2048 and 14.3 s at chunk 6144, nearly constant per chunk). On the 5090 the ring is compute-bound (`rest-dma-diag`, port plan) and
the gain is small. It is lossy-class (summation order; first-token KL 0.0007-0.009 on 2 x A4000, C) and conflicts with the prefix-cache grid unless the grid is
the super-chunk.
4. **Laptop-only, lossless, small to build:** sparse `copied` events and deduplicated slot waits (`a11f8b0a`, `f217b23b`). Upstream measured ~80 / ~45 us per event
record / wait under WDDM (on an AMD RX 6900 XT, C). Our ring records and waits per expert entry (`crates/cuda-driver/src/mmq_original_ring.rs:899,959,1015,1058`).
Measure the cost on the 3080 first (a model-free probe).
5. **KVA (approximate late-layer prefill) is not recommended** for our workload: lossy, upstream itself ships it off after split 24 lost records and failed agent
loops (`docs/KVA.md`), and it costs decode (R9700 -11 %, draft acceptance falls once most cells are approximated).
6. **Correctness items to take (all small):** clamp `LELEKA_ADAPT_DECAY` (`4a7e373d`), keep a seal-time guard against nvcc 13.2.0/13.2.1 (the 5090 miscompile
warning; our sealed PTX is clean today and new compiles are pinned to 13.2.86, M, section 8 H4), check the q8_1 division flavour of `chain_swiglu_quant_kernel` against the quantizer it must equal
(`7d1016f3`), give window-graph instantiate an OOM fallback for the 459 MiB-free laptop (`a8c1d4b7`), add a ptxas spill gate (`3a3f35c6`).
7. **Already ours or not applicable:** PLE reader error path (`ebe3383a`, ours handles it, `crates/model-format/src/ple_reader.rs:722`), cross-conversation K/V reuse
(`f8ff3420`, our prefix cache is keyed by token hash chains with verified tokens, `docs/prefix-cache.md:44-47`), WSL KV pinning (`c41c0ebb`, premise false on
this laptop, `docs/laptop-profile.md:18,61`), PLE-in-RAM policy (our PLE is KAR rows), route prior (off again upstream, `20a63cf0`).
### Top 10 (details in the tables)
| # | Item | Why |
|---|---|---|
| 1 | Paired vanilla arms with `STRATA_PF_FUSED=0` / `STRATA_PROMPT_ATTN_IMMA=0` (no code) | Decides how much of vanilla's prompt speed is the fused path |
| 2 | A1 fused int8 prompt experts + GPU grouping (L) | E: 6-12 % of a 8192-token chunk on the 5090; lossy-class, gate Q |
| 3 | A2 layer-major prefill, laptop first (L) | E: 20-40 % of 3080 TTFT if the ring stays copy-bound; lossy-class |
| 4 | A3 sparse copy events / wait dedupe (S-M), after a WDDM event-cost probe | Lossless, laptop |
| 5 | H1 q8_1 division flavour check of the chain fusion (S) | Same bug class as upstream `7d1016f3` |
| 6 | H3 window-graph OOM fallback (S-M) | Laptop has 459 MiB free |
| 7 | H2 / H4 / H5 hygiene (ADAPT_DECAY clamp, nvcc guard, ptxas spill gate) (S) | Cheap, correctness |
| 8 | A4 + B1 + B2 IMMA prompt attention, GR_UP_WIDE, GR_V3 as one rounding-level bundle (M) | 1-2 % each at best (C); only after 1-2 |
| 9 | `STRATA_PF_FUSED_TILE` / tile threshold for 8192-token chunks on the 5090 (S, model-free) | GB10 gained 3-4 % from the 128-row tile (C, `9a398bd5`) |
| 10 | Reject list: KVA, GDN_TC, PF_FUSED NT/F16/WS, SELECT_LONG, HC_PERSIST, route prior, PLE_AUTO_RAM, async checkpoint switches | See rows; do not spend time |
---
## 2. What explains upstream's TTFT and per-round advantage
Our own numbers (all from `docs/upstream-port-plan.md` unless stated): vanilla Strata 0.2.6 / engine 0.1.50 on the 5090, 5 turns to ~245k tokens: TTFT sum 41.3 s,
mean decode 154.5 tok/s; ours (`rest-full*`) 57.3-57.6 s and ~111 tok/s at that time. The task brief gives newer paired runs of ~52 s and ~55 s (I read the order as ours against vanilla),
so the TTFT gap as such may already be closed; the mechanisms below are what is left on the table, not a current deficit.
**Prompt path (mechanisms found in the sources, size E).**
* *Vanilla uses `PF_FUSED` on a 5090.* `sm120_series.hpp` gates it on a compute capability 12.0 card with 80+ SMs (the 5090 has 170); it applies to every chunk of
`stream_all_min()` tokens or more (`kStreamAllMinDefault = 1024`, `engine/strata/src/prefill/prefill.cpp:186`). In that branch the host never reads the routing:
`fused::group` builds the per-expert row lists on the GPU and the experts are launched in batches of up to 128 with a pointer each (resident slot or ring slot, no
gather) (`prefill.cpp:3664-3760`). The MMQ branch (`prefill.cpp:3762-3830`, the only one we have) does a D2H of the ids, a stream synchronize and grouping on the host.
* *No per-layer GDN-state download found upstream.* In `Prefill::run_impl` (`prefill.cpp` 2900-5400) the device-to-host copies and stream syncs I found are in debug
dumps, the host-grouping branch, the peer / layer-split paths and the end of the chunk. Our port downloads 3.1 MB of GDN state per GDN layer (`gdn.state_out`,
62 ms per chunk in the plan's anatomy). That is a design difference of the port, not an upstream commit.
* Our CUPTI anatomy (M, port plan, chunk 8192 at 139k tokens, traced 1,841 ms): GPU idle 21.7 %; host-gap 9.8 %, host-sync 5.8 %, copy-wait 4.2 %, launch 0.9 %. Sites
that the fused path removes or shortens: `moe_prefill_finite -> mmq_zero` 51 ms (+5.6), the 24,014 per-expert gather launches 44 ms, the status drain before the combine
28 ms. That is ~100-130 ms of the traced chunk (E: 5-7 %), plus upstream's kernel claim (+3.4 to +9.9 % prompt on a card that holds every expert, C, `959e6c34`,
`docs/DETAILS.md` History table), so **E: 6-12 % of chunk time, low confidence**.
* The 0.2.7 defaults (`GR_V3`, `PROMPT_ATTN_IMMA`, `GR_UP_WIDE`) are **not** in vanilla 0.2.6, so they do not explain the old gap; they widen upstream's lead only
in 0.2.7/0.2.8 and are worth 1-2 % each (C).
**Per-round (decode) time.** Nothing in `41cf05a0..870aedd9` changes the 5090 verify round by more than ~2 %. The pin-era sm_120 set (`SIDE_MIXER=2`, `ATTN_DAILY`, `GR_UP75`,
`GR_DOWN_TG`, `GU_SWIGLU`) is claimed -14 % round time on a card with *all* experts in VRAM (RTX PRO 5000: 13.70 -> 11.80 ms, C, `docs/DETAILS.md`); on the 5090 about 20 %
of the routed entries come from CPU/PCIe, and the paired 247k session showed no gain from `ATTN_DAILY` / `GU_SWIGLU` (port plan, "sm_120 decode switches"). The in-repo gap
table (`docs/experiments/decode-gap-5090.md`, numbers superseded) attributes the verify gap to the cold-start burst after each prompt (prompt seed), a 6-8 % late-window miss
rate against 1-4 %, and 1,295 fewer cache slots (11,280 against 12,575), plus a draft that costs 2.0 against 0.9 ms per round. None of these has an upstream commit in this
range. The route tail skip is *not* the cause on the 5090 according to that page (vanilla hits 96-99 % either way), which contradicts the +15.2 % of the 9e3 replay in the port
plan (that replay had a 9,100-slot tier); the pair that would settle it (`v-nsk-t`) was never run.
---
## 3. Prompt path and prefill (TTFT)
Columns: Ours = state in this repository (grep of `crates/`, port plan row). 5090 / 3080 = applicability to Qwen3.8-Flash-Next IQ3_S. Gain is for us, E unless marked.
| ID | Upstream (SHAs, files) | What it does, claimed gain (source) | Numerics and gate | Ours today | 5090 / 3080 | Effort, gain for us | Prio |
|---|---|---|---|---|---|---|---|
| A1 | Pin era `959e6c34`, `b1e0fdaa` (default on); in range `bdcc34df`, `10c8cc62`, `c47c6994`, `9a398bd5`, `9e203190`. `include/strata/prefill/moe_fused.hpp`, `moe_fused_iq.hpp`; `src/prefill/moe_fused.cu` (751 lines), `moe_fused_iq.cu` (1544 at pin, 2135 at main); integration `prefill.cpp:3664-3760` | **Fused int8 prompt experts**: activations to int8 once per token, grouping on the GPU (`fused::group`), one launch per batch of up to 128 experts reading each expert where it is (cache slot or ring slot), gate/up + SwiGLU + int8 H + down in one pass on `mma.sync m16n8k32`. Claims: prompt +7.0 / +5.2 / +3.4 % at 4K / 20K / 98K, +9.9 / +5.4 / +3.4 % in the History table (RTX PRO 5000, IQ3_S, experts resident, 3/3 and 6/6 pairs, C: `959e6c34`, `docs/DETAILS.md`); KL vs MMQ 0.0002 (5,998 positions) and 0.0010 (after 6K documents). Range commits add opt-ins for GA100/CMP: `PF_FUSED_NT=256`, `PF_BATCH=N` (`bdcc34df`, +4-8 % prompt on a CMP 170HX, C), `PF_FUSED_F16` / `PF_FUSED_WS` (`10c8cc62`; WS needs ~101 KB smem, "not available" on sm_86/89/120), `PF_FUSED_Q2N` (`c47c6994`, Q2_0 pack), and a GB10 tile rule (`9a398bd5`, below) | Rounds differently from MMQ (int8 activations and H): **lossy-class, gate Q** (`scripts/quality/q_tail_gate.py`, p99/max/flip <= 1.25 x run-to-run control) plus L. Not bit-comparable to the Original | **Absent** (no match for `fused_iq`/`PF_FUSED` in `crates/`). Plan row 3.2 "todo". Our ring is ggml MMQ + host grouping (`moe.prepare` 122 ms, `moe.spans` 26, gather launches, plan anatomy) | 5090: yes, upstream default (170 SMs >= 80). 3080: no, upstream keeps MMQ below 80 SMs (`b1e0fdaa`: 4.7 % slower on a 48-SM 5070; `c47c6994`: 4.5 % slower on an A4000) | **L** (about 2,300 lines of CUDA to seal for sm_120, a ring/launch rewrite in `mmq_original_ring.rs`, identity + Q gates). **E: 6-12 % of chunk time on the 5090** (section 2 arithmetic) = 3.5-7 s of a 58 s 5-turn TTFT sum; the host-wait part is certain to disappear, the kernel part is C. Note upstream only takes it in the streamed walk (`stream_all`, chunk >= 1024) | **P1** after M1 |
| A1b | `9a398bd5` (`moe_fused_iq.cu` `pick_ww`), `STRATA_PF_FUSED_TILE=64\|128` | On GB10 the 64-row tile was chosen everywhere; forcing 128 rows gave +3.7 / +3.4 % at 16K and +4.3 % at 32K (C, 12 samples a cell); on an RTX 5070 the 128-row tile was slower at 2048-8192 tokens (comment above `pick_ww`). The 5090 at chunk 8192 has 160 routed rows per expert on average, above the 56-112 band that picks 128, so it runs the 64-row tile | Tile shape only, bitwise within the fused path | n/a until A1 | 5090: candidate. 3080: n/a | **S** model-free sweep once A1 exists. E: 0-4 % of the MoE kernel time | P3 |
| A2 | `ffe40c16` (1,005 lines in `prefill.cpp`), `162dec34`, `fca1936c`, `a6df0023` (`moe_shared_init`, `moe_scatter_add`), `df7068b6`, `42094da9`, `5602253e`, `cc125e06`, `18c53576`, `e7318fa2`, `d02478b7`, `a732a34c`, `9e203190`, `945a63be`, `6eff377a`, `c6f6db85`, `37e4832a`. Credit in messages: vizdatom #1670, PR #3976 | **Layer-major prefill**: a super-chunk of S tokens runs layer by layer; each 512-token sub-chunk does the attention half, router and shared expert, then the layer's routed experts run once for the whole super-chunk (each expert staged once, rows of all sub-chunks in one MMQ group). "Expert traffic drops by about S / 512" (12.9K prompt 509 -> 79 GB on a Ryzen box, C `ffe40c16`). 2 x RTX A4000, streamed experts, first token after 8K / 20K / 32K prompts 2.8x / 4.8-5.7x / 5.1-5.5x faster (141 -> 26-28 s), decode unchanged, needles 12/12 (C `37e4832a`; baseline chunk was 512 tokens there). Defaults: super-chunk 32,768 tokens, VRAM margin 512 MiB, residual rows in VRAM or pinned host (`PREFILL_LM_R=vram\|host\|auto`). On by default only for a CUDA layer split (`prefill_layer_major_default`, `sm120_series.hpp`); one GPU stays opt-in | Another summation order of the routed experts: first-token KL 0.0007-0.009, same top choice (release notes 0.2.7, C). **Lossy-class, gate Q + L**. No checkpoint inside a super-chunk (`layer_major_mid`) | **Absent.** `layer_major` hits in `crates/` are the layer loop inside one chunk (see terminology). Prefix cache grid = chunk size (`docs/prefix-cache.md`): a super-chunk needs grid = super-chunk, i.e. coarser shared-prefix reuse (request-end checkpoints stay exact) | 5090: little. The ring is compute-bound (`rest-dma-diag`: removing all expert DMA does not shorten a chunk, M); only the per-expert launch/host overhead shrinks (24k gather launches become ~1/4). 3080: large, the ring is copy-bound (`laptop-vs-vanilla.md` section 2-3, M) | **L**: new prompt transaction (layer-outer over sub-chunks, GDN/KV append per sub-chunk, residual arena for S tokens: 40,960 B per token, 1.0 GB at 24,576), grid change, Q gate. **E: 5090 3-6 %; 3080 20-40 % of TTFT** (`moe.ring` 14.3 s of a 6144-token chunk that is ~22-24 s after the PLE fix, i.e. ~60 %, E from `docs/laptop-vs-vanilla.md` sections 2 and 4; expert traffic /4 at S = 24,576; U, the compute share of the ring is not known). Do after A1 (A1 changes the ring) | **P2 laptop, P3 5090** |
| A3 | `a11f8b0a`, `f217b23b`; `include/strata/prefill/copy_events.hpp`, `src/prefill/prefill.cpp`, `src/prefill/copy_events_test.cpp` | **Sparse copied events + deduplicated slot waits** in the streamed walk: `STRATA_PREFILL_COPY_EVENT_EVERY=N` records `copied` every N-th entry and the compute stream waits on the first recorded entry at or after the one it needs; `STRATA_PREFILL_COPY_WAIT_DEDUPE=1` skips a copy-stream wait when the previous slot was released by the same event. Rationale: "under WDDM every cudaEventRecord and cross-stream wait is a submission of its own (~80 / ~45 us each on an RX 6900 XT under Windows 11)" (C, AMD). Opt-in upstream, "needs the author's numbers repeated before any default talk" | Lossless (same copies into the same slots). Gate I: replay identity | Our ring does the same per entry: `copied` and `used` events recorded and waited per entry (`mmq_original_ring.rs:899,959,1015,1058`). Absent | 5090 Linux: no (Linux events are cheap). 3080 native Windows (WDDM): candidate. Entries per chunk are 15.5k on the 5090 profile and more on the laptop | **S-M** after a probe (cost of `cuEventRecord` + `cuStreamWaitEvent` on the 3080, model-free). **E: 0-7 % of a laptop chunk** (15-20k entries x ~125 us would be 2-2.5 s of a ~22 s chunk if the AMD figure held for NVIDIA WDDM; U) | **P2 laptop** |
| A4 | `54d9363c` (`qsa_prompt_attn.cu`, `sm120_series.hpp`); kernel `prompt_attn_i8v3_kernel` is pin-era | **`STRATA_PROMPT_ATTN_IMMA` default on for sm_80+**: both attention products on INT8 tensor cores. +1.6 / +1.8 % prompt at 8K / 16K (RTX PRO 5000), +1.1 / +1.3 % (2 x A4000), +2.5 % (RTX 3060 / A4000 History row), 5 pairs (C) | Another summation order (~1e-7), "a near-tie can flip a prompt's first token". Gate Q | We have the v2 cp.async INT8 kernel only (`crates/cuda-driver/src/qsa_prompt_attention.cu`, `..._variants.cu`); no IMMA | Both cards (sm_80+) | **M** (port one kernel, seal, sm_86 companion). E: <= 1-2 % of the prompt attention stage = <= 0.5 % of TTFT (attention 113 ms of a 1.6 s chunk, ledger) | P4 |
| A5 | `f4012d63`, `011e5bec`, `c5cf218e`, `5b469ee9`, `053a4157`, `750ca8c3`, `7a34c60d`, `6c00851a`, `31712914`, `e3450e45`, `25a62e0f`, `76cd7d79`, `bda30050`, `45c9e623`; `include/strata/prefill/kva.hpp`, `kva_floor.hpp`, `prefill.cpp`, `docs/KVA.md` | **KVA**: for a cold prompt of >= 4096 tokens the late layers (36-47) build only their recurrent state (GDN, QSA K/V, indexer keys) and skip attention output, MoE and the expert transfers; the last 2048 tokens run exactly. Claims: RTX 5070 prompt +11 % at 14K, +18 % at 30K; P100 +12 / +20 %; R9700 27K needle prompt +28 % but **decode -11 %** (tokens per round 4.08 -> 3.33) because draft acceptance falls (C, `docs/KVA.md`). Shipped **off** in 0.2.7 after split 24 (layers 24-47) lost records in extraction tasks (249 of 270 facts) and passed 0 of 10 agent runs on an RTX 5070 | **Lossy**; KL 0.018-0.020 nats at the first token with split 24 (C). Needs its own quality gate and an agent-task gate | Absent | Applies to one CUDA/HIP device. For us: 256k agent sessions are exactly the case where nearly all cells would be approximated on the first read and the draft layer then misses | **Not recommended.** Decode is our first priority and the draft penalty grows with context. If ever tried: opt-in flag, laptop first, agent-task gate. E: first-read TTFT -10..-20 %, decode -5..-11 % | Reject |
| A6 | Opt-ins of the contributor wave (#3779 / #3712, #3752, #3455, #3867, #3943, #3751): `8c2a8469` (`GDN_TC`), `dc390c38` (`DEQUANT_SIDE`), `17b08c96` + `d6428bf2` (`PLE_COMPACT`, `PLE_COPY_STREAM`), `884e37df` (`EMBED_VRAM`), `dd97421d` (`mmq::swiglu_quant`), `5dbd8774` (`MMQ_WS`), `9067cc64` (`EXPERT_NIBBLE`), `6a6d58ad` (`DOWN_WS`), `a3389901` (`PATTN_SM60`), `f213f78b` (`MTP_Q8_SM60`) | `GDN_TC`: recurrence 105 -> 34 ms at 3.3K tokens on a CMP 170HX, **runs only on sm_80/sm_90** (needs 124,944 B smem; sm_86/89/120 have 99 KB, `8c2a8469` message). `DEQUANT_SIDE`: dequant on a side stream, +2.2-2.6 % prompt for the PLE/embed/dequant group on a Gen2 x4 link. `PLE_COMPACT`: raw IQ4_NL rows to the device, needs the GGUF table (ours: KAR rows). `EMBED_VRAM`: token table in VRAM (ours already has a VRAM copy: `docs/experiments/vram-footprint-5090.md`). `swiglu_quant`: fused SwiGLU + q8_1, byte-exact, but "nothing calls it" except the GP100 `MMQ_WS` path. `MMQ_WS`, `EXPERT_NIBBLE`, `DOWN_WS`, `PATTN_SM60`, `MTP_Q8_SM60`: Pascal GP100 | `swiglu_quant` bitwise (18 byte-compare cases); the others per contributor, rounding-level | None present | Not applicable to sm_86 / sm_120 (smem, Pascal, KAR PLE) except `swiglu_quant` and `DEQUANT_SIDE` in principle | `swiglu_quant`: S-M (sealed MMQ asset), E < 0.3 % (saves one pass over H, ~210 MB at chunk 8192). `DEQUANT_SIDE`: our dequant is 9 ms per 8192-token chunk on the 5090 (port plan), E < 0.5 % | Reject / P5 |
| A7 | `91d4d7ff`, `14d076ee`, `3a267530` | `STRATA_TRACE` elapsed ms per step, prompt-chunk line with stage range, one clock for the process | none | We have `PREFILL-PROFILE` and CUPTI traces | both | Idea only: the shared clock is useful for split work; not needed | Skip |
| A8 | `c5cf218e`, `5b469ee9` (inside A5), `gdn_rec_parity.cu` (+395) | State-only GDN recurrence without the output norm (KVA); parity harness gains the tc variant | | Our `gdn_out_norm_y16` already drops the dead store (port plan 2.4) | | none | Skip |
---
## 4. Decode kernels and graphs
| ID | Upstream | What and claim (source) | Numerics / gate | Ours today | 5090 / 3080 | Effort, gain for us | Prio |
|---|---|---|---|---|---|---|---|
| B1 | `d18d8ba0` (opt-in), `d39e2a75` (default on sm_120); `src/kernels/cuda/fused_gr.cu` `gr_up_wide_kernel` | **`STRATA_GR_UP_WIDE`**: hyper-connection up projection with one warp a row, grid 160 -> 1,280 blocks (192 SMs had 160 blocks). RTX PRO 5000, experts resident, 5 pairs: story 197.6 -> 201.3 (+1.9 %), code 243.5 -> 245.1 (+0.7 %), token ids identical (C) | Bitwise (same dot, xor tree, epilogue) | Our chain GR up kernel is already 5.7 us at 4 rows against the Original's 8.9 (`docs/chain-kernels.md` section 8; `chain_gr_up8`, grid differs); the plan marks `GR_UP75` "not ported, equivalent". Not probed against the wide kernel | 5090 yes; 3080 no (sm_86 default off) | S probe (model-free byte-compare + timing of upstream's kernel against `chain_gr_up8` at T = 1..8). E: 0-1 % of a round, likely 0 because the chain kernel already spreads the work | P4 |
| B2 | `54d9363c` (`gr_v3_default`) | **`STRATA_GR_V3` default on** for a discrete cc 12.0 card above 13 GiB: stream-split HC read. RTX PRO 5000 +1.2 % decode (code 245.1 -> 248.1), identical tokens; -3.0 / -5.9 % on 2 x A4000 and +1.0 / -3.4 % on a 3060 (C) | Another summation order (~1e-7), not byte-identical to 0.2.6. Gate Q | Not present as such (`mtp_original_scalar_prefill.rs:79` says "GR_V3 is deliberately a separate producer"). Our chain GR read is a different design | 5090 yes; 3080 no (measured slower on sm_86) | M, E <= 1 % | P4 |
| B3 | `2395c8a5` (`STRATA_HC_PERSIST`), `f1dadd17` (its `__nanosleep` guard for sm_60) | The HIP persistent one-kernel HC read ported to CUDA. RTX PRO 5000: story **-5.4 %**, code +1.6 % (C). Opt-in, "kept as the starting point" | Another summation order | Absent | no | Reject (negative on CUDA) | Reject |
| B4 | `0049fa73` (`STRATA_GRAPH_PRIO`) | Gives the window graph's kernel nodes their stream priority (`cudaGraphInstantiateFlagUseNodePriority`): CMP 170HX +1.8 % (C). Bitwise by construction | none | Our window is one stream with no cross-stream edges (`docs/chain-kernels.md` section 2.3); there are no side branches to prioritise until `SIDE_MIXER` is ported | | S once `SIDE_MIXER` exists; E 0 now | P5 |
| B5 | `8b95bffb` (`MMVQ_IL_PF`), `c2d3fe50`, `269c6d3e`, `91aebae6`, `bdecbffc`, `2299c8f7`, `663ec80a`, `25796351` | Interleaved-MMVQ Q6_K hoisted-load variants (table only for sm_80); wide dequant and IL tables on sm_80; Ada (cc 8.9) tables. +1.4 % decode on a CMP 170HX (C) | Bitwise | none | sm_86 / sm_120 get nothing: tables are for cc 8.0 and 8.9 only (`sm80_default_on`, `mmvq_il_89_default` in `sm120_series.hpp`) | none | Reject (not our cards) |
| B6 | `b434a8aa` (`STRATA_SELECT_LONG`), `qsa_select.cu` (+528) | Multi-CTA decode top-k and a shuffle-free scorer. Built **only in the experimental sm_60 build** (`STRATA_EXPERIMENTAL_SM60`), GP100 four-die claim +2.9 % at 115K (C) | Same ids / score bits | We already have the cluster top-k on sm_90+ (port plan 2.5: 183 -> 19.5 us per call at 245k tokens) | no | none | Reject |
| B7 | `7d1016f3`, `789d8390`, `11b04902`, `7c4c2079` (touches `fused_gr.cu`) | `STRATA_QFUSE` fixes: the fused q8_1 producers divided with IEEE `/` while the separate quantizer is compiled `--use_fast_math` (`div.full.f32`), giving a different q8_1 code at ~1 element in 10^6; and a one-token window did not self-commit under QFUSE. Together they explained text changes and lower MTP acceptance (C, `7d1016f3`, `789d8390`) | The first is a bit-parity bug class (see H1) | Our port has no QFUSE. But `chain_swiglu_quant_kernel` is a fused producer (SwiGLU + q8_1) compiled `--fmad=true --ftz=false` with IEEE division (`scripts/q8/rebuild_quantizer_ptx.sh`, `chain_window.cu:714`) | both | See H1 | P1 (check) |
| B8 | `c30656aa`, `0afaaa39`, `20a63cf0`; `7c4c2079`; `sm120_series.hpp` | Residency-biased routing (`STRATA_ROUTE_PRIOR`): default on at 2.0, then 1.5, for discrete NVIDIA cards <= 13 GiB in 0.2.7 (story +15 %, code +37 % on a 3060 12 GB, C); **turned off again in 0.2.8** (#4402: repetition loops; 4.5 of 10 agent tasks against 5.6) | Lossy (changes experts) | We have no route prior | no (5090 32 GB, 3080 16 GB are above 13 GiB) | none | Reject |
| B9 | `9d3c8c36`, `b119f40f` | Verify / batch windows up to 16 rows, HIP default 16, CUDA stays 8 (`window_limits.hpp`). Costs 14 MB kernels and 16 MiB VRAM in a 16-row CUDA build | Bitwise below 9 rows | Our MTP window is 8 | no | none | Reject |
| B10 | `f4612b1a`, `499e9635`, `ca17d0f5`, `447460e8`, `4c7bce3a` (`STRATA_SPEC_PROB`, gated proposal) | Probabilistic acceptance that keeps the target probabilities (#3416), window-invariant CPU arithmetic. "a correctness change, not a speed change" (`docs/DETAILS.md`) | Changes sampling, not greedy | Speculation owner's area | | none | Skip (other reviewer) |
| B11 | `6c01f85a` | Penalty for a history token beyond the logit row indexed past the row (#3911), in `src/qwen35/` (Qwen3.6 engine) | | n/a (other model) | | | Skip |
---
## 5. Memory planner, footprint, robustness, build
| ID | Upstream | What and claim (source) | Ours today | Applicability | Action, effort, gain | Prio |
|---|---|---|---|---|---|---|
| C1 | `cfa197e2`, `include/strata/core/auto_cache.hpp` | The automatic expert cache leaves `kLateAllocMib = 256` for what the load allocates after it (cuBLAS handles and workspaces, lazily loaded modules, verifier buffers): the card ended ~240 MiB under the requested reserve (459 MiB free at reserve 700 on an A4000; measured with `STRATA_TRACE`, C). About 100 slots (1.8 % of a 16 GB card) | We have the budget-aware planner and a 300 MiB decode reserve (`docs/experiments/vram-footprint-5090.md`, M: lowest free 563 MiB on the 5090) | Same concern on the 3080 (laptop reserve 1,024 MiB) | None; confirm with `LELEKA_VRAM_LEDGER=1` that nothing allocates after the cache on the laptop path | P5 |
| C2 | `2a9a67c1` | Later-card VRAM audit (layer split): failed `cudaGraphUpload` left a sticky error that ended the engine, per-card OOM report with NVML, stage reserve arithmetic as a tested helper. | Driver API returns codes, no sticky `cudaGetLastError` model | Layer split n/a | Idea: our OOM message could list per-process VRAM from NVML (we sample NVML in `leleka-memory`). S, no speed | P5 |
| C3 | `07d5ecfa`, `01d6f7b9` (serve) | Wait up to 20 s (`STRATA_ARENA_RAM_WAIT_S`) for the RAM the expert arena needs when a previous engine is still exiting | Supervisor owns restarts (control-plane) | | Check that our start after a crash waits for released pinned memory rather than failing preflight. S | P4 |
| C4 | `3100ca05` (`STRATA_VRAM_FREE=device`) | Under WDDM `cudaMemGetInfo` answers for the calling process: on an RTX 5090 CUDA read 30,994 MiB free where NVML read 24,348 with 6 GiB held elsewhere (C). Takes min(CUDA, NVML) | We sample NVML for telemetry (`leleka-memory/src/telemetry.rs`), but the cache planner's `card_free` is `context.memory_info().0`, i.e. CUDA's per-process figure (`crates/leleka-runtime/src/qwen_forward/original_cache_startup.rs:123,138,149`); no NVML minimum (M, source) | Native Windows laptop: only matters if another process holds VRAM (the dGPU shows 0 MiB at idle on this Optimus laptop, `docs/laptop-vs-vanilla.md`); Linux server no | `usable_room(min(cuda_free, nvml_free), ...)` on Windows. S, no speed; protects against over-sizing the cache when a browser or video app holds VRAM | P3 |
| C5 | `a8c1d4b7` | A window-graph `cudaGraphInstantiate` that runs out of memory frees the graph of the largest other window size and retries, instead of ending the engine (#3702) | `original_gpu_schedule_ffi.rs:328` returns an error on a failed instantiate; no eviction or eager fallback found | Laptop (459 MiB free) yes | S-M: on OOM free another size or fall back to eager launch, with a test that forces the failure. See H3 | P2 |
| C6 | `3478382e`, `f62589fd`, `8c030148` | Per-thread copy streams / events were never destroyed: 2-6 MiB of VRAM lost per long cold prompt on a layer split until `cudaStreamCreate` failed (#3470, #3350); a checkpoint copy OOM ended the engine; a restore is refused only if a card has no copy stream and < 64 MiB free | Prefix-cache failures drop the entry and the request goes on (`docs/prefix-cache.md:116-121`). Stream/event lifetime in `cuda-driver` wrappers not audited | | Add a leak check: free VRAM after N long cold prompts must be flat (`LELEKA_VRAM_LEDGER=1`, 100 ms sampler). S | P3 |
| C7 | `3cd33d50`, `61ede87e`, `a4c41a92`, `f262b81b`, `1a937829`, `f0f056b9`, `3a3f35c6` | Build: a CUDA build with no architecture is sm_120, `native` builds the W4A4 unit for sm_120a (#4029); Maxwell sm_52 floor; ARM64 / DGX Spark build; `cuda_spill_guard` (`tools/check_cuda_spills.py`: cuobjdump resource usage per entry, ALLOWED table, 0 violations on sm_120 and sm_86) | We seal PTX and use `ptxas`; no spill check (`grep spill` finds nothing in `crates/`/`scripts/`) | Spill gate applies to our sealed PTX | S: run `ptxas -arch=sm_120 -v` over `crates/cuda-driver/src/*.ptx` and fail on new `lmem`/spill; E: finds regressions, no speed | P3 |
| C8 | `45c9e623` (`STRATA_LOGITS_DUMP`), `e3450e45` (docs) | Post-window logits tap in the verify epilogue for KL measurement | Our gate uses top-16 log-probabilities (`STRATA_LOGPOS`) | | Idea: full-vocabulary KL for gate Q. S in the Original harness only. No product use | P5 |
---
## 6. Conversation / prefix cache, PLE, batch (mostly not for us)
| ID | Upstream | What and claim | Ours today | Verdict |
|---|---|---|---|---|
| D1 | `f8ff3420`, `01e404c1`, `cea3ed40`, `c7a0cef1` | Parked-conversation fixes for `--batch` slots: retained K/V reused across conversations (#1503), idle slot parked before overwrite, slot checkpoints only if prefixes, parking an idle slot dropped the main session's shared-prefix checkpoint (#4420: 323 ms -> 4,130 ms re-read) | Our store is keyed by token hash chains and verifies tokens on every match (`docs/prefix-cache.md:44-47`); no batch slots | Not affected. Add a test that a hit never survives a token mismatch (S) |
| D2 | `0f7224d1`, `f73b3c86`, `ca378670`, `85e3dde5` | Opt-in async checkpoint / park copies, VRAM slots for parked conversations (restore of 3K conversation 28-47 -> 7-12 ms on a CMP 170HX at PCIe Gen2 x4, C) | Request-end checkpoints are copies to pinned host (`docs/prefix-cache.md`) | PCIe 5 x16 (5090) and 4 x16 (3080) make these small. Measure our checkpoint cost per request end first; only then consider (E < 1 % of a turn) |
| D3 | `3b34b6c7`, `472de9cd`, `bc5f84fd`, `587a4744`, `3e2f45e2`, `8dd297d0`, `ebe3383a` | PLE table resident in RAM when it fits (28.8 GB IQ4_NL table; 8K prompt PLE block 845 -> 132 ms on an R9700, C); policy fixes (arena must fit too, give the lock back for the conversation cache); `STRATA_PLE_CHECK`; reader error path | Our PLE rows come from the KAR archive through `ple_reader.rs` (error path already ends cleanly, line 722); PLE read-ahead measured in `docs/laptop-vs-vanilla.md`. Upstream's own History table says `--ple-io ram` on the 72 GB card made prompts **slower** (4K -18 %, 20K -9 %, 98K -2 %) | Not applicable |
| D4 | `a3bb38ec`, `17878ac5`, `ec8e4059`, `690172c4` | Batch slots / two-NVIDIA pipelined default / split serving (#4000, slower than layer split on two A6000) | Single session product | Not applicable |
| D5 | `4a7e373d`, `2b13a449`, `cea3ed40` (also D1), `2251053b`, `41188ec7`, `8aee4538` | `--adapt-decay` range check; `STRATA_RAM_ADAPT` stage-buffer reuse; serial timing line shows adaptive waits; calibrate tool; comment fix | `LELEKA_ADAPT_DECAY` accepts any finite value (see H2) | H2 |
---
## 7. Defaults changed upstream (relative to the pin) and what they do on our cards
| Default (SHA) | Cards | Output | Off switch | Matters for us |
|---|---|---|---|---|
| `STRATA_GR_UP_WIDE` on (`d39e2a75`) | cc 12.0 CUDA | bitwise | `=0`, `STRATA_SM120_PERF=0` | 5090 yes (B1) |
| `STRATA_GR_V3` on (`54d9363c`) | discrete cc 12.0, > 13 GiB | rounding | `=0` | 5090 yes (B2) |
| `STRATA_PROMPT_ATTN_IMMA` on (`54d9363c`) | CUDA sm_80+ | rounding | `=0` | both (A4) |
| `STRATA_ROUTE_PRIOR` 2.0 -> 1.5 -> **off** (`c30656aa`, `0afaaa39`, `20a63cf0`) | <= 13 GiB NVIDIA | lossy | `=0` | no |
| `STRATA_KVA` **off** (`e3450e45`; split 36 / tail 2048 when on, `bda30050`) | one CUDA/HIP GPU | lossy | unset | no (A5) |
| `STRATA_PLE_AUTO_RAM` on (`3b34b6c7`, `472de9cd`, `587a4744`) | all | placement | `=0` | no (KAR PLE) |
| `STRATA_PREFILL_LAYER_MAJOR` on for >= 2-GPU CUDA split (`37e4832a`) | split only | rounding | `=0` | no (one GPU; A2 is opt-in there) |
| two-NVIDIA pipelined batch default (`ec8e4059`); window 16 on HIP (`9d3c8c36`) | multi-GPU | scheduling | `STRATA_BATCH_GROUPS_NV_SERIAL=1` | no |
| sm_80 wide dequant + IL tables (`269c6d3e`, `91aebae6`); cc 8.9 tables (`663ec80a`) | sm_80, sm_89 | bitwise | `STRATA_DEQUANT_WIDE=0`, `STRATA_MMVQ_IL_89=0` | no |
| sm_121 table: `PF_FUSED`, `PREFILL_NVFP4=w4a4`, `HC_UPMIX`, `SPEC_COST` (`9a398bd5`) | GB10 | rounding | `STRATA_SM121_PERF=0` | no (but shows `HC_UPMIX` +5.4 % decode where the HC read is ~13 % of a round, C `docs/DGX_SPARK_LINUX.md`; ours HC read is 3.4 of 12.6 ms of the chain, already reworked) |
| gfx12 decode switches, miss split 0.15 (`3fd5a748`, `d7ad4a27`, `8d56d417`; reverted once `1d00c018`) | AMD RDNA4 | mixed | | no |
| Windows gfx1151 shared-expert fork off (`c77292f0`) | AMD | scheduling | | no |
| CMake: no arch given -> sm_120 (`3cd33d50`) | build | | `-DCMAKE_CUDA_ARCHITECTURES` | no (we seal PTX) |
| Master switch `STRATA_DEFAULTS=026` (`a3ab37fc`) | all | | | Useful when A/B-ing against a 0.2.7+ vanilla: set it, or each switch above explicitly |
| `tool_call_recovery` on (0.2.8, serve) | | | | other reviewer |
Vanilla 0.2.6 (`engine 0.1.50`, the comparison binary) has none of the 0.2.7/0.2.8 defaults above. If the comparison binary is upgraded, A/B arms need
`STRATA_DEFAULTS=026` or the per-switch `=0`.
---
## 8. Bug fixes and correctness items we should take
Correctness first. Each is small. "H" = hygiene or check, "B" = fix.
| ID | Upstream | Finding | Action | Effort |
|---|---|---|---|---|
| H1 | `7d1016f3` | A fused q8_1 producer and the separate quantizer must divide the same way: `--use_fast_math` `div.full.f32` against IEEE `/` differ in the q8_1 code at ~1 element in 10^6, enough to lower MTP acceptance (C). In our tree `chain_swiglu_quant_kernel` (fused SwiGLU + q8_1, IEEE `/`, `--fmad=true --ftz=false`) must equal the quantizer that the Original window uses for the routed experts' down input; `scripts/q8/rebuild_quantizer_ptx.sh` compiles `native_head_iq.cu` with `--use_fast_math` and `mtp_original_full_head_iq.cu` without. Which copy the verify window uses is **U**. `docs/experiments/parity-audit-5090.md` row 7 proposes re-sealing quantizers with fast-math: that would move the other side of this pair | Model-free byte compare of `chain_swiglu_quant_kernel` against both quantizer copies on random + boundary inputs (`tools/q8-probe`, extend `probe_all.sh`); decide the flavour once, for the whole q8_1 family, before any fast-math re-seal | S |
| H2 | `4a7e373d` (#1284) | `--adapt-decay` above 1 makes the usage counts grow without end (inf after a few hundred adaptations) and swap gains NaN, which breaks the swap sort; negative flips counts. Upstream falls back to 0.7 with a line. Ours: `LELEKA_ADAPT_DECAY` accepts any finite f32 (`original_serve_residency.rs:467-473`) | Clamp to 0..1 with a stderr line (experiment knob only, default 0.7 is safe) | S |
| H3 | `a8c1d4b7` (#3702), `2a9a67c1` | Graph instantiate OOM must not end the engine. Ours returns an error from `cuGraphInstantiateWithFlags` (`original_gpu_schedule_ffi.rs:328`); the 3080 runs with ~459 MiB free | Free the largest other window size and retry, or launch eagerly; unit test with an injected failure | S-M |
| H4 | `docs/TROUBLESHOOTING.md` (RTX 50 entry, #892, #968) | CUDA **13.2.0 and 13.2.1** (nvcc 13.2.51) miscompile some kernels for sm_120 (IQ2_S / IQ3_S products wrong, relative error 0.5-1.0); 13.2.2 (nvcc 13.2.86) is right. **Checked (M):** the header of every sealed PTX in `crates/cuda-driver/src/*.ptx` names its compiler: 86 files `V13.2.86`, 56 `V13.0.88`, 58 `V12.8.93`, none `V13.2.51` | `scripts/gpu-bringup/compile_assets.py` already requires the pinned nvcc (`deploy/cuda-toolkit.lock.json`: `cuda_nvcc` 13.2.86), so new compiles are safe. The gap is files that are spliced or older: add one check in `seal_pins.py` that refuses a PTX whose header names `V13.2.0`/`V13.2.1`/`V13.2.51`, and log the nvcc build of each asset at engine start. S | S |
| H5 | `3a3f35c6` | Kernels that keep a per-thread array in local memory spill silently; upstream gates the build with `cuobjdump --dump-resource-usage` | `ptxas -v` over the sealed PTX, ALLOWED table, run in `scripts/` before sealing (also catches register growth when a sealed file is re-spliced as in row 1.1) | S |
| H6 | `3478382e`, `f62589fd` | Per-thread copy streams/events lost 2-6 MiB per long cold prompt (#3470); checkpoint copy OOM ended the engine (#3350) | Leak test on the server: free VRAM flat over N long cold prompts; checkpoint/restore failure paths return to a full read (partly covered, `docs/prefix-cache.md:116-121`) | S |
| H7 | `ebe3383a`, `36381540` (pin era) | PLE reader: failed read left the next ticket waiting; prefetch matched by position | **Done in ours**: `ple_reader.rs:722-723,774` (error sticks, no job queued); row matching is by row id (port plan 0.4) | none |
| H8 | `f8ff3420`, `c7a0cef1` | Cross-conversation K/V reuse; parking dropped the shared-prefix checkpoint | Not affected by design (hash-chain keys with verified tokens) | add one regression test |
| H9 | `789d8390` | A one-token window must not skip the commit graph when the window did not self-commit (QFUSE only) | No QFUSE in ours; but our `ONE_TOKEN_COMMIT` equivalent, if/when `COMMIT_BATCH` / one-token self-commit is ported (plan rows 2.1/2.2), needs the same "commit skipped iff the window self-committed" invariant in one place | note for rows 2.1/2.2 |
---
## 9. Pin-era items still open in `docs/upstream-port-plan.md`, re-ranked after this review
These are outside the commit range but decide the same goals; listed so the order of work is complete.
| Plan row | Item | Status in plan | Re-rank |
|---|---|---|---|
| 3.2 | Fused int8 prompt experts | todo | **= A1, P1** |
| 2.6 | WSL KV host copy `cudaHostRegister` (`c41c0ebb`) | todo | **Close.** Premise (driver caps `cudaHostAlloc(Mapped)` near 1 GiB under WSL2) does not hold on this laptop: `docs/laptop-profile.md:18` (16 x 512 MiB `cudaHostAlloc` and 1-16 GiB `cudaHostRegister` succeeded), and the port already pins its KV host copy (3.094 GiB, line 61). The native-Windows laptop runs do not use WSL at all |
| 3.4 | Chunked GDN prompt recurrence `STRATA_GDN_CHUNKED` (`0f78032f`) | todo | Claimed 1.8x on the recurrence on an RTX 5090 (`docs/DETAILS.md`), 0.73x on a 3060, 0.87x on a 5070. Our recurrence is ~4.3 ms per layer per 8192 tokens x 36 layers = ~155 ms of a 1.6 s chunk, so 1.8x is at most ~70 ms (E: 4 % of a chunk); output-changing. After A1 and A2; 5090 only |
| 3.3 | PcieAuto, async tier by measurement | todo | Tier reviewer's area; `docs/experiments/parity-audit-5090.md` row 5 is open |
| 2.1 / 2.2 | `SIDE_MIXER`, `HEAD_MIX_MULTI`, `COMMIT_BATCH`, cluster argmax ... | partly implemented, `ATTN_DAILY` / `GU_SWIGLU` default off after the 247k pair | Estimates in the plan sum to ~2-6 % of a round for all remaining items together (E, plan table). They cannot close a 141 -> 200 tok/s target |
| (not in plan) | `STRATA_PREFILL_CPU_SHARE=auto` below 1024 tokens (pin era) | absent in ours (`docs/experiments/2026-10-28-s6-1-lossy-audit.md` V-02) | Not a kernel item, but short agent deltas (tool outputs, 0.5-3K tokens) are the common turn in a real session: upstream claims -28..-34 % prompt time at 512 tokens, -20..-26 % at 1,000 (3060 / P100 / 5070, C). Hand to the CPU/tier reviewer |
---
## 10. Recommended order
0. **Measure first, no code (server GPU jobs, I cannot run them):**
* M1 vanilla 0.2.6 paired arms on the frozen 245k corpus with `STRATA_PF_FUSED=0` against default, with `PREFILL-PROFILE` per stage; same for `STRATA_PROMPT_ATTN_IMMA` and `STRATA_GR_V3` if the binary is 0.2.7+ (`STRATA_DEFAULTS=026` for the control). This sizes A1 and A4 on our own workload.
* M2 model-free on the 5090: upstream's `prefill_fused_iq_test` (in the pinned tree) against our MMQ layer pass at T = 8192 (layer time, 64-row and 128-row tiles via `STRATA_PF_FUSED_TILE`).
* M3 model-free on the 3080: cost of `cuEventRecord` + `cuStreamWaitEvent` per call under native Windows WDDM (sizes A3), and one cold-prompt VRAM leak run (H6).
1. **Hygiene, S each:** H1, H2, H4, H5, H3 (S-M), H6.
2. **A1** fused int8 prompt experts with GPU grouping (5090), identity + gate Q + L; includes the tile sweep A1b.
3. **A3** sparse events (laptop), after M3.
4. **A2** layer-major prefill, laptop first, then 5090; needs the prefix-cache grid decision; after A1 because both rewrite the ring.
5. **Bundle** A4 + B1 + B2 as one rounding-level switch set, only if M1 shows >= 1 % and the gate passes.
6. Nothing else in the range. Rejects: A5, A6 (except `swiglu_quant` as a footnote), B3, B5, B6, B8, B9, D2-D4.
Gates, per `AGENTS.md`: A1, A2, A4, B2 are lossy-class (rounding / summation order): experimental flags until gate Q (teacher-forced `q_tail_gate.py`, rule <= 1.25 x run-to-run control)
and a live Codex session pass; no performance claim without a paired A/B on the same workload with hardware, software, model digest, cache state and token counts recorded. A3 and the H items are
lossless; identity gate I (byte compare of kernel outputs / replay identity) is enough.
---
## 11. Limits of this review
* No code was built or run. All "Ours" statements come from `grep` over `crates/`, `scripts/`, `docs/` of `main` `e92513b7`, the port plan and the in-repo experiment pages; where I could not tell I wrote U.
* Upstream numbers are claims on other hardware: RTX PRO 5000 (110 SMs, 72 GB, every expert resident), 2 x A4000, RTX 3060 / 5070, R9700, P100, CMP 170HX, GB10. The 5090 streams ~20 % of routed entries from CPU/PCIe, so decode gains measured with all experts resident do not transfer one to one (`docs/upstream-port-plan.md`, sm_120 switches).
* `docs/experiments/decode-gap-5090.md` and `vanilla-decode-5090.md` carry a "superseded / unpaired" banner; I quote them for mechanisms, not for sizes.
* The A1 gain is the weakest estimate: the host-wait part is derived from our CUPTI anatomy, the kernel part is upstream's claim on a different card.
* The DeepSeek, Metal, SYCL, HIP/AMD, Pascal, ARM64 and Python/serve/app commits were scanned by subject only unless named above.
---
## Appendix: coverage of the 145 engine commits
Rows above that carry the SHA: A1 `bdcc34df 10c8cc62 c47c6994 9a398bd5 9e203190`; A2 `ffe40c16 162dec34 fca1936c a6df0023 df7068b6 42094da9 5602253e cc125e06 18c53576 e7318fa2 d02478b7 a732a34c 945a63be 6eff377a c6f6db85 37e4832a`;
A3 `a11f8b0a f217b23b`; A4 `54d9363c`; A5 `f4012d63 011e5bec c5cf218e 5b469ee9 053a4157 750ca8c3 7a34c60d 6c00851a 31712914 e3450e45 25a62e0f 76cd7d79 bda30050 45c9e623`;
A6 `8c2a8469 dc390c38 17b08c96 d6428bf2 884e37df dd97421d 5dbd8774 9067cc64 6a6d58ad a3389901 f213f78b`; A7 `91d4d7ff 14d076ee 3a267530`;
B1 `d18d8ba0 d39e2a75`; B3 `2395c8a5 f1dadd17`; B4 `0049fa73`; B5 `8b95bffb c2d3fe50 269c6d3e 91aebae6 bdecbffc 2299c8f7 663ec80a 25796351`; B6 `b434a8aa`; B7 `7d1016f3 789d8390 11b04902 7c4c2079`;
B8 `c30656aa 0afaaa39 20a63cf0`; B9 `9d3c8c36 b119f40f`; B10 `f4612b1a 499e9635 ca17d0f5 447460e8 4c7bce3a`; B11 `6c01f85a`;
C1 `cfa197e2`; C2 `2a9a67c1`; C3 `07d5ecfa`; C4 `3100ca05`; C5 `a8c1d4b7`; C6 `3478382e f62589fd 8c030148`; C7 `3cd33d50 61ede87e a4c41a92 f262b81b 1a937829 f0f056b9 3a3f35c6`;
D1 `f8ff3420 01e404c1 cea3ed40 c7a0cef1`; D2 `0f7224d1 f73b3c86 ca378670 85e3dde5`; D3 `3b34b6c7 472de9cd bc5f84fd 587a4744 3e2f45e2 8dd297d0 ebe3383a`; D4 `a3bb38ec 17878ac5 ec8e4059 690172c4`;
D5 `4a7e373d 2b13a449 2251053b 41188ec7 8aee4538`; section 7 `a3ab37fc 3fd5a748 d7ad4a27 8d56d417 1d00c018 c77292f0 1d380fad`.
Skipped as not Qwen3.8 / CUDA-Linux-Windows relevant (DeepSeek, Metal, SYCL, HIP/AMD only, version bumps, test registration): `19352923 58e5d785 27a8ed96 a42cc3d7 36f6663c 1e72cdc4 cca3dd2e 4a759f82 75638030 e3d8823e 232fa357 8f7d53cc 85444201 0c5b157f 7a80b3a9 9ea04496 5bc1e246 38b06316 ebe3383a(D3)`.