[GH-ISSUE #879] All-logits-NaN degeneration (one repeated token forever) still fires on 0.1.39b / current main — first poison traced to the MoE output rows: garbage bits, varying layer #385

Closed
opened 2026-11-04 01:42:32 +07:00 by bsakaguchi · 15 comments
Owner

Originally created by @66419118nnn on GitHub (Oct 5, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/879

Follow-up to ROCm/legacy-rocm-build#606 with a working statistical reproducer and a full instrumentation suite. TL;DR: the degeneration survives 0.1.39 (both q8_1 clamps + repeat_stop_tokens); it also survives disabling the unclamped fused-SwiGLU quantizer that rwkeyes identified below. Layer-trace instrumentation on current main (6f32ec0) shows the first non-finite value of a window being produced in the MoE path — of the 13 fires with per-layer traces, the first poisoned signal is the routed-expert rows in 11, the attention block's output of layer 28 in one (with that layer's input, GDN state and PLE all clean), and the layer's combined contribution only (a 2-signal early build) in the last — while the layer input, GDN/QSA state, PLE history, KV, CPU-pool output and the expert-cache slot bytes are clean in every fire. In all 6 fires that recorded raw bits, the GPU-side value is the same non-canonical NaN payload 0x7FFFFFFF; the miss side recorded garbage payloads twice (0x7FD6E000, 0x7FD3E000) and a canonical arithmetic NaN once (0xFFC00000). This is a data-path defect, not an overflow, so the clamp family of fixes cannot close it.

Environment

  • Engine: current main 6f32ec0 (0.1.39b), built locally (CUDA 13.0, sm_120) — and, for the earlier half of the fires, 0.1.35 with an equivalent local patch set. The signature is identical across both (300 commits apart, including the ROCm/legacy-rocm-build#606 fix).
  • GPU: RTX 5090 D 32 GB (compute capability 12.0), memory clock at stock (14 001 MHz) since 2026-10-03 — every fire in the 21-fire set postdates that; ECC is not available on this board.
  • CPU: Ryzen 9 9950X3D, 64 GB RAM; 15 expert-pool workers.
  • Model: Qwen3.8-Flash-Next, Unsloth UD-Q4_K_XL (GGUF-in-place, native pack), --expert-cache auto (6 493–6 714 of 24 576 experts resident in VRAM across boots, ≈ 26–27%), --resident-budget-gib 53 (clamped to 50.5–51.6 GiB page-locked complement, whatever the boot leaves free), --spec 3, suffix drafts on, --pcie-frac 0.55, --kv int8, --prefill auto:32768, ctx 224 000.
  • Tier-independence: the same fires were produced on UD-IQ4_XS (4 fires) and, per the Q8 report in ROCm/legacy-rocm-build#606's thread, on someone else's Q8 — this is not a quantization-tier artifact.

Reproducer (statistical: 1 fire per 1–18 replays; every completed 30+-try round has fired at least once)

A real agentic request whose window failed (85 688-token prompt, 47 messages, 26 tools, reasoning_effort xhigh), captured verbatim at guard failure by a serve-layer hook in our local patch, then replayed with fresh seeds:

STRATA_API_KEY=… python3 replay-degen.py 20261004-211527-request.json \
    --tries 40 --max-tokens 3000 --model <tier> --strip-images

(replay-degen.py is in the gist; the capture contains my private conversation, so I will share it directly on request rather than attaching it. It reproduces on this 5090 D with a partial-residency tier; not yet verified on other cards.)

Every observed ignition in long-context traffic lands at positions 77 261–88 443 — in every fire whose prompt length is known, within ~3 000 decoded positions after prefill — plus one short-context fire at position 311, three minutes after a cold start. On four 0.1.39b rounds today the fires landed at try 6, 18, 1 and 9 of 40; earlier 0.1.35 rounds hit ~1 fire in 15–20 tries. Deterministic per-seed reproduction does not survive an engine restart — the trigger needs process-level state (cache residency/swap history), which is why rounds must be Monte-Carlo.

What the instrumentation is (all of it is in local-patches-20261005-0139b.diff, ~440 lines on top of 6f32ec0)

  1. A logits finiteness guard (logits_nonfinite in sampler.cu, enqueued into the captured verify-window graph, flag read after the sync the window already performs — measured zero cost): a window whose logits are non-finite fails instead of being sampled, so the symptom becomes a clean request error instead of 9 613 consecutive !.
  2. Seven per-layer poison flags baked into the window graph (lay_flags_ in verify.cpp): layer input (folded residual), attention block, shared expert, routed total (post-fold), combined output, GPU cache-hit rows (hit_out_), CPU miss rows (parts_ pre-fold).
  3. First-non-finite recorders (row, col, raw bits) for the miss side and the hit side.
  4. A planned-row audit (audit_hit_rows): scans only the rows in this layer's GPU plan (p_dst[0, counts[1])), so a stale row the engine never reads cannot masquerade as poison.
  5. A kernel-stage audit (STRATA_KERNEL_AUDIT=1, in native_expert_grouped): scans the gu (gate/up) outputs, the SwiGLU output, and the down-projection output.
  6. (0.1.35 build additionally: slot-vs-file memcmp of the poisoned expert's cache bytes, and a host-side scan of the CPU pool's rows at publish time.)

Evidence

Fire A (0.1.39b + guard only, try 6): position 88 443 — fires with the owner's full 0.1.39 fix in place.
Fire B (0.1.39b + STRATA_FUSED_SWIGLU_Q81=0, try 18): position 87 353 — the third unclamped quantizer is not the cause either.
Fire C (0.1.39b + layer trace, try 1): position 87 611 — (log lines verbatim; the ← annotations are mine) —

layer trace: first poisoned input/attn/shared at layer 14 (GDN)        ← downstream
layer trace: first poisoned routed total / combined / GPU cache-hit at layer 13 (GDN)   ← FIRST
layer trace: first poisoned CPU miss rows at layer -1                  ← clean the whole window
first non-finite HIT value: row 26 (token 2, expert slot 6), col 2092, bits 0x7fffffff
mapped miss rows: 0 of 76800 non-finite

Fire D (0.1.39b + everything, try 9): position 85 965 —

layer trace: first poisoned routed total / combined / CPU miss rows at layer 37 (GDN)   ← miss side FIRST
layer trace: first poisoned GPU cache-hit / input / attn / shared at layer 38 (GDN)     ← downstream
first non-finite MISS value: row 17 (token 1, slot 7), col 2144, bits 0xffc00000   ← canonical -qNaN
first non-finite HIT value:  row 15 (token 1, slot 5), col 736,  bits 0x7fffffff   ← garbage payload
kernel-stage audit: first non-finite in gate (gu kernel) of layer 47, flat 6848, bits 0x7fffffff
planned-GPU-row audit: layer 38, row 15 (token 1, slot 5), col 2176, bits 0x7fffffff, expert 5   ← in the plan

From the 0.1.35 instrumentation (13 fires with dumps, same shapes):

  • The poisoned GPU row is inside the plan's dst table (the engine consumes it) in both fires where the planned-row audit ran — the stale-row objection is ruled out.
  • The poisoned expert's cache slot is byte-identical to the pack file (slot 4 203, layer 21, expert 1) — the blob arrived fine; the poison is made after it lands.
  • The CPU pool's rows at publish time are clean in every hit-side fire.
  • GDN state (36 layers), PLE history (92 160 values), layer inputs up to the first poisoned layer: all finite.

Across 21 fires (0.1.35 + 0.1.39b): the first poisoned layer varies — {3, 13, 15, 16, 18, 20, 22, 26, 28, 37} — with GDN and QSA layers both appearing, and both sides of the hit/miss split having fired first (the routed-expert rows are the first poisoned signal in 11 of the 13 fires with layer traces; one, position 85 683, has the attention block's output of layer 28 first, with that layer's input, the GDN state and PLE all clean — so the defect is not exclusive to the expert GEMMs). What is invariant: the GPU-side first non-finite value is the same garbage payload 0x7FFFFFFF in all 6 fires that recorded bits, and everything else — weights, cache slots, pool output, persistent state — is clean at the moment of the failure dump.

What is ruled out, and what is left

  • It is not the q8_1/q8_0/KV fp16 overflow family: our build had those clamped before 0.1.39 existed, fires continued; 0.1.39b (official clamps) fires; the fused-SwiGLU site disabled still fires.
  • It is not precision-tier, cache-slot corruption, stale-row instrumentation, GDN/PLE/KV state, the AVX-512/AVX-2 multi-token CPU kernels (forcing the ggml single-token dot path fires on try 1), or sampling.
  • The first non-finite value appears in the routed-expert pipeline's output rows in 11 of the 13 traced fires — and in the attention block's output of layer 28 in the other fully-instrumented one — at a varying layer, with raw garbage bits on the GPU-computed side — i.e. bytes that are not the result of any float arithmetic in that path. Where exactly the garbage bytes enter (the gu/down GEMM's output write coverage vs. the plan's entries, scratch-buffer reuse across graph replays, the ent_dst-indexed write, or — for the miss-side fires — the host-publish → mapped-memory read-back of the pool's rows) is what the instrumentation localizes to; I have not been able to close that last inch from outside the kernels.

Suggested places to look (in native_expert_grouped and the window graph)

  1. Output-row coverage vs. plan entries in launch_gu / launch_down: the GEMMs write gate/up/out rows for the plan's entries; if any launch's row range or ent_dst base assumes counts[1] == cap (or strides by cap while the plan is shorter), it writes or reads rows the plan does not own — which is exactly where a stale-scratch 0x7FFFFFFF can be laundered into a consumed row.
  2. hit_scratch_ / nat_xq_ reuse across CUDA-graph replays with varying window T (spec 3 + suffix drafts means T cycles 1–5 and the graphs are instantiated per T): the stage audit caught garbage in the gu output of a late layer, i.e. bytes surviving in scratch from earlier in the window or from a previous window.
  3. The miss-side path (expert_pool_dispatch_multi → host publish → copy_rows_from_mapped): the host's rows are finite at publish and at failure time, yet the pre-fold miss row held 0xFFC00000 — worth checking the flag-ring (m_flag_/wait_flag_ge) sequencing under graph replay for the group-skip (skip_ + grp) cases, and the pool's memset of GPU-kind rows (expert_source.cpp, the kind[i] >= 0 branch).
  4. The 0x7FFFFFFF payload specifically: four 0xFF bytes. In a q8_1 block that is the pattern of ds = {inf-ish, inf-ish} written as raw bytes, or a half2 sentinel — a hexdump of the 16 bytes around the recorded (row, col) in gate/hit_out would tell which.

Mitigation we run in production (offered as-is)

The verify-window finiteness guard from the attached diff: a non-finite window fails cleanly (one bad request instead of minutes of ! spam), the engine exits, and the failure dump lands in the engine log with position/row/bits. Together with repeat_stop_tokens it bounds the damage; it does not, of course, cure the root cause.

Everything referenced above is in this gist: https://gist.github.com/66419118nnn/7c9399d982d98229c61fcefaaa0b9215 — the full experiment report (Chinese), fires.json with all 21 fires and their verbatim dumps, replay-degen.py, both patch sets (0.1.35 and 6f32ec0), and the four round logs.

Originally created by @66419118nnn on GitHub (Oct 5, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/879 Follow-up to ROCm/legacy-rocm-build#606 with a working statistical reproducer and a full instrumentation suite. **TL;DR: the degeneration survives 0.1.39 (both q8_1 clamps + `repeat_stop_tokens`); it also survives disabling the unclamped fused-SwiGLU quantizer that rwkeyes identified below. Layer-trace instrumentation on current main (`6f32ec0`) shows the first non-finite value of a window being produced in the MoE path — of the 13 fires with per-layer traces, the first poisoned signal is the routed-expert rows in 11, the attention block's output of layer 28 in one (with that layer's input, GDN state and PLE all clean), and the layer's combined contribution only (a 2-signal early build) in the last — while the layer input, GDN/QSA state, PLE history, KV, CPU-pool output and the expert-cache slot bytes are clean in every fire. In all 6 fires that recorded raw bits, the GPU-side value is the same non-canonical NaN payload 0x7FFFFFFF; the miss side recorded garbage payloads twice (0x7FD6E000, 0x7FD3E000) and a canonical arithmetic NaN once (0xFFC00000).** This is a data-path defect, not an overflow, so the clamp family of fixes cannot close it. ## Environment - Engine: current `main` `6f32ec0` (0.1.39b), built locally (CUDA 13.0, sm_120) — and, for the earlier half of the fires, 0.1.35 with an equivalent local patch set. The signature is identical across both (300 commits apart, including the ROCm/legacy-rocm-build#606 fix). - GPU: RTX 5090 D 32 GB (compute capability 12.0), memory clock at stock (14 001 MHz) since 2026-10-03 — every fire in the 21-fire set postdates that; ECC is not available on this board. - CPU: Ryzen 9 9950X3D, 64 GB RAM; 15 expert-pool workers. - Model: Qwen3.8-Flash-Next, Unsloth UD-Q4_K_XL (GGUF-in-place, native pack), `--expert-cache auto` (6 493–6 714 of 24 576 experts resident in VRAM across boots, ≈ 26–27%), `--resident-budget-gib 53` (clamped to 50.5–51.6 GiB page-locked complement, whatever the boot leaves free), `--spec 3`, suffix drafts on, `--pcie-frac 0.55`, `--kv int8`, `--prefill auto:32768`, ctx 224 000. - Tier-independence: the same fires were produced on UD-IQ4_XS (4 fires) and, per the Q8 report in ROCm/legacy-rocm-build#606's thread, on someone else's Q8 — this is not a quantization-tier artifact. ## Reproducer (statistical: 1 fire per 1–18 replays; every completed 30+-try round has fired at least once) A real agentic request whose window failed (85 688-token prompt, 47 messages, 26 tools, `reasoning_effort xhigh`), captured verbatim at guard failure by a serve-layer hook in our local patch, then replayed with fresh seeds: ``` STRATA_API_KEY=… python3 replay-degen.py 20261004-211527-request.json \ --tries 40 --max-tokens 3000 --model <tier> --strip-images ``` (`replay-degen.py` is in the gist; the capture contains my private conversation, so I will share it directly on request rather than attaching it. It reproduces on this 5090 D with a partial-residency tier; not yet verified on other cards.) Every observed ignition in long-context traffic lands at positions 77 261–88 443 — in every fire whose prompt length is known, within ~3 000 decoded positions after prefill — plus one short-context fire at position 311, three minutes after a cold start. On four 0.1.39b rounds today the fires landed at try 6, 18, 1 and 9 of 40; earlier 0.1.35 rounds hit ~1 fire in 15–20 tries. Deterministic per-seed reproduction does **not** survive an engine restart — the trigger needs process-level state (cache residency/swap history), which is why rounds must be Monte-Carlo. ## What the instrumentation is (all of it is in `local-patches-20261005-0139b.diff`, ~440 lines on top of `6f32ec0`) 1. **A logits finiteness guard** (`logits_nonfinite` in `sampler.cu`, enqueued into the captured verify-window graph, flag read after the sync the window already performs — measured zero cost): a window whose logits are non-finite fails instead of being sampled, so the symptom becomes a clean request error instead of 9 613 consecutive `!`. 2. **Seven per-layer poison flags baked into the window graph** (`lay_flags_` in `verify.cpp`): layer input (folded residual), attention block, shared expert, routed total (post-fold), combined output, GPU cache-hit rows (`hit_out_`), CPU miss rows (`parts_` pre-fold). 3. **First-non-finite recorders** (row, col, raw bits) for the miss side and the hit side. 4. **A planned-row audit** (`audit_hit_rows`): scans only the rows in this layer's GPU plan (`p_dst[0, counts[1])`), so a stale row the engine never reads cannot masquerade as poison. 5. **A kernel-stage audit** (`STRATA_KERNEL_AUDIT=1`, in `native_expert_grouped`): scans the gu (gate/up) outputs, the SwiGLU output, and the down-projection output. 6. (0.1.35 build additionally: slot-vs-file memcmp of the poisoned expert's cache bytes, and a host-side scan of the CPU pool's rows at publish time.) ## Evidence **Fire A (0.1.39b + guard only, try 6):** position 88 443 — fires with the owner's full 0.1.39 fix in place. **Fire B (0.1.39b + `STRATA_FUSED_SWIGLU_Q81=0`, try 18):** position 87 353 — the third unclamped quantizer is not the cause either. **Fire C (0.1.39b + layer trace, try 1):** position 87 611 — *(log lines verbatim; the ← annotations are mine)* — ``` layer trace: first poisoned input/attn/shared at layer 14 (GDN) ← downstream layer trace: first poisoned routed total / combined / GPU cache-hit at layer 13 (GDN) ← FIRST layer trace: first poisoned CPU miss rows at layer -1 ← clean the whole window first non-finite HIT value: row 26 (token 2, expert slot 6), col 2092, bits 0x7fffffff mapped miss rows: 0 of 76800 non-finite ``` **Fire D (0.1.39b + everything, try 9):** position 85 965 — ``` layer trace: first poisoned routed total / combined / CPU miss rows at layer 37 (GDN) ← miss side FIRST layer trace: first poisoned GPU cache-hit / input / attn / shared at layer 38 (GDN) ← downstream first non-finite MISS value: row 17 (token 1, slot 7), col 2144, bits 0xffc00000 ← canonical -qNaN first non-finite HIT value: row 15 (token 1, slot 5), col 736, bits 0x7fffffff ← garbage payload kernel-stage audit: first non-finite in gate (gu kernel) of layer 47, flat 6848, bits 0x7fffffff planned-GPU-row audit: layer 38, row 15 (token 1, slot 5), col 2176, bits 0x7fffffff, expert 5 ← in the plan ``` **From the 0.1.35 instrumentation (13 fires with dumps, same shapes):** - The poisoned GPU row is **inside the plan's dst table** (the engine consumes it) in both fires where the planned-row audit ran — the stale-row objection is ruled out. - The poisoned expert's cache slot is **byte-identical to the pack file** (slot 4 203, layer 21, expert 1) — the blob arrived fine; the poison is made after it lands. - The CPU pool's rows at publish time are clean in every hit-side fire. - GDN state (36 layers), PLE history (92 160 values), layer inputs up to the first poisoned layer: all finite. **Across 21 fires (0.1.35 + 0.1.39b):** the first poisoned layer varies — {3, 13, 15, 16, 18, 20, 22, 26, 28, 37} — with GDN and QSA layers both appearing, and both sides of the hit/miss split having fired first (the routed-expert rows are the first poisoned signal in 11 of the 13 fires with layer traces; one, position 85 683, has the attention block's output of layer 28 first, with that layer's input, the GDN state and PLE all clean — so the defect is not exclusive to the expert GEMMs). What is invariant: the GPU-side first non-finite value is the same garbage payload 0x7FFFFFFF in all 6 fires that recorded bits, and everything else — weights, cache slots, pool output, persistent state — is clean at the moment of the failure dump. ## What is ruled out, and what is left - It is **not** the q8_1/q8_0/KV fp16 overflow family: our build had those clamped before 0.1.39 existed, fires continued; 0.1.39b (official clamps) fires; the fused-SwiGLU site disabled still fires. - It is **not** precision-tier, cache-slot corruption, stale-row instrumentation, GDN/PLE/KV state, the AVX-512/AVX-2 multi-token CPU kernels (forcing the ggml single-token dot path fires on try 1), or sampling. - The first non-finite value appears **in the routed-expert pipeline's output rows in 11 of the 13 traced fires — and in the attention block's output of layer 28 in the other fully-instrumented one — at a varying layer, with raw garbage bits on the GPU-computed side** — i.e. bytes that are not the result of any float arithmetic in that path. Where exactly the garbage bytes enter (the gu/down GEMM's output write coverage vs. the plan's entries, scratch-buffer reuse across graph replays, the `ent_dst`-indexed write, or — for the miss-side fires — the host-publish → mapped-memory read-back of the pool's rows) is what the instrumentation localizes to; I have not been able to close that last inch from outside the kernels. ## Suggested places to look (in `native_expert_grouped` and the window graph) 1. **Output-row coverage vs. plan entries in `launch_gu` / `launch_down`**: the GEMMs write `gate`/`up`/`out` rows for the plan's entries; if any launch's row range or `ent_dst` base assumes `counts[1] == cap` (or strides by `cap` while the plan is shorter), it writes or reads rows the plan does not own — which is exactly where a stale-scratch 0x7FFFFFFF can be laundered into a consumed row. 2. **`hit_scratch_` / `nat_xq_` reuse across CUDA-graph replays** with varying window T (spec 3 + suffix drafts means T cycles 1–5 and the graphs are instantiated per T): the stage audit caught garbage in the gu output of a *late* layer, i.e. bytes surviving in scratch from earlier in the window or from a previous window. 3. **The miss-side path** (`expert_pool_dispatch_multi` → host publish → `copy_rows_from_mapped`): the host's rows are finite at publish and at failure time, yet the pre-fold miss row held 0xFFC00000 — worth checking the flag-ring (`m_flag_`/`wait_flag_ge`) sequencing under graph replay for the group-skip (`skip_ + grp`) cases, and the pool's memset of GPU-kind rows (`expert_source.cpp`, the `kind[i] >= 0` branch). 4. The `0x7FFFFFFF` payload specifically: four 0xFF bytes. In a q8_1 block that is the pattern of `ds = {inf-ish, inf-ish}` written as raw bytes, or a half2 sentinel — a hexdump of the 16 bytes around the recorded (row, col) in `gate`/`hit_out` would tell which. ## Mitigation we run in production (offered as-is) The verify-window finiteness guard from the attached diff: a non-finite window fails cleanly (one bad request instead of minutes of `!` spam), the engine exits, and the failure dump lands in the engine log with position/row/bits. Together with `repeat_stop_tokens` it bounds the damage; it does not, of course, cure the root cause. Everything referenced above is in this gist: **https://gist.github.com/66419118nnn/7c9399d982d98229c61fcefaaa0b9215** — the full experiment report (Chinese), `fires.json` with all 21 fires and their verbatim dumps, `replay-degen.py`, both patch sets (0.1.35 and `6f32ec0`), and the four round logs.
Author
Owner

@66419118nnn commented on GitHub (Oct 5, 2026):

Addendum: deterministic reproduction, race hypothesis, and corrected residency model

1. Deterministic repro (~100% within a few rounds, any client)

  1. Send a long-running task.
  2. While decoding, hit Stop.
  3. The engine does not stop — it keeps generating through the "stopped" window.
  4. Edit the message, re-send.
  5. The interrupt is only applied at this moment (when the new request arrives); output then starts.
  6. Repeat stop → edit → resend a few times.

Output degenerates into single-character ! spam within a few rounds. Verified on oh-my-pi, Qoder, and zCode — all behave identically, so this is client-independent.

2. Hypothesis: deferred-abort teardown/setup race

Abort is deferred until the next request arrives, so request N's teardown (slot / KV block / scratch release) runs concurrently with request N+1's setup reusing the same buffers. This window is the likely injection point.

This also suggests where 0x7FFFFFFF comes from: it is INT32_MAX, the standard sentinel / invalid-ID value in engine code. An int32 sentinel landing in memory later read as fp32 decodes exactly as NaN (all-ones exponent, non-zero mantissa) → NaN in the MoE output row → collapsed distribution → garbage token.

3. Corrected residency model

  • Poison is session-scoped, not engine-global: a new session recovers output without reloading the engine.
  • Reloading also recovers, but is not required.
  • Within the affected session it is irreversible — the ! tail is in KV, keeps being attended to, and in-context degeneration self-sustains.

Lifecycle: race seeds the poison into the new session's KV at birth → in-context degeneration perpetuates it. This matches the ROCm/legacy-rocm-build#728 observation that presence_penalty 1.5 "helps for a while, still recurs less often": the penalty weakens the attractor (perpetuation) but doesn't remove the seed.

4. One-line discrimination experiment

In a poisoned session, truncate context back to before the loop and regenerate. Recovers → KV-tail self-sustainment (fix: detect + KV rollback). Still spamming → a session-private buffer re-poisons every step (fix: session buffer lifecycle).

5. Why agent users are hit hardest

Agents constantly abort + edit + resend (retries, cancelled tool loops). Incidence is plausibly a function of abort-resend cycles, not uptime — consistent with ROCm/legacy-rocm-build#606's 36k-token trigger and ROCm/legacy-rocm-build#728's "after a while".

6. Suggested audit targets

  1. Where the deferred abort is processed (teardown of N at arrival of N+1).
  2. Fence between in-flight writes of the aborted request and buffer reuse by the new request.
  3. Generation/epoch counter on KV blocks so stale writes are discarded; canary-check blocks at session start.

Side note: "abort only takes effect when the next request arrives" is a user-visible abort-latency bug on its own — possibly worth a separate issue.

7. Guard improvement

The 256-repeated-token guard misses whole-sentence loops (1,110× sentence loop in ROCm/legacy-rocm-build#728, traced to ROCm/legacy-rocm-build#819 — separate chain). If the KV-tail hypothesis confirms, the right response on detection is auto truncate-KV-tail + regenerate, turning the guard from session-fatal into self-healing.

<!-- gh-comment-id:5987811970 --> @66419118nnn commented on GitHub (Oct 5, 2026): ## Addendum: deterministic reproduction, race hypothesis, and corrected residency model ### 1. Deterministic repro (~100% within a few rounds, any client) 1. Send a long-running task. 2. While decoding, hit **Stop**. 3. The engine does **not** stop — it keeps generating through the "stopped" window. 4. Edit the message, re-send. 5. The interrupt is only applied at this moment (when the new request arrives); output then starts. 6. Repeat stop → edit → resend a few times. Output degenerates into single-character `!` spam within a few rounds. Verified on **oh-my-pi, Qoder, and zCode** — all behave identically, so this is client-independent. ### 2. Hypothesis: deferred-abort teardown/setup race Abort is deferred until the next request arrives, so request N's teardown (slot / KV block / scratch release) runs concurrently with request N+1's setup reusing the same buffers. This window is the likely injection point. This also suggests where `0x7FFFFFFF` comes from: it is `INT32_MAX`, the standard sentinel / invalid-ID value in engine code. An int32 sentinel landing in memory later read as fp32 decodes exactly as **NaN** (all-ones exponent, non-zero mantissa) → NaN in the MoE output row → collapsed distribution → garbage token. ### 3. Corrected residency model - Poison is **session-scoped, not engine-global**: a **new session** recovers output without reloading the engine. - Reloading also recovers, but is not required. - Within the affected session it is irreversible — the `!` tail is in KV, keeps being attended to, and in-context degeneration self-sustains. Lifecycle: **race seeds the poison into the new session's KV at birth → in-context degeneration perpetuates it**. This matches the ROCm/legacy-rocm-build#728 observation that presence_penalty 1.5 "helps for a while, still recurs less often": the penalty weakens the attractor (perpetuation) but doesn't remove the seed. ### 4. One-line discrimination experiment In a poisoned session, truncate context back to before the loop and regenerate. Recovers → KV-tail self-sustainment (fix: detect + KV rollback). Still spamming → a session-private buffer re-poisons every step (fix: session buffer lifecycle). ### 5. Why agent users are hit hardest Agents constantly abort + edit + resend (retries, cancelled tool loops). Incidence is plausibly a function of abort-resend cycles, not uptime — consistent with ROCm/legacy-rocm-build#606's 36k-token trigger and ROCm/legacy-rocm-build#728's "after a while". ### 6. Suggested audit targets 1. Where the deferred abort is processed (teardown of N at arrival of N+1). 2. Fence between in-flight writes of the aborted request and buffer reuse by the new request. 3. Generation/epoch counter on KV blocks so stale writes are discarded; canary-check blocks at session start. Side note: "abort only takes effect when the next request arrives" is a user-visible abort-latency bug on its own — possibly worth a separate issue. ### 7. Guard improvement The 256-repeated-token guard misses whole-sentence loops (1,110× sentence loop in ROCm/legacy-rocm-build#728, traced to ROCm/legacy-rocm-build#819 — separate chain). If the KV-tail hypothesis confirms, the right response on detection is **auto truncate-KV-tail + regenerate**, turning the guard from session-fatal into self-healing.
Author
Owner

@cjdell commented on GitHub (Oct 5, 2026):

Following this issue with an independent data point — a second card/toolchain/quantization tier, so the defect reproduces on HIP/RDNA4, not just CUDA/sm_120.

Box: Radeon R9700 32 GB (gfx1201, HIP), Ryzen 5700G, 93 GB RAM, Strata 0.1.39 built from 6f32ec0 (the same revision you used). Model: Qwen3.8-Flash-Next IQ3_XXS (ISTA-DASLab GSQ-RCO, native pack). Engine args: --spec 4 --spec-min-p 0.5 --kv int8 --kv-resident 32768 --max-context 262144 --expert-cache auto --prefill auto (only the R9700 is visible; HIP_VISIBLE_DEVICES=0). Our build carries all four fp16 clamps (native_swiglu_quantize_q8_1_kernel from 437a753, the iq_kernels.cu fused gate/up store, and the kv_q8.cu + prefill/kernels.cu int8-KV scales — verified present in the running derivation), so this fire is with the full clamp set in place, matching your finding that the clamp family is insufficient.

The fire: a ~3h45m Pi agentic session, one ignition near its end. Prompt only 100,134 tokens (not 130K+): the reply came back as a thinking block of !×255, finish_reason: "length", output 256 tokens, cacheRead 99,889. Engine log, same second: the reply repeated one token ('!') 256 times in a row: ended as "length" (repeat_stop_tokens ...) followed by the reply reached max tokens while still thinking, so it has no answer. Two extra observations that may help localise it: (1) this is the first fire we've seen in the reasoning channel rather than the answer text; (2) the clamps did close the long-context site — on the same restart a previously-failing ~132K (索) prompt completed (reading the prompt: …132,947 tokens → done: 2560 tokens (stop)), and the engine went on to serve 141K–149K prompts fine immediately afterwards, so the post-fire engine was not in a global ROCm/legacy-rocm-build#606 state. The ignition is intermittent and process-state-dependent, exactly as your reproducer reports. We don't have raw-bit instrumentation on this build yet; if it's useful I can port your guard (or the record_first_nonfinite/STRATA_KERNEL_AUDIT bits) to HIP and report the payload — happy to know which of the two you'd prefer as a confirmation.

My workarounds:
https://github.com/cjdell/nixos-config/blob/main/hosts/zen3-nixos/ai/strata-package.nix

<!-- gh-comment-id:5992985422 --> @cjdell commented on GitHub (Oct 5, 2026): Following this issue with an independent data point — a second card/toolchain/quantization tier, so the defect reproduces on HIP/RDNA4, not just CUDA/sm_120. Box: Radeon R9700 32 GB (gfx1201, HIP), Ryzen 5700G, 93 GB RAM, Strata 0.1.39 built from `6f32ec0` (the same revision you used). Model: Qwen3.8-Flash-Next IQ3_XXS (ISTA-DASLab GSQ-RCO, native pack). Engine args: `--spec 4 --spec-min-p 0.5 --kv int8 --kv-resident 32768 --max-context 262144 --expert-cache auto --prefill auto` (only the R9700 is visible; `HIP_VISIBLE_DEVICES=0`). Our build carries all four fp16 clamps (`native_swiglu_quantize_q8_1_kernel` from `437a753`, the `iq_kernels.cu` fused gate/up store, and the `kv_q8.cu` + `prefill/kernels.cu` int8-KV scales — verified present in the running derivation), so this fire is **with the full clamp set in place**, matching your finding that the clamp family is insufficient. The fire: a ~3h45m Pi agentic session, one ignition near its end. Prompt only **100,134 tokens** (not 130K+): the reply came back as a **thinking** block of `!`×255, `finish_reason: "length"`, output 256 tokens, cacheRead 99,889. Engine log, same second: `the reply repeated one token ('!') 256 times in a row: ended as "length" (repeat_stop_tokens ...)` followed by `the reply reached max tokens while still thinking, so it has no answer`. Two extra observations that may help localise it: (1) this is the **first fire we've seen in the reasoning channel** rather than the answer text; (2) the clamps *did* close the long-context site — on the same restart a previously-failing ~132K (`索`) prompt completed (`reading the prompt: …132,947 tokens` → `done: 2560 tokens (stop)`), and the engine went on to serve 141K–149K prompts fine immediately afterwards, so the post-fire engine was not in a global ROCm/legacy-rocm-build#606 state. The ignition is intermittent and process-state-dependent, exactly as your reproducer reports. We don't have raw-bit instrumentation on this build yet; if it's useful I can port your guard (or the `record_first_nonfinite`/`STRATA_KERNEL_AUDIT` bits) to HIP and report the payload — happy to know which of the two you'd prefer as a confirmation. My workarounds: https://github.com/cjdell/nixos-config/blob/main/hosts/zen3-nixos/ai/strata-package.nix
Author
Owner

@Niko1221 commented on GitHub (Oct 6, 2026):

Thank you for the traces. 0.1.40 changes three things that touch this. The residency-table uploads wait for their own copy before the verifier reads the table (PR ROCm/legacy-rocm-build#550). A window no longer runs the 100%-resident graph while any expert is out of VRAM (#871). And a Stop sent during the prompt read now reaches the engine at once. We ran stop, edit, resend 8 times on 0.1.39 and 8 on 0.1.40 (Q2_0, partial residency, RTX 5070, STRATA_DBG_NAN=1) and saw no degeneration and no non-finite values, so we could not reproduce it. Please retry on 0.1.40. If it still fires, send the log with STRATA_DBG_NAN=1 and try --adapt-every 100000 and no --resident-budget-gib.

<!-- gh-comment-id:6010876517 --> @Niko1221 commented on GitHub (Oct 6, 2026): Thank you for the traces. 0.1.40 changes three things that touch this. The residency-table uploads wait for their own copy before the verifier reads the table (PR ROCm/legacy-rocm-build#550). A window no longer runs the 100%-resident graph while any expert is out of VRAM (#871). And a Stop sent during the prompt read now reaches the engine at once. We ran stop, edit, resend 8 times on 0.1.39 and 8 on 0.1.40 (Q2_0, partial residency, RTX 5070, STRATA_DBG_NAN=1) and saw no degeneration and no non-finite values, so we could not reproduce it. Please retry on 0.1.40. If it still fires, send the log with STRATA_DBG_NAN=1 and try --adapt-every 100000 and no --resident-budget-gib.
Author
Owner

@Kelsidavis commented on GitHub (Oct 7, 2026):

Additional reproduction on Linux with Strata 0.1.40 (locally built CUDA 12 engine, sm_70 + sm_86; Tesla V100 and RTX 3060). Checkout HEAD is 82f46a8c8f475f001ad76d92f58f4a4f8ffb0253; its latest engine-source commit is 1cbcacbcae2953f3be9edc46369f0c875bc6ab8b. The binary’s BUILD.json source fingerprint is 6f298dff754d187f, and it matches the current engine-source fingerprint. V100 ECC was disabled (no retired ECC pages reported). Relevant engine options: --max-context 131072 --kv int8 --kv-resident 32768 --spec 4 --spec-min-p 0.5 --mtp [model] --expert-cache auto.

After a fresh server/engine start, requests worked normally for about 21 minutes. The first observed degenerate response was at 18:49:39 PDT: a 35,278-token prompt, 16,384-token output limit, and 478 generated tokens before the server detected 256 consecutive ! tokens in reasoning and ended with finish_reason=length. Subsequent requests also produced !: a 21,818-token prompt with a 6,000-token limit stopped after 282 generated tokens, and an 18,943-token prompt stopped after 348. The 21,818-token request had thinking disabled and repeated ! in answer text, so it was not confined to reasoning.

I then tried an independent synthetic 57-token health check, with max_tokens=64, temperature=1.0, top_p=0.95, top_k=20. It returned 64 ! tokens in reasoning_content, finish_reason=length, and no answer. This was a fresh prompt and the engine remained reported as loaded; changing sampling did not clear the state. Its last reported expert-cache hit rate was 95.6%, with all 30 draft tokens accepted.

POST /unload followed by POST /load (same Python server process) cleared the problem. The identical health check then returned a normal answer, finish_reason=stop, 27 generated tokens, with 18 of 21 drafts accepted. This appears consistent with the follow-up investigation in #879. I do not have a minimal trigger, but this confirms the stuck output can recur on 0.1.40 and persists across unrelated requests until the engine is reloaded.

<!-- gh-comment-id:6029427815 --> @Kelsidavis commented on GitHub (Oct 7, 2026): Additional reproduction on Linux with Strata 0.1.40 (locally built CUDA 12 engine, sm\_70 + sm\_86; Tesla V100 and RTX 3060). Checkout HEAD is `82f46a8c8f475f001ad76d92f58f4a4f8ffb0253`; its latest engine-source commit is `1cbcacbcae2953f3be9edc46369f0c875bc6ab8b`. The binary’s `BUILD.json` source fingerprint is `6f298dff754d187f`, and it matches the current engine-source fingerprint. V100 ECC was disabled (no retired ECC pages reported). Relevant engine options: `--max-context 131072 --kv int8 --kv-resident 32768 --spec 4 --spec-min-p 0.5 --mtp [model] --expert-cache auto`. After a fresh server/engine start, requests worked normally for about 21 minutes. The first observed degenerate response was at 18:49:39 PDT: a 35,278-token prompt, 16,384-token output limit, and 478 generated tokens before the server detected 256 consecutive `!` tokens in reasoning and ended with `finish_reason=length`. Subsequent requests also produced `!`: a 21,818-token prompt with a 6,000-token limit stopped after 282 generated tokens, and an 18,943-token prompt stopped after 348. The 21,818-token request had thinking disabled and repeated `!` in answer text, so it was not confined to reasoning. I then tried an independent synthetic 57-token health check, with `max_tokens=64`, `temperature=1.0`, `top_p=0.95`, `top_k=20`. It returned 64 `!` tokens in `reasoning_content`, `finish_reason=length`, and no answer. This was a fresh prompt and the engine remained reported as loaded; changing sampling did not clear the state. Its last reported expert-cache hit rate was 95.6%, with all 30 draft tokens accepted. `POST /unload` followed by `POST /load` (same Python server process) cleared the problem. The identical health check then returned a normal answer, `finish_reason=stop`, 27 generated tokens, with 18 of 21 drafts accepted. This appears consistent with the follow-up investigation in \#879. I do not have a minimal trigger, but this confirms the stuck output can recur on 0.1.40 and persists across unrelated requests until the engine is reloaded.
Author
Owner

@Niko1221 commented on GitHub (Oct 7, 2026):

0.1.40.2 adds tools/stop_resend_test.py: it streams an answer, stops reading, and resends or edits the prompt after 0 to 0.4 s (or with another request already running), and fails on an empty answer or a repeated token. Please run it against your server with the engine started with STRATA_DBG_NAN=1 and tell us what the log names.

<!-- gh-comment-id:6037844139 --> @Niko1221 commented on GitHub (Oct 7, 2026): 0.1.40.2 adds tools/stop_resend_test.py: it streams an answer, stops reading, and resends or edits the prompt after 0 to 0.4 s (or with another request already running), and fails on an empty answer or a repeated token. Please run it against your server with the engine started with STRATA_DBG_NAN=1 and tell us what the log names.
Author
Owner

@VeenLee commented on GitHub (Oct 9, 2026):

My machine has encountered the same peoblem:
the reply repeated one token ('!') 256 times in a row: ended as "length".
Enter COMS setting and disable XMP solved my problem, RAM frequency has dropped from 6400MHz to 4800MHz.

<!-- gh-comment-id:6073070417 --> @VeenLee commented on GitHub (Oct 9, 2026): My machine has encountered the same peoblem: the reply repeated one token ('!') 256 times in a row: ended as "length". Enter COMS setting and disable XMP solved my problem, RAM frequency has dropped from 6400MHz to 4800MHz.
Author
Owner

@MKheru commented on GitHub (Oct 10, 2026):

HIP / RDNA4 (R9700): the poison is born in the batched prompt path for chunks of ~193–256 tokens — --short-read 260 avoids it (0 / 770 vs 27 / 1,471 in that window)

A night of targeted runs on 0.1.40.2. Short version: every all-! fire we could produce (28 of them) came from a prompt read of 198–258 new tokens on top of a cached conversation, i.e. a batched prompt chunk of about 193–253 tokens. There were none in 4,419 requests whose read fell outside that window. STRATA_DBG_NAN=1 puts the first non-finite values in a layer's MoE output during that chunk. Raising --short-read to 260, so those reads go through the verify windows instead, gave 0 fires in 770 requests (312 of them inside the window) at no measurable speed cost.

Setup

GPU 0 AMD Radeon AI PRO R9700 32 GB (gfx1201), power limit 210 W, PCIe 3.0 ×8
GPU 1 NVIDIA RTX 3050 8 GB (driver 615.71.09), used as an expert helper through a local patch (below)
CPU / RAM i7-6700K (4C/8T), 64 GB DDR4 non-ECC (XMP state not known)
OS Bazzite 44 (Fedora 44), kernel 7.2.8, in-kernel amdgpu
Build Strata 0.1.40.2 from source in a container: ROCm 7.2.1, HIP gfx1201; helper library CUDA 12.8 sm_86
Model Swift 1.5 Qwen3.8-Flash-Next IQ3_XXS GSQ-RCO (native pack), MTP head (q2_0 runtime pack)

Local patch, for transparency. Three files are changed: remote_experts.cpp, remote_expert_opt.cu and generate.cpp. The patch lets the HIP engine use an NVIDIA card as --expert-cache-device1 through a dlopen'd CUDA library, and accepts --resident-experts with that helper. It does not touch prefill.cpp, the prompt-path kernels or the verify kernels. The helper only takes part in RemoteExperts::begin/finish, which run in the decode windows. We did not run without the helper. cjdell's report above, which has the same shape on a single R9700, suggests it is not needed.

Engine arguments (container paths):

--pack <pack> --native <gguf> --ple-gguf <gguf> --expert-profile data/expert-profile.bin --expert-cache auto
--prefill 16384 --short-read 150 --prompt-cache-root 256 --spec 4 --spec-min-p 0.5 --mtp <mtp rt>
--max-context 262144 --kv int8 --kv-resident 262144 --pool-workers 4 --vram-reserve-mib 768
--expert-cache-device1 2200 --resident-experts --remote-expert-opt
env: STRATA_HIP_WMMA=1 STRATA_NO_LARGEPAGES=1 STRATA_DECODE_TIMING=1 STRATA_XV_KEEP_HELPER_RAM=1 (+ the helper library's variables)
server: --fit-max-tokens

In production

We traced about 730 agent requests (an OpenAI-compatible coding agent with tools). Two fires had the same shape:

cached read then
14,264 222 ! from the first token; the next 15 requests of that conversation too
31,924 261 ! from the first token; the next 3 requests too

A new conversation was always clean. Replaying the failing request verbatim on a fresh engine, alone or after the requests that led to it, was clean. cjdell's fire above has the same shape: 99,889 cached + 245 read. tools/stop_resend_test.py passed 40/40 with STRATA_DBG_NAN=1.

Localisation (STRATA_DBG_NAN=1, verbatim; 204 tokens read → chunk T 199)

strata dbg: layer 31 (mmq 1, types 16/20, 223 experts): non-finite GU 550400 H 275200 Dm 1100800 bo 110080 of T 199
strata dbg: prompt end: last residual row 10240 non-finite (max |x| 0); PLE history 0 non-finite (max |x| 11.6); GDN state 0 0 non-finite (max |x| 1.86)
strata dbg: verify window at position 15013, row 0: 248320 of 248320 logits non-finite (token out 0)

550,400 / 1,280 = 430 GU rows, and 1,100,800 / 2,560 = 430 Dm rows, i.e. 43 tokens × K = 10. So 43 of the chunk's 199 tokens have all their expert rows non-finite, which points at per-token data rather than one expert's weights. Only one fire was captured with this flag, because it lowers the fire rate (about 0.14 % of requests here against 0.43 % without it), probably through the per-layer syncs.

Method

The script at the end replays agent-like turns: each request resumes the previous conversation from the cache, appends N new tokens of text, and generates 160 tokens. Conversations start at about 12 k tokens and are restarted at 60 k, and after a fire with a different first message (no shared prefix).

Read size vs fires (all runs except --short-read 260, pooled)

tokens read requests fires
< 192 1,888 0
192–223 807 10
224–255 763 15
256–287 680 3 (256, 257, 258)
≥ 288 2,596 0

All 28 fires had 198–258 tokens read. That is 28 in 1,636 window requests (1.7 %) and 0 in 4,419 outside it.

One change at a time (default config; band 151–400 tokens read unless noted)

run requests fires in the 192–258 window
baseline 1,406 6 6 / 308
--no-prefill-borrow 779 3 3 / 191
--adapt-every 100000 1,252 10 10 / 294
STRATA_PF_STEP_SYNC=1 948 2 + 1 GPU hang 2 / 238
without STRATA_HIP_WMMA (band 195–260) 1,053 6 6 / 440
--short-read 260 (band 195–260) 770 0 0 / 312

None of the other changes removes the fire. The prompt-cache-slot borrowing, cache adaptation, a per-step sync and the WMMA prompt attention all still fire. Pooling the other runs gives 27 fires in 1,471 window requests (1.8 %), so about 5.7 were expected with --short-read 260. Seeing 0 has a probability of roughly 0.3 % by chance. The median request time was 4.4 s with --short-read 260 against 4.6 s at baseline.

One case is not covered: a read longer than --prefill whose last chunk lands in the window.

GPU hangs on the same path

Twice, once with STRATA_DBG_NAN=1 and once with STRATA_PF_STEP_SYNC=1, a short read never finished:

strata serve: no progress for 60 s during a request (reading the prompt (batched): waiting for the GPU (attention, router) at layer 15 of the prompt chunk from token 24455)
HW Exception by GPU node-1 (...) reason :GPU Hang
amdgpu: MES(0) failed to respond to msg=REMOVE_QUEUE ... Failed to evict process queues ... GPU reset begin! ... MODE1 reset ... VRAM is lost due to GPU reset!

In both cases the server restarted the engine and it ran normally afterwards. Neither hang happened in the runs without extra syncs, which had 0 hangs and 25 fires. So the same defect may show up either as non-finite rows or as a hang, depending on timing.

Reproducer (any long plain-text file as the corpus, e.g. docs/DETAILS.md)
#!/usr/bin/env python3
"""Reproducer for the all-'!' NaN degeneration (#879 / ROCm/legacy-rocm-build#606): agent-like turns whose new part is a short prompt read.

Each request resumes the previous conversation from the cache, appends LO..HI new tokens of text, and generates MAX
tokens. A reply made only of '!' (token 0) means the conversation state is poisoned: it is counted, and a new
conversation (different first message, so no shared prefix) is started. A conversation is also restarted past CAP
tokens. Any long plain-text file works as the corpus (e.g. docs/DETAILS.md of this repo).

  python3 stress_short_reads.py http://127.0.0.1:8080 corpus.txt [--lo 195] [--hi 260] [--max 160]
                                [--minutes 60] [--base 12000] [--cap 60000]
"""
import json, random, sys, time, urllib.request

URL = sys.argv[1].rstrip("/") + "/v1/chat/completions"
CORPUS = open(sys.argv[2], encoding="utf-8", errors="replace").read()
a = sys.argv[3:]
opt = lambda n, d: type(d)(a[a.index(n) + 1]) if n in a else d
LO, HI, MAX, MINUTES, BASE, CAP = opt("--lo", 195), opt("--hi", 260), opt("--max", 160), opt("--minutes", 60.0), \
    opt("--base", 12000), opt("--cap", 60000)
rng = random.Random()
chars_per_token = [3.5]   # re-estimated after every request from the tokens the server reports as read


def chunk(tokens):
    n = int(tokens * chars_per_token[0])
    i = rng.randrange(0, max(1, len(CORPUS) - n))
    return CORPUS[i:i + n]


def new_conversation():
    return [{"role": "system", "content": f"[session {rng.randrange(10**9)}] You are a helpful assistant.\n\n" + chunk(BASE)},
            {"role": "user", "content": "Read the material above. I will send more; answer briefly each time."}]


def send(msgs):
    body = {"model": "m", "messages": msgs, "max_tokens": MAX, "temperature": 1.0, "top_p": 0.95, "top_k": 20,
            "stream": False, "chat_template_kwargs": {"enable_thinking": True, "reasoning_effort": "low"}}
    r = json.load(urllib.request.urlopen(urllib.request.Request(URL, data=json.dumps(body).encode(),
                                                               headers={"Content-Type": "application/json"}), timeout=1800))
    m = r["choices"][0]["message"]
    return r, (m.get("reasoning_content") or "") + (m.get("content") or "")


end, n, bad, msgs = time.time() + MINUTES * 60, 0, 0, new_conversation()
while time.time() < end:
    piece = chunk(rng.randint(LO, HI) - 20)
    msgs = msgs + [{"role": "user", "content": piece}]
    r, text = send(msgs)
    u = r.get("usage", {})
    cached = (u.get("prompt_tokens_details") or {}).get("cached_tokens") or 0
    read = (u.get("prompt_tokens") or 0) - cached
    if cached and read > 40:
        chars_per_token[0] = 0.8 * chars_per_token[0] + 0.2 * len(piece) / max(1, read - 20)
    poisoned = (len(text.strip()) >= 4 and set(text.strip()) == {"!"}) or "!" * 30 in text
    n += 1
    if poisoned:
        bad += 1
        print(f"POISONED request {n}: prompt {u.get('prompt_tokens')} tokens, {cached} cached, {read} read", flush=True)
    if poisoned or (u.get("prompt_tokens") or 0) > CAP:
        msgs = new_conversation()
    else:
        msgs = msgs + [{"role": "assistant", "content": (r["choices"][0]["message"].get("content") or "OK.")[:200]}]
    if n % 100 == 0:
        print(f"{n} requests, {bad} poisoned", flush=True)
print(f"done: {n} requests, {bad} poisoned", flush=True)

python3 stress_short_reads.py http://127.0.0.1:8080 docs/DETAILS.md --minutes 60 (defaults: reads of 195–260 tokens, 160 generated). At our rate, expect about one fire per 50–70 requests in the window, without --short-read 260.

<!-- gh-comment-id:6097729179 --> @MKheru commented on GitHub (Oct 10, 2026): ## HIP / RDNA4 (R9700): the poison is born in the batched prompt path for chunks of ~193–256 tokens — `--short-read 260` avoids it (0 / 770 vs 27 / 1,471 in that window) A night of targeted runs on 0.1.40.2. Short version: every all-`!` fire we could produce (28 of them) came from a **prompt read of 198–258 new tokens on top of a cached conversation**, i.e. a batched prompt chunk of about 193–253 tokens. There were none in 4,419 requests whose read fell outside that window. `STRATA_DBG_NAN=1` puts the first non-finite values in a layer's MoE output during that chunk. Raising `--short-read` to 260, so those reads go through the verify windows instead, gave 0 fires in 770 requests (312 of them inside the window) at no measurable speed cost. ### Setup | | | |---|---| | GPU 0 | AMD Radeon AI PRO R9700 32 GB (gfx1201), power limit 210 W, PCIe 3.0 ×8 | | GPU 1 | NVIDIA RTX 3050 8 GB (driver 615.71.09), used as an expert helper through a local patch (below) | | CPU / RAM | i7-6700K (4C/8T), 64 GB DDR4 non-ECC (XMP state not known) | | OS | Bazzite 44 (Fedora 44), kernel 7.2.8, in-kernel amdgpu | | Build | Strata 0.1.40.2 from source in a container: ROCm 7.2.1, HIP gfx1201; helper library CUDA 12.8 sm_86 | | Model | Swift 1.5 Qwen3.8-Flash-Next IQ3_XXS GSQ-RCO (native pack), MTP head (q2_0 runtime pack) | **Local patch, for transparency.** Three files are changed: `remote_experts.cpp`, `remote_expert_opt.cu` and `generate.cpp`. The patch lets the HIP engine use an NVIDIA card as `--expert-cache-device1` through a dlopen'd CUDA library, and accepts `--resident-experts` with that helper. It does not touch `prefill.cpp`, the prompt-path kernels or the verify kernels. The helper only takes part in `RemoteExperts::begin/finish`, which run in the decode windows. We did not run without the helper. cjdell's report above, which has the same shape on a single R9700, suggests it is not needed. Engine arguments (container paths): ``` --pack <pack> --native <gguf> --ple-gguf <gguf> --expert-profile data/expert-profile.bin --expert-cache auto --prefill 16384 --short-read 150 --prompt-cache-root 256 --spec 4 --spec-min-p 0.5 --mtp <mtp rt> --max-context 262144 --kv int8 --kv-resident 262144 --pool-workers 4 --vram-reserve-mib 768 --expert-cache-device1 2200 --resident-experts --remote-expert-opt env: STRATA_HIP_WMMA=1 STRATA_NO_LARGEPAGES=1 STRATA_DECODE_TIMING=1 STRATA_XV_KEEP_HELPER_RAM=1 (+ the helper library's variables) server: --fit-max-tokens ``` ### In production We traced about 730 agent requests (an OpenAI-compatible coding agent with tools). Two fires had the same shape: | cached | read | then | |---|---|---| | 14,264 | 222 | `!` from the first token; the next 15 requests of that conversation too | | 31,924 | 261 | `!` from the first token; the next 3 requests too | A new conversation was always clean. Replaying the failing request verbatim on a fresh engine, alone or after the requests that led to it, was clean. cjdell's fire above has the same shape: 99,889 cached + 245 read. `tools/stop_resend_test.py` passed 40/40 with `STRATA_DBG_NAN=1`. ### Localisation (`STRATA_DBG_NAN=1`, verbatim; 204 tokens read → chunk T 199) ``` strata dbg: layer 31 (mmq 1, types 16/20, 223 experts): non-finite GU 550400 H 275200 Dm 1100800 bo 110080 of T 199 strata dbg: prompt end: last residual row 10240 non-finite (max |x| 0); PLE history 0 non-finite (max |x| 11.6); GDN state 0 0 non-finite (max |x| 1.86) strata dbg: verify window at position 15013, row 0: 248320 of 248320 logits non-finite (token out 0) ``` 550,400 / 1,280 = 430 GU rows, and 1,100,800 / 2,560 = 430 Dm rows, i.e. 43 tokens × K = 10. So 43 of the chunk's 199 tokens have **all** their expert rows non-finite, which points at per-token data rather than one expert's weights. Only one fire was captured with this flag, because it lowers the fire rate (about 0.14 % of requests here against 0.43 % without it), probably through the per-layer syncs. ### Method The script at the end replays agent-like turns: each request resumes the previous conversation from the cache, appends N new tokens of text, and generates 160 tokens. Conversations start at about 12 k tokens and are restarted at 60 k, and after a fire with a different first message (no shared prefix). ### Read size vs fires (all runs except `--short-read 260`, pooled) | tokens read | requests | fires | |---|---|---| | < 192 | 1,888 | 0 | | **192–223** | **807** | **10** | | **224–255** | **763** | **15** | | 256–287 | 680 | 3 (256, 257, 258) | | ≥ 288 | 2,596 | 0 | All 28 fires had 198–258 tokens read. That is 28 in 1,636 window requests (1.7 %) and 0 in 4,419 outside it. ### One change at a time (default config; band 151–400 tokens read unless noted) | run | requests | fires | in the 192–258 window | |---|---|---|---| | baseline | 1,406 | 6 | 6 / 308 | | `--no-prefill-borrow` | 779 | 3 | 3 / 191 | | `--adapt-every 100000` | 1,252 | 10 | 10 / 294 | | `STRATA_PF_STEP_SYNC=1` | 948 | 2 + 1 GPU hang | 2 / 238 | | without `STRATA_HIP_WMMA` (band 195–260) | 1,053 | 6 | 6 / 440 | | **`--short-read 260`** (band 195–260) | **770** | **0** | **0 / 312** | None of the other changes removes the fire. The prompt-cache-slot borrowing, cache adaptation, a per-step sync and the WMMA prompt attention all still fire. Pooling the other runs gives 27 fires in 1,471 window requests (1.8 %), so about 5.7 were expected with `--short-read 260`. Seeing 0 has a probability of roughly 0.3 % by chance. The median request time was 4.4 s with `--short-read 260` against 4.6 s at baseline. One case is not covered: a read longer than `--prefill` whose last chunk lands in the window. ### GPU hangs on the same path Twice, once with `STRATA_DBG_NAN=1` and once with `STRATA_PF_STEP_SYNC=1`, a short read never finished: ``` strata serve: no progress for 60 s during a request (reading the prompt (batched): waiting for the GPU (attention, router) at layer 15 of the prompt chunk from token 24455) HW Exception by GPU node-1 (...) reason :GPU Hang amdgpu: MES(0) failed to respond to msg=REMOVE_QUEUE ... Failed to evict process queues ... GPU reset begin! ... MODE1 reset ... VRAM is lost due to GPU reset! ``` In both cases the server restarted the engine and it ran normally afterwards. Neither hang happened in the runs without extra syncs, which had 0 hangs and 25 fires. So the same defect may show up either as non-finite rows or as a hang, depending on timing. <details><summary>Reproducer (any long plain-text file as the corpus, e.g. docs/DETAILS.md)</summary> ```python #!/usr/bin/env python3 """Reproducer for the all-'!' NaN degeneration (#879 / ROCm/legacy-rocm-build#606): agent-like turns whose new part is a short prompt read. Each request resumes the previous conversation from the cache, appends LO..HI new tokens of text, and generates MAX tokens. A reply made only of '!' (token 0) means the conversation state is poisoned: it is counted, and a new conversation (different first message, so no shared prefix) is started. A conversation is also restarted past CAP tokens. Any long plain-text file works as the corpus (e.g. docs/DETAILS.md of this repo). python3 stress_short_reads.py http://127.0.0.1:8080 corpus.txt [--lo 195] [--hi 260] [--max 160] [--minutes 60] [--base 12000] [--cap 60000] """ import json, random, sys, time, urllib.request URL = sys.argv[1].rstrip("/") + "/v1/chat/completions" CORPUS = open(sys.argv[2], encoding="utf-8", errors="replace").read() a = sys.argv[3:] opt = lambda n, d: type(d)(a[a.index(n) + 1]) if n in a else d LO, HI, MAX, MINUTES, BASE, CAP = opt("--lo", 195), opt("--hi", 260), opt("--max", 160), opt("--minutes", 60.0), \ opt("--base", 12000), opt("--cap", 60000) rng = random.Random() chars_per_token = [3.5] # re-estimated after every request from the tokens the server reports as read def chunk(tokens): n = int(tokens * chars_per_token[0]) i = rng.randrange(0, max(1, len(CORPUS) - n)) return CORPUS[i:i + n] def new_conversation(): return [{"role": "system", "content": f"[session {rng.randrange(10**9)}] You are a helpful assistant.\n\n" + chunk(BASE)}, {"role": "user", "content": "Read the material above. I will send more; answer briefly each time."}] def send(msgs): body = {"model": "m", "messages": msgs, "max_tokens": MAX, "temperature": 1.0, "top_p": 0.95, "top_k": 20, "stream": False, "chat_template_kwargs": {"enable_thinking": True, "reasoning_effort": "low"}} r = json.load(urllib.request.urlopen(urllib.request.Request(URL, data=json.dumps(body).encode(), headers={"Content-Type": "application/json"}), timeout=1800)) m = r["choices"][0]["message"] return r, (m.get("reasoning_content") or "") + (m.get("content") or "") end, n, bad, msgs = time.time() + MINUTES * 60, 0, 0, new_conversation() while time.time() < end: piece = chunk(rng.randint(LO, HI) - 20) msgs = msgs + [{"role": "user", "content": piece}] r, text = send(msgs) u = r.get("usage", {}) cached = (u.get("prompt_tokens_details") or {}).get("cached_tokens") or 0 read = (u.get("prompt_tokens") or 0) - cached if cached and read > 40: chars_per_token[0] = 0.8 * chars_per_token[0] + 0.2 * len(piece) / max(1, read - 20) poisoned = (len(text.strip()) >= 4 and set(text.strip()) == {"!"}) or "!" * 30 in text n += 1 if poisoned: bad += 1 print(f"POISONED request {n}: prompt {u.get('prompt_tokens')} tokens, {cached} cached, {read} read", flush=True) if poisoned or (u.get("prompt_tokens") or 0) > CAP: msgs = new_conversation() else: msgs = msgs + [{"role": "assistant", "content": (r["choices"][0]["message"].get("content") or "OK.")[:200]}] if n % 100 == 0: print(f"{n} requests, {bad} poisoned", flush=True) print(f"done: {n} requests, {bad} poisoned", flush=True) ``` `python3 stress_short_reads.py http://127.0.0.1:8080 docs/DETAILS.md --minutes 60` (defaults: reads of 195–260 tokens, 160 generated). At our rate, expect about one fire per 50–70 requests in the window, without `--short-read 260`. </details>
Author
Owner

@MKheru commented on GitHub (Oct 10, 2026):

XMP update (re @VeenLee's report): on our R9700 box XMP is off. The board can't run the profile at all (enabling it makes the BIOS fail to boot), so the RAM runs at its default JEDEC settings. All the all-! fires reported above happened with XMP off, so on our side this is not a RAM overclock issue: the trigger is still the batched prompt chunk of ~193–256 tokens, and --short-read 260 still avoids it.

<!-- gh-comment-id:6103072381 --> @MKheru commented on GitHub (Oct 10, 2026): **XMP update (re @VeenLee's report):** on our R9700 box XMP is **off**. The board can't run the profile at all (enabling it makes the BIOS fail to boot), so the RAM runs at its default JEDEC settings. All the all-`!` fires reported above happened with XMP off, so on our side this is not a RAM overclock issue: the trigger is still the batched prompt chunk of ~193–256 tokens, and `--short-read 260` still avoids it.
Author
Owner

@Niko1221 commented on GitHub (Oct 11, 2026):

Thank you for the stress script and the read-length analysis; we used both.

What we tried on an R9700 (gfx1201): your stress_short_reads.py, 1,870 requests over four configurations (IQ3_S and an IQ3_XXS pack with the same expert types as yours, --short-read 150, --prompt-cache-root 256, the 0.1.40 and 0.1.42 engines), about 830 of them reading 192-258 new tokens. No fire. A separate test of the prompt MMQ kernels at 8-420 rows per expert (276 cases, IQ2_XXS / IQ4_NL) gave finite outputs matching a CPU reference every time.

0.1.43 adds lask3802's NaN guard (#1892, on by default): a window whose logits are all NaN emits nothing, the caches are dropped and the prompt is read again from token 0, and the server retries once, so the '!' answers should not reach you even if the cause is still there. The engine logs non-finite logits (#879) when it fires.

To find the cause, could you check on 0.1.43:

  1. Does it still fire (the log line above) without your local CUDA-helper patch?
  2. Does it fire with STRATA_PREFILL_CPU_SHARE=0, with --pcie-frac 0, and at the card's default power limit?
  3. The expert cache N slots line, and STRATA_DBG_NAN output from more than one fire: is the bad row range always one group?
<!-- gh-comment-id:6110176086 --> @Niko1221 commented on GitHub (Oct 11, 2026): Thank you for the stress script and the read-length analysis; we used both. What we tried on an R9700 (gfx1201): your stress_short_reads.py, 1,870 requests over four configurations (IQ3_S and an IQ3_XXS pack with the same expert types as yours, --short-read 150, --prompt-cache-root 256, the 0.1.40 and 0.1.42 engines), about 830 of them reading 192-258 new tokens. No fire. A separate test of the prompt MMQ kernels at 8-420 rows per expert (276 cases, IQ2_XXS / IQ4_NL) gave finite outputs matching a CPU reference every time. 0.1.43 adds lask3802's NaN guard (#1892, on by default): a window whose logits are all NaN emits nothing, the caches are dropped and the prompt is read again from token 0, and the server retries once, so the '!' answers should not reach you even if the cause is still there. The engine logs `non-finite logits (#879)` when it fires. To find the cause, could you check on 0.1.43: 1. Does it still fire (the log line above) without your local CUDA-helper patch? 2. Does it fire with `STRATA_PREFILL_CPU_SHARE=0`, with `--pcie-frac 0`, and at the card's default power limit? 3. The `expert cache N slots` line, and STRATA_DBG_NAN output from more than one fire: is the bad row range always one group?
Author
Owner

@MKheru commented on GitHub (Oct 12, 2026):

It follows ROCm 7.2.1's runtime libraries: same 0.1.43 source on ROCm 10.0.0, 0 fires in 1,911 requests; cross builds point at the libraries, not the compiler

Thank you for running the stress script. Here is everything from one night and one day of runs on our box (about
18 hours), on your three points and on what came after them.

In short. On our R9700, nothing in Strata's settings removes the fire, and the debug prints show bad rows written
by several different kernels. The same 0.1.43 source, rebuilt and run on ROCm 10.0.0, gives 0 fires in 1,911
requests
. At the 7.2.1 rate we would have expected about 12. A cross build settles where the fault is. The engine
built with 7.2.1 but run on 10.0.0's libraries gives 0 fires in 1,183 requests. The engine built with 10.0.0 but run on
7.2.1's libraries fires again within two minutes: 9 fires in 941 requests, the 7.2.1 rate. So the fault sits in ROCm 7.2.1's runtime or
libraries, not in the code the compiler makes and, as far as one card can tell, not in Strata.

Setup.

  • R9700 alone (gfx1201); no other GPU used. Engines built from the v0.1.40.2 and v0.1.43 tags with no local change,
    except the debug prints described below, which only run under STRATA_DBG_NAN.
  • ROCm 7.2.1 unless noted; power limit 210 W unless noted.
  • Model: Swift 1.5 Qwen3.8-Flash-Next IQ3_XXS, GSQ-RCO native pack, MTP head.
  • Flags: --resident-experts --pool-workers 4 --kv int8 --max-context 262144 --kv-resident 262144 --prefill 16384 --short-read 150 --prompt-cache-root 256 --spec 4 --spec-min-p 0.5, plus STRATA_HIP_WMMA=1.
  • Load: the stress_short_reads.py from my previous comment. It sends reads of 195–260 new tokens on a resumed
    12k–60k conversation, with 160 tokens out; about 40 % of the requests land in the 192–258 window.
  • Fires are counted from the engine's own non-finite logits (#879) lines (0.1.43) or logits non-finite lines
    (0.1.40.2).

1. Without the helper patch: yes, on both engines

engine (stock, R9700 only, STRATA_DBG_NAN=1) duration requests fires
0.1.40.2 66 min 592 1
0.1.43 93 min 646 7

0.1.43's guard caught every fire of the night (21): no ! reached the client. Without STRATA_DBG_NAN, each caught
request was answered normally in 15–23 s, re-read of 15k–28k tokens included. With it, the retry took 106–440 s,
because the debug checks slow the re-read to ~125 tok/s.

2. One setting at a time, on 0.1.43: none of them removes it

change duration requests fires
— (0.1.43 defaults, above) 93 min 646 7
STRATA_PREFILL_CPU_SHARE=0 (already off on HIP, so this repeats the default) 64 min 427 3, + 1 GPU hang
--pcie-frac 0 61 min 586 2
power limit 300 W (the card's default) instead of 210 W 61 min 593 1
--kv fp16 instead of int8 61 min 336 4, + 1 GPU hang
no STRATA_DBG_NAN (stock 0.1.43) 82 min 1,025 4, + 1 GPU hang

Durations include the engine start (1–5 min).

The fire rate varies between runs (0.17–1.2 % of requests), so with these counts I can't say one engine fires more
than the other.

3. The expert cache line, and where the bad rows are

strata generate: expert cache auto: 23.40 GiB free, 768 MiB reserved (+83 MiB for the draft head) -> 10404 slots
strata generate: expert cache 13907 slots, 22.57 GiB of VRAM; policy is

(12088 slots, 19.63 GiB with --kv fp16.)

Only full-attention layers. Every report came from layers 3, 7, 19, 23, 27, 31, 35, 39, 43 or 47. This model's
full-attention (QSA) layers are exactly 3, 7, 11, …, 47 (read from the GGUF tensors: attn_k, no ssm_*). None of the
36 GDN layers was ever reported.

Whole tokens. In 76 of 77 STRATA_DBG_NAN layer reports, every expert row of a bad token is bad: the non-finite rows
of GU, H and Dm are exactly 10 × the bad tokens of bo.

Already bad at the MoE's input, never in the first 64 rows of the chunk. I added one print (diff at the end) that
lists the non-finite tokens of bo and of m.mixed. In 10 of 11 night fires, the same tokens are already non-finite in
m.mixed. The 11th has a finite input, and the bad values first appear at the combine, for tokens in the same range.
The finite values are small (largest |x| 3.3–10.5), so it is not an overflow. To your question: no, the bad rows are
not one group.
They come in one to twelve runs with holes, from row 64 to the end of the chunk, and never below
row 64.

The 11 night lines, verbatim
strata dbg879: layer 31 T 197: non-finite tokens of the MoE output 6 [66-67,69-72]; of its input (mixed) 6 [66-67,69-72]; max |finite input| 10.45
strata dbg879: layer 43 T 231: non-finite tokens of the MoE output 68 [86-116,128,131,135-153,155,157-162,164-170,229-230]; of its input (mixed) 68 [86-116,128,131,135-153,155,157-162,164-170,229-230]; max |finite input| 7.561
strata dbg879: layer 35 T 238: non-finite tokens of the MoE output 149 [64,72,76-82,84-127,130,133,137,140-200,202-224,226-227,229,232-237]; of its input (mixed) 149 [64,72,76-82,84-127,130,133,137,140-200,202-224,226-227,229,232-237]; max |finite input| 6.328
strata dbg879: layer 23 T 221: non-finite tokens of the MoE output 4 [84-86,89]; of its input (mixed) 4 [84-86,89]; max |finite input| 9.094
strata dbg879: layer 27 T 199: non-finite tokens of the MoE output 40 [158-192,194-198]; of its input (mixed) 40 [158-192,194-198]; max |finite input| 3.309
strata dbg879: layer 47 T 256: non-finite tokens of the MoE output 62 [192-253]; of its input (mixed) 62 [192-253]; max |finite input| 10.06
strata dbg879: layer 7 T 202: non-finite tokens of the MoE output 123 [73,80-201]; of its input (mixed) 123 [73,80-201]; max |finite input| 5.608
strata dbg879: layer 27 T 253: non-finite tokens of the MoE output 180 [64-91,93,95-141,143-145,147-150,153-202,204-215,217,219-252]; of its input (mixed) 180 [64-91,93,95-141,143-145,147-150,153-202,204-215,217,219-252]; max |finite input| 3.4
strata dbg879: layer 19 T 245: non-finite tokens of the MoE output 160 [79-133,136-170,172-181,183-222,224-235,237-244]; of its input (mixed) 160 [79-133,136-170,172-181,183-222,224-235,237-244]; max |finite input| 9.571
strata dbg879: layer 19 T 229: non-finite tokens of the MoE output 85 [144-228]; of its input (mixed) 85 [144-228]; max |finite input| 3.309
strata dbg879: layer 19 T 193: non-finite tokens of the MoE output 5 [67-69,72,74]; of its input (mixed) 0 []; max |finite input| 4.127

4. Inside the attention half: three different kernels write the bad rows

Next I took the attention half of the QSA layers apart, still on stock 0.1.43 with debug prints only, under the same
load. There were four prints, all under STRATA_DBG_NAN and only for chunks of 1024 tokens or fewer:

  • Attention half, end: the non-finite tokens of every buffer of the chain (m.mixed, K, V, Qf, q, the indexer's
    two projections, the selected cells checked against [0, p0 + t], m.attn, m.attn_h, m.bo, m.inj).
  • MoE half, input: the same check (R, its row scales, xn16, lo, gated, mixed).
  • Step by step: after each of the eleven steps of the half (K proj, V proj, Q proj, indexer projections, K
    norm/rope + KV append, Q split/norm/rope, indexer append, selection, attention, gate, out proj), the first step after
    which each buffer holds a non-finite row.
  • Fill pattern: those buffers filled with 0xFF bytes before the half, then the rows still holding that pattern
    reported. It never fired: every bad row was written, with wrong values.

These three debug runs lasted 14, 56 and 31 min (614 requests). The three fires that went through these prints,
verbatim:

strata dbg879b: layer 19 T 201 p0 59199 (attention half): in 0 []; K 0 []; V 17 [69,80-95]; Qf 0 []; q 0 []; idx_raw 0 []; q_idx 0 []; ids out of range 0 []; attn 113 [85-131,133-170,172-197,199-200]; attn_h 115 [64,78,85-131,133-170,172-197,199-200]; bo 115 [64,78,85-131,133-170,172-197,199-200]; inj 0 []
strata dbg879d: layer 3 T 244 p0 26025 (attention half, step by step): V first non-finite after V proj 16 [208-223];
strata dbg879d: layer 39 T 194 p0 12254 (attention half, step by step): attn first non-finite after attention 108 [84-191]; attn_h first non-finite after gate 109 [79,84-191]; bo first non-finite after out proj 109 [79,84-191];
strata dbg879b: layer 39 T 194 p0 12254 (attention half): in 0 []; K 0 []; V 0 []; Qf 0 []; q 0 []; idx_raw 0 []; q_idx 0 []; ids out of range 0 []; attn 108 [84-191]; attn_h 109 [79,84-191]; bo 109 [79,84-191]; inj 0 []
  • The half's input is always clean, and so are K, Q and the indexer. The selected cells are always in range.
  • Three different kernels write the bad rows:
    • the V projection, twice (rows [69,80-95], then [208-223] right after the V GEMM);
    • the attention ([84-191], with clean q, K, V and selection);
    • the gate (rows 64 and 78 in the first fire and row 79 in the third, where m.attn and Qf are finite).
  • attn_k and attn_v have the same type and shape in this pack (IQ4_XS, 2560 → 512, read from the GGUF). From the same
    input, K comes out right and V wrong, so this is not a shape the GEMM gets wrong.
  • Still never a row below 64 of the chunk (14 of 14).
  • It can be silent. In the layer-3 fire, the NaN rows of V went into the int8 KV cache as finite codes. Nothing
    downstream was non-finite, the guard did not fire and the reply went out normally, with 16 wrong K/V cells in the
    cache.

None of this looks like one kernel's bug. It looks like something that sometimes corrupts the rows a kernel writes in
this window, below Strata. So the next step was to change the layers under it, one at a time.

5. One change at a time below Strata

All runs use stock 0.1.43 without the debug prints, under the same load.

change duration requests in the 192–258 window fires card hangs
— (ROCm 7.2.1, the night's run without STRATA_DBG_NAN) 82 min 1,025 — 4 1
GPU_MAX_HW_QUEUES=1 30 min * 372 149 5 0
STRATA_DENSE_MMQ=1 (dense projections through MMQ, no hipBLAS/hipBLASLt) 48 min * 609 247 4 0
ROCm 10.0.0 (HIP 7.15, hipBLASLt 1.4), engine rebuilt and run there 126 min 1,911 730 0 0
engine built on 7.2.1, run on 10.0.0's libraries 77 min 1,183 511 0 0
engine built on 10.0.0, run on 7.2.1's libraries 78 min 941 400 9 1

* Stopped by hand once they had fired 4–5 times. Stopping on fires inflates their rates; it does not change the
fact that they fire. The ROCm 10.0.0 and cross runs ran their full planned length, whatever they showed.

  • The 7.2.1 baseline. The three 7.2.1 rows without debug prints give 13 fires in 2,006 requests. At that rate,
    ROCm 10.0.0 should have shown ~12 fires; getting 0 by chance has a probability of about 4 × 10⁻⁶. The 7.2.1-built
    engine on 10.0.0's libraries should have shown ~8 (probability of 0 by chance ≈ 5 × 10⁻⁴).
  • Same settings throughout. All rows use the same --short-read 150 (checked in the generated config of each
    run) and the same load.
  • How the cross builds were made. Each binary comes from the other image's build directory. All shared objects
    (libamdhip64.so.7, libhsa-runtime64.so.1, libhipblas.so.3, libhipblaslt.so.1, librocblas.so.5,
    libamd_comgr.so.3) resolve from the image the binary runs in (checked with ldd).
  • Which library, I have not isolated. It is one of the HIP runtime, ROCr, comgr or the BLAS libraries. The
    STRATA_DENSE_MMQ=1 row suggests it is not the dense GEMMs.
  • Gotcha for anyone trying the official image. rocm/dev-ubuntu-24.04:10.0.0-full does not put /opt/rocm/lib on
    the loader path. Our first start failed with libhipblaslt.so.1: cannot open shared object file; an ld.so.conf.d
    entry plus LD_LIBRARY_PATH=/opt/rocm/lib fixed it.
  • Two changes that do nothing on this card. STRATA_PF_GEMM=1 would have been the obvious A/B for the GEMM, but
    strata_pf_gemm_f16 returns false below gfx11's WMMA check on gfx12 (wmma_gemm.cu:688), so it is a no-op here.
    STRATA_PROMPT_ATTN_OLD and STRATA_SELECT_OLD are already the HIP defaults.

Speed on 10.0.0 (mesure.py, one pass each, our daily settings with --short-read 260):

7.2.1 10.0.0
fresh 4k prompt read 800 tok/s 907 tok/s
fresh 40k prompt read 1,747 tok/s 1,903 tok/s
writing, median 67.9 tok/s 65.9 tok/s

The writing difference is within the noise of a single pass.

6. The card hangs: a separate issue, not settled

  • Signature. The hang matches ROCm/ROCm#6630 (R9700, MES(0) failed to respond to msg=REMOVE_QUEUE, then a MODE1
    reset). That issue is open, and its author reproduces it on ROCm 6.4.4, 7.x and 10.0.0. Firmware there is MES 0x8b;
    here it is MES 0x93, on kernel 7.2.
  • What our logs show first. The prompt read stops making progress (reading the prompt: … 10 s … 20 s … 30 s so far), and the queue-removal failure comes 2.5 to 33 s after the read started. The driver message is the end of the
    story, not its start. Once, the engine's own watchdog named the step: waiting for the GPU (attention, router) at layer 15.
  • Counts.
    • On 7.2.1's libraries, four hangs in about 6,700 requests (the fourth during the last cross run above, with the
      10.0.0-built engine; the read stalled waiting for the GPU (attention, router) at layer 7).
    • On 10.0.0's libraries, none in 3,094 requests. At the 7.2.1 rate, ~1.8 were expected (a 16 % chance of seeing
      none), so this hints that the hang follows the libraries too, but it does not show it.
  • What ROCm/legacy-rocm-build#884 suggests. STRATA_HIP_ADAPT_KERNEL_COPY=1 is worth a try for that, since our setup has MMQ, adaptive
    swaps and SDMA together. I have not run it yet.

7. What I take from it

  • Reach. On gfx1201, ROCm/legacy-rocm-build#879 goes away with ROCm 10.0.0, and the 7.2.1 runtime libraries are enough to bring it back.
    It may be worth a line in the README for HIP users.
  • For anyone who stays on 7.2.1. 0.1.43's guard works (21 of 21 caught, ~20 s per retry without debug prints).
    --short-read 260 kept the window path out of use entirely (0 fires in 770 requests in my earlier run, at no measured
    cost).
  • The silent case. The layer-3 case in section 4 is a reason to prefer the upgrade over the guard: with int8 KV, a fire can leave
    wrong cells in the cache without tripping it.
  • Your no-fire run. This may be why your R9700 saw no fire in 1,870 requests: which ROCm was that box on? If it
    was newer than 7.2.1, that would fit.
  • Limits. One card, one model. I did not bisect which 7.2.1 library carries it.
The night's debug print (0.1.43, src/prefill/prefill.cpp, only under STRATA_DBG_NAN)
--- a/src/prefill/prefill.cpp
+++ b/src/prefill/prefill.cpp
@@ -3920,6 +3920,38 @@
                                          "H %lld Dm %lld bo %lld of T %lld\n", (long long) l, (int) use_mmq, mmq_gt, mmq_dt,
                                          n_order, (long long) bgu, (long long) bh, (long long) bdm, (long long) bbo,
                                          (long long) T);
+                            // local debug (#879): which tokens of the chunk are non-finite at the MoE output (bo), and is the
+                            // MoE input (m.mixed) of those tokens already non-finite? Only under STRATA_DBG_NAN.
+                            {
+                                std::vector<float> ho((size_t) T * N), hx((size_t) T * N);
+                                cudaMemcpy(ho.data(), m.bo, ho.size() * 4, cudaMemcpyDeviceToHost);
+                                cudaMemcpy(hx.data(), m.mixed, hx.size() * 4, cudaMemcpyDeviceToHost);
+                                auto ranges = [&](const std::vector<float>& h, float* amax_finite) {
+                                    std::string out; int64_t start = -1, prev = -2, n = 0; float am = 0.f;
+                                    for (int64_t t = 0; t < T; ++t) {
+                                        bool bad = false;
+                                        for (int64_t j = 0; j < N; ++j) {
+                                            const float v = h[(size_t) t * N + j];
+                                            if (!std::isfinite(v)) bad = true; else am = std::max(am, std::fabs(v));
+                                        }
+                                        if (!bad) continue;
+                                        ++n;
+                                        if (t != prev + 1) {
+                                            if (start >= 0) out += std::to_string(start) + (prev > start ? "-" + std::to_string(prev) : "") + ",";
+                                            start = t;
+                                        }
+                                        prev = t;
+                                    }
+                                    if (start >= 0) out += std::to_string(start) + (prev > start ? "-" + std::to_string(prev) : "");
+                                    if (amax_finite) *amax_finite = am;
+                                    return std::to_string(n) + " [" + out + "]";
+                                };
+                                float am_x = 0.f;
+                                const std::string rbo = ranges(ho, nullptr), rx = ranges(hx, &am_x);
+                                std::fprintf(stderr, "strata dbg879: layer %lld T %lld: non-finite tokens of the MoE output %s; "
+                                             "of its input (mixed) %s; max |finite input| %.4g\n", (long long) l, (long long) T,
+                                             rbo.c_str(), rx.c_str(), (double) am_x);
+                            }
                         }
                     }
                 }

The morning's prints (attention half, MoE input, step by step, fill pattern) are larger. I can post them as a gist if
they are useful.

<!-- gh-comment-id:6131223402 --> @MKheru commented on GitHub (Oct 12, 2026): ## It follows ROCm 7.2.1's runtime libraries: same 0.1.43 source on ROCm 10.0.0, 0 fires in 1,911 requests; cross builds point at the libraries, not the compiler Thank you for running the stress script. Here is everything from one night and one day of runs on our box (about 18 hours), on your three points and on what came after them. **In short.** On our R9700, nothing in Strata's settings removes the fire, and the debug prints show bad rows written by several different kernels. The same 0.1.43 source, rebuilt and run on ROCm 10.0.0, gives **0 fires in 1,911 requests**. At the 7.2.1 rate we would have expected about 12. A cross build settles where the fault is. The engine built with 7.2.1 but run on 10.0.0's libraries gives 0 fires in 1,183 requests. The engine built with 10.0.0 but run on 7.2.1's libraries fires again within two minutes: **9 fires in 941 requests**, the 7.2.1 rate. So the fault sits in ROCm 7.2.1's runtime or libraries, not in the code the compiler makes and, as far as one card can tell, not in Strata. **Setup.** - R9700 alone (gfx1201); no other GPU used. Engines built from the `v0.1.40.2` and `v0.1.43` tags with no local change, except the debug prints described below, which only run under `STRATA_DBG_NAN`. - ROCm 7.2.1 unless noted; power limit 210 W unless noted. - Model: Swift 1.5 Qwen3.8-Flash-Next IQ3_XXS, GSQ-RCO native pack, MTP head. - Flags: `--resident-experts --pool-workers 4 --kv int8 --max-context 262144 --kv-resident 262144 --prefill 16384 --short-read 150 --prompt-cache-root 256 --spec 4 --spec-min-p 0.5`, plus `STRATA_HIP_WMMA=1`. - Load: the `stress_short_reads.py` from my previous comment. It sends reads of 195–260 new tokens on a resumed 12k–60k conversation, with 160 tokens out; about 40 % of the requests land in the 192–258 window. - Fires are counted from the engine's own `non-finite logits (#879)` lines (0.1.43) or `logits non-finite` lines (0.1.40.2). ### 1. Without the helper patch: yes, on both engines | engine (stock, R9700 only, `STRATA_DBG_NAN=1`) | duration | requests | fires | |---|---|---|---| | 0.1.40.2 | 66 min | 592 | 1 | | 0.1.43 | 93 min | 646 | 7 | 0.1.43's guard caught every fire of the night (21): no `!` reached the client. Without `STRATA_DBG_NAN`, each caught request was answered normally in 15–23 s, re-read of 15k–28k tokens included. With it, the retry took 106–440 s, because the debug checks slow the re-read to ~125 tok/s. ### 2. One setting at a time, on 0.1.43: none of them removes it | change | duration | requests | fires | |---|---|---|---| | — (0.1.43 defaults, above) | 93 min | 646 | 7 | | `STRATA_PREFILL_CPU_SHARE=0` (already off on HIP, so this repeats the default) | 64 min | 427 | 3, + 1 GPU hang | | `--pcie-frac 0` | 61 min | 586 | 2 | | power limit 300 W (the card's default) instead of 210 W | 61 min | 593 | 1 | | `--kv fp16` instead of int8 | 61 min | 336 | 4, + 1 GPU hang | | no `STRATA_DBG_NAN` (stock 0.1.43) | 82 min | 1,025 | 4, + 1 GPU hang | Durations include the engine start (1–5 min). The fire rate varies between runs (0.17–1.2 % of requests), so with these counts I can't say one engine fires more than the other. ### 3. The expert cache line, and where the bad rows are ``` strata generate: expert cache auto: 23.40 GiB free, 768 MiB reserved (+83 MiB for the draft head) -> 10404 slots strata generate: expert cache 13907 slots, 22.57 GiB of VRAM; policy is ``` (12088 slots, 19.63 GiB with `--kv fp16`.) **Only full-attention layers.** Every report came from layers 3, 7, 19, 23, 27, 31, 35, 39, 43 or 47. This model's full-attention (QSA) layers are exactly 3, 7, 11, …, 47 (read from the GGUF tensors: `attn_k`, no `ssm_*`). None of the 36 GDN layers was ever reported. **Whole tokens.** In 76 of 77 `STRATA_DBG_NAN` layer reports, every expert row of a bad token is bad: the non-finite rows of GU, H and Dm are exactly 10 × the bad tokens of `bo`. **Already bad at the MoE's input, never in the first 64 rows of the chunk.** I added one print (diff at the end) that lists the non-finite tokens of `bo` and of `m.mixed`. In 10 of 11 night fires, the same tokens are already non-finite in `m.mixed`. The 11th has a finite input, and the bad values first appear at the combine, for tokens in the same range. The finite values are small (largest |x| 3.3–10.5), so it is not an overflow. To your question: **no, the bad rows are not one group.** They come in one to twelve runs with holes, from row 64 to the end of the chunk, and never below row 64. <details><summary>The 11 night lines, verbatim</summary> ``` strata dbg879: layer 31 T 197: non-finite tokens of the MoE output 6 [66-67,69-72]; of its input (mixed) 6 [66-67,69-72]; max |finite input| 10.45 strata dbg879: layer 43 T 231: non-finite tokens of the MoE output 68 [86-116,128,131,135-153,155,157-162,164-170,229-230]; of its input (mixed) 68 [86-116,128,131,135-153,155,157-162,164-170,229-230]; max |finite input| 7.561 strata dbg879: layer 35 T 238: non-finite tokens of the MoE output 149 [64,72,76-82,84-127,130,133,137,140-200,202-224,226-227,229,232-237]; of its input (mixed) 149 [64,72,76-82,84-127,130,133,137,140-200,202-224,226-227,229,232-237]; max |finite input| 6.328 strata dbg879: layer 23 T 221: non-finite tokens of the MoE output 4 [84-86,89]; of its input (mixed) 4 [84-86,89]; max |finite input| 9.094 strata dbg879: layer 27 T 199: non-finite tokens of the MoE output 40 [158-192,194-198]; of its input (mixed) 40 [158-192,194-198]; max |finite input| 3.309 strata dbg879: layer 47 T 256: non-finite tokens of the MoE output 62 [192-253]; of its input (mixed) 62 [192-253]; max |finite input| 10.06 strata dbg879: layer 7 T 202: non-finite tokens of the MoE output 123 [73,80-201]; of its input (mixed) 123 [73,80-201]; max |finite input| 5.608 strata dbg879: layer 27 T 253: non-finite tokens of the MoE output 180 [64-91,93,95-141,143-145,147-150,153-202,204-215,217,219-252]; of its input (mixed) 180 [64-91,93,95-141,143-145,147-150,153-202,204-215,217,219-252]; max |finite input| 3.4 strata dbg879: layer 19 T 245: non-finite tokens of the MoE output 160 [79-133,136-170,172-181,183-222,224-235,237-244]; of its input (mixed) 160 [79-133,136-170,172-181,183-222,224-235,237-244]; max |finite input| 9.571 strata dbg879: layer 19 T 229: non-finite tokens of the MoE output 85 [144-228]; of its input (mixed) 85 [144-228]; max |finite input| 3.309 strata dbg879: layer 19 T 193: non-finite tokens of the MoE output 5 [67-69,72,74]; of its input (mixed) 0 []; max |finite input| 4.127 ``` </details> ### 4. Inside the attention half: three different kernels write the bad rows Next I took the attention half of the QSA layers apart, still on stock 0.1.43 with debug prints only, under the same load. There were four prints, all under `STRATA_DBG_NAN` and only for chunks of 1024 tokens or fewer: - **Attention half, end:** the non-finite tokens of every buffer of the chain (`m.mixed`, K, V, Qf, q, the indexer's two projections, the selected cells checked against `[0, p0 + t]`, `m.attn`, `m.attn_h`, `m.bo`, `m.inj`). - **MoE half, input:** the same check (`R`, its row scales, `xn16`, `lo`, `gated`, `mixed`). - **Step by step:** after each of the eleven steps of the half (K proj, V proj, Q proj, indexer projections, K norm/rope + KV append, Q split/norm/rope, indexer append, selection, attention, gate, out proj), the first step after which each buffer holds a non-finite row. - **Fill pattern:** those buffers filled with `0xFF` bytes before the half, then the rows still holding that pattern reported. It never fired: every bad row was written, with wrong values. These three debug runs lasted 14, 56 and 31 min (614 requests). The three fires that went through these prints, verbatim: ``` strata dbg879b: layer 19 T 201 p0 59199 (attention half): in 0 []; K 0 []; V 17 [69,80-95]; Qf 0 []; q 0 []; idx_raw 0 []; q_idx 0 []; ids out of range 0 []; attn 113 [85-131,133-170,172-197,199-200]; attn_h 115 [64,78,85-131,133-170,172-197,199-200]; bo 115 [64,78,85-131,133-170,172-197,199-200]; inj 0 [] strata dbg879d: layer 3 T 244 p0 26025 (attention half, step by step): V first non-finite after V proj 16 [208-223]; strata dbg879d: layer 39 T 194 p0 12254 (attention half, step by step): attn first non-finite after attention 108 [84-191]; attn_h first non-finite after gate 109 [79,84-191]; bo first non-finite after out proj 109 [79,84-191]; strata dbg879b: layer 39 T 194 p0 12254 (attention half): in 0 []; K 0 []; V 0 []; Qf 0 []; q 0 []; idx_raw 0 []; q_idx 0 []; ids out of range 0 []; attn 108 [84-191]; attn_h 109 [79,84-191]; bo 109 [79,84-191]; inj 0 [] ``` - **The half's input is always clean**, and so are K, Q and the indexer. The selected cells are always in range. - **Three different kernels write the bad rows:** - the V projection, twice (rows `[69,80-95]`, then `[208-223]` right after the V GEMM); - the attention (`[84-191]`, with clean q, K, V and selection); - the gate (rows 64 and 78 in the first fire and row 79 in the third, where `m.attn` and `Qf` are finite). - attn_k and attn_v have the same type and shape in this pack (IQ4_XS, 2560 → 512, read from the GGUF). From the same input, K comes out right and V wrong, so this is not a shape the GEMM gets wrong. - Still never a row below 64 of the chunk (14 of 14). - **It can be silent.** In the layer-3 fire, the NaN rows of V went into the int8 KV cache as finite codes. Nothing downstream was non-finite, the guard did not fire and the reply went out normally, with 16 wrong K/V cells in the cache. None of this looks like one kernel's bug. It looks like something that sometimes corrupts the rows a kernel writes in this window, below Strata. So the next step was to change the layers under it, one at a time. ### 5. One change at a time below Strata All runs use stock 0.1.43 without the debug prints, under the same load. | change | duration | requests | in the 192–258 window | fires | card hangs | |---|---|---|---|---|---| | — (ROCm 7.2.1, the night's run without `STRATA_DBG_NAN`) | 82 min | 1,025 | — | 4 | 1 | | `GPU_MAX_HW_QUEUES=1` | 30 min * | 372 | 149 | 5 | 0 | | `STRATA_DENSE_MMQ=1` (dense projections through MMQ, no hipBLAS/hipBLASLt) | 48 min * | 609 | 247 | 4 | 0 | | **ROCm 10.0.0** (HIP 7.15, hipBLASLt 1.4), engine rebuilt and run there | 126 min | **1,911** | **730** | **0** | 0 | | engine built on 7.2.1, run on **10.0.0's libraries** | 77 min | 1,183 | 511 | **0** | 0 | | engine built on 10.0.0, run on **7.2.1's libraries** | 78 min | 941 | 400 | **9** | 1 | \* Stopped by hand once they had fired 4–5 times. Stopping on fires inflates their rates; it does not change the fact that they fire. The ROCm 10.0.0 and cross runs ran their full planned length, whatever they showed. - **The 7.2.1 baseline.** The three 7.2.1 rows without debug prints give 13 fires in 2,006 requests. At that rate, ROCm 10.0.0 should have shown ~12 fires; getting 0 by chance has a probability of about 4 × 10⁻⁶. The 7.2.1-built engine on 10.0.0's libraries should have shown ~8 (probability of 0 by chance ≈ 5 × 10⁻⁴). - **Same settings throughout.** All rows use the same `--short-read 150` (checked in the generated config of each run) and the same load. - **How the cross builds were made.** Each binary comes from the other image's build directory. All shared objects (`libamdhip64.so.7`, `libhsa-runtime64.so.1`, `libhipblas.so.3`, `libhipblaslt.so.1`, `librocblas.so.5`, `libamd_comgr.so.3`) resolve from the image the binary runs in (checked with `ldd`). - **Which library, I have not isolated.** It is one of the HIP runtime, ROCr, comgr or the BLAS libraries. The `STRATA_DENSE_MMQ=1` row suggests it is not the dense GEMMs. - **Gotcha for anyone trying the official image.** `rocm/dev-ubuntu-24.04:10.0.0-full` does not put `/opt/rocm/lib` on the loader path. Our first start failed with `libhipblaslt.so.1: cannot open shared object file`; an `ld.so.conf.d` entry plus `LD_LIBRARY_PATH=/opt/rocm/lib` fixed it. - **Two changes that do nothing on this card.** `STRATA_PF_GEMM=1` would have been the obvious A/B for the GEMM, but `strata_pf_gemm_f16` returns false below gfx11's WMMA check on gfx12 (`wmma_gemm.cu:688`), so it is a no-op here. `STRATA_PROMPT_ATTN_OLD` and `STRATA_SELECT_OLD` are already the HIP defaults. **Speed on 10.0.0** (`mesure.py`, one pass each, our daily settings with `--short-read 260`): | | 7.2.1 | 10.0.0 | |---|---|---| | fresh 4k prompt read | 800 tok/s | 907 tok/s | | fresh 40k prompt read | 1,747 tok/s | 1,903 tok/s | | writing, median | 67.9 tok/s | 65.9 tok/s | The writing difference is within the noise of a single pass. ### 6. The card hangs: a separate issue, not settled - **Signature.** The hang matches ROCm/ROCm#6630 (R9700, `MES(0) failed to respond to msg=REMOVE_QUEUE`, then a MODE1 reset). That issue is open, and its author reproduces it on ROCm 6.4.4, 7.x and 10.0.0. Firmware there is MES 0x8b; here it is MES 0x93, on kernel 7.2. - **What our logs show first.** The prompt read stops making progress (`reading the prompt: … 10 s … 20 s … 30 s so far`), and the queue-removal failure comes 2.5 to 33 s after the read started. The driver message is the end of the story, not its start. Once, the engine's own watchdog named the step: `waiting for the GPU (attention, router) at layer 15`. - **Counts.** - On 7.2.1's libraries, four hangs in about 6,700 requests (the fourth during the last cross run above, with the 10.0.0-built engine; the read stalled `waiting for the GPU (attention, router) at layer 7`). - On 10.0.0's libraries, none in 3,094 requests. At the 7.2.1 rate, ~1.8 were expected (a 16 % chance of seeing none), so this hints that the hang follows the libraries too, but it does not show it. - **What ROCm/legacy-rocm-build#884 suggests.** `STRATA_HIP_ADAPT_KERNEL_COPY=1` is worth a try for that, since our setup has MMQ, adaptive swaps and SDMA together. I have not run it yet. ### 7. What I take from it - **Reach.** On gfx1201, ROCm/legacy-rocm-build#879 goes away with ROCm 10.0.0, and the 7.2.1 runtime libraries are enough to bring it back. It may be worth a line in the README for HIP users. - **For anyone who stays on 7.2.1.** 0.1.43's guard works (21 of 21 caught, ~20 s per retry without debug prints). `--short-read 260` kept the window path out of use entirely (0 fires in 770 requests in my earlier run, at no measured cost). - **The silent case.** The layer-3 case in section 4 is a reason to prefer the upgrade over the guard: with int8 KV, a fire can leave wrong cells in the cache without tripping it. - **Your no-fire run.** This may be why your R9700 saw no fire in 1,870 requests: which ROCm was that box on? If it was newer than 7.2.1, that would fit. - **Limits.** One card, one model. I did not bisect which 7.2.1 library carries it. <details><summary>The night's debug print (0.1.43, <code>src/prefill/prefill.cpp</code>, only under STRATA_DBG_NAN)</summary> ```diff --- a/src/prefill/prefill.cpp +++ b/src/prefill/prefill.cpp @@ -3920,6 +3920,38 @@ "H %lld Dm %lld bo %lld of T %lld\n", (long long) l, (int) use_mmq, mmq_gt, mmq_dt, n_order, (long long) bgu, (long long) bh, (long long) bdm, (long long) bbo, (long long) T); + // local debug (#879): which tokens of the chunk are non-finite at the MoE output (bo), and is the + // MoE input (m.mixed) of those tokens already non-finite? Only under STRATA_DBG_NAN. + { + std::vector<float> ho((size_t) T * N), hx((size_t) T * N); + cudaMemcpy(ho.data(), m.bo, ho.size() * 4, cudaMemcpyDeviceToHost); + cudaMemcpy(hx.data(), m.mixed, hx.size() * 4, cudaMemcpyDeviceToHost); + auto ranges = [&](const std::vector<float>& h, float* amax_finite) { + std::string out; int64_t start = -1, prev = -2, n = 0; float am = 0.f; + for (int64_t t = 0; t < T; ++t) { + bool bad = false; + for (int64_t j = 0; j < N; ++j) { + const float v = h[(size_t) t * N + j]; + if (!std::isfinite(v)) bad = true; else am = std::max(am, std::fabs(v)); + } + if (!bad) continue; + ++n; + if (t != prev + 1) { + if (start >= 0) out += std::to_string(start) + (prev > start ? "-" + std::to_string(prev) : "") + ","; + start = t; + } + prev = t; + } + if (start >= 0) out += std::to_string(start) + (prev > start ? "-" + std::to_string(prev) : ""); + if (amax_finite) *amax_finite = am; + return std::to_string(n) + " [" + out + "]"; + }; + float am_x = 0.f; + const std::string rbo = ranges(ho, nullptr), rx = ranges(hx, &am_x); + std::fprintf(stderr, "strata dbg879: layer %lld T %lld: non-finite tokens of the MoE output %s; " + "of its input (mixed) %s; max |finite input| %.4g\n", (long long) l, (long long) T, + rbo.c_str(), rx.c_str(), (double) am_x); + } } } } ``` </details> The morning's prints (attention half, MoE input, step by step, fill pattern) are larger. I can post them as a gist if they are useful.
Author
Owner

@cjdell commented on GitHub (Oct 13, 2026):

Another update with an admittedly LLM generated response (this is way out of my depth):


0.1.43 on a single R9700 (ROCm 7.2.3, Linux): the guard now recovers,
but it still fires ~4×/day; per-stage audit gives raw bits for every fire

Niko1221 — answering your three points from 2026-10-11, on 0.1.43 with no local
patch of any kind (no CUDA-helper patch, nothing beyond the two int8-KV clamps we
have carried since 0.1.41 — see note at the end):

  1. Yes, it still fires on 0.1.43 without any helper patch. Single R9700, HIP
    only, no second GPU involved. ROCm/legacy-rocm-build#1892's guard recovers as designed (drops the
    caches, re-reads from token 0, retries once) and never emits !, but the
    poison is still produced: 4 fires on 0.1.43 between 2026-10-12 18:19 and
    2026-10-13 12:21 BST
    (positions 102,465 / 145,770 / 163,011 / 131,417).
  2. Not yet run the STRATA_PREFILL_CPU_SHARE=0 / --pcie-frac 0 / power-limit
    A/Bs. Our current defaults: --pcie-frac is unset (so the new measured-PCIe
    default is on), STRATA_PREFILL_CPU_SHARE unset, no power-limit override.
    We can run those next if you want them before anything else.
  3. expert cache 10679 slots (24.08 GiB VRAM; 31.35 GiB page-locked in RAM).
    Our per-stage dump prints on every fire, not just the first — four fires
    below. The bits are always 0x7fc00000 (canonical positive quiet NaN),
    never the CUDA reporter's 0x7FFFFFFF.

Environment

GPU AMD Radeon AI PRO R9700 32 GB, gfx1201, single card, no helper GPU
OS / kernel NixOS, Linux 7.2.9, in-kernel amdgpu
ROCm clr 7.2.3, hipblaslt 7.2.3, hipblas 7.2.3, rocm-runtime 7.2.3, rocm-comgr 22.0.0-rocm
Engine 0.1.43 (7695859a), HIP/gfx1201, /nix/store/1s8ca3glsa0arp6hk39xnqv6sc7rkcgp-strata-0.1.43/bin/strata
Model Qwen3.8-Flash-Next UD-IQ4_XS (Unsloth), native pack
Cache 10679 GPU slots, 24.08 GiB VRAM; 31.35 GiB page-locked RAM; pre-filled from the profile
SMU fw 104.80.0 (0x00685000)

Command:

bin/strata --serve --pack /home/cjdell/Strata/pack/ud-iq4-xs --native .../Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00003.gguf
  --expert-profile .../expert-profile.bin --expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5
  --mtp /home/cjdell/Strata/mtp/rt --max-context 262144 --kv int8 --kv-resident 32768 --resident-budget-gib 55

Env: HIP_VISIBLE_DEVICES=0, HSA_USERPTR_FOR_PAGED_MEM=0, STRATA_KERNEL_AUDIT=1.

The four fires (0.1.43)

Every one is a prompt read (before the first token), CPU/miss path clean,
first poison in the GPU expert-cache HIT rows of a GDN layer, and every
non-finite value is 0x7fc00000:

Fire 1 (#879, 2026-10-13 01:36 BST, position 102,465):

layer trace: first poisoned GPU cache-hit rows at layer 20 (GDN)   [input 21]
first non-finite HIT value: row 5 (token 0, expert slot 5), col 2048, bits 0x7fc00000
kernel-stage audit: first non-finite in gate (gu kernel) of layer 47, flat 9696, bits 0x7fc00000
planned-GPU-row audit: layer 20, row 25 (token 2, slot 5), col 352, bits 0x7fc00000, expert 5
mapped miss rows: 0 of 102400 non-finite, max|x| 0.1887

Fire 2 (2026-10-13 02:23, position 145,770): cache-hit rows layer 20 (input 21);
HIT row 3 (slot 3) col 768; stage gu layer 47 flat 320; planned layer 20 row 14
(token 1, slot 4) col 1120 expert 4; miss 0/102400, max|x| 0.2536.

Fire 3 (2026-10-13 02:30, position 163,011): cache-hit rows layer 4 (input 5);
HIT row 5 (slot 5) col 1472; stage gu layer 47 flat 1056; planned layer 4 row 0
(token 0, slot 0) col 2048 expert 0; miss 0/102400, max|x| 0.3728.

Fire 4 (2026-10-13 12:21, position 131,417): cache-hit rows layer 16 (input 17);
HIT row 3 (slot 3) col 2080; stage gu layer 47 flat 384; planned layer 16 row 4
(token 0, slot 4) col 1568 expert 4; miss 0/102400, max|x| 0.3287.

Two things we'd like you to read off this

  • The bits are canonical qNaN 0x7fc00000, never 0x7FFFFFFF. On HIP the
    first non-finite is an ordinary NaN from real arithmetic in all four fires,
    not the all-0xFF INT32_MAX-shaped write the CUDA reporter sees. Our
    routed total (hits+misses) probe reads -1 (never poisoned); the CPU miss
    publish is clean every time (0 of 102,400). It is always the GPU cache-hit
    expert row write
    that first goes bad.
  • The stage audit always says "gate (gu kernel) of layer 47" while the layer
    trace names layer 4 / 16 / 20. Layer 47 is fixed across all four fires, the
    layer trace is not. Is that what you expect (the last layer's probe runs first
    / the record is last-wins), or is it a bug in the dump ordering? If it is real,
    layer 47's gu output looks like a constant first-touch point.

ROCm version note

MKheru's 2026-10-12 cross-build (0.1.43 on ROCm 10.0.0 = 0 fires; 7.2.1 libs =
fires) points squarely at the 7.2.x runtime. We are on 7.2.3 and fire the
same way, which is a third data point for "7.2.x libraries, not the compiler".
If you want a ROCm-10 run on this exact box to confirm, say so and we'll build it.

(We carry two local clamps, both still unclamped upstream: kv_q8.cu and
src/prefill/kernels.cu kv_append_kernel write amax / 127 to fp16 without a
clamp. They are on the int8-KV path and are not what closes ROCm/legacy-rocm-build#879 — flag if you
want them A/B'd off.)

<!-- gh-comment-id:6144658718 --> @cjdell commented on GitHub (Oct 13, 2026): Another update with an admittedly LLM generated response (this is way out of my depth): --- 0.1.43 on a single R9700 (ROCm 7.2.3, Linux): the guard now recovers, but it still fires ~4×/day; per-stage audit gives raw bits for *every* fire Niko1221 — answering your three points from 2026-10-11, on 0.1.43 with no local patch of any kind (no CUDA-helper patch, nothing beyond the two int8-KV clamps we have carried since 0.1.41 — see note at the end): 1. **Yes, it still fires on 0.1.43 without any helper patch.** Single R9700, HIP only, no second GPU involved. ROCm/legacy-rocm-build#1892's guard recovers as designed (drops the caches, re-reads from token 0, retries once) and never emits `!`, but the poison is still produced: **4 fires on 0.1.43 between 2026-10-12 18:19 and 2026-10-13 12:21 BST** (positions 102,465 / 145,770 / 163,011 / 131,417). 2. **Not yet run** the `STRATA_PREFILL_CPU_SHARE=0` / `--pcie-frac 0` / power-limit A/Bs. Our current defaults: `--pcie-frac` is **unset** (so the new measured-PCIe default is on), `STRATA_PREFILL_CPU_SHARE` unset, no power-limit override. We can run those next if you want them before anything else. 3. **`expert cache 10679 slots`** (24.08 GiB VRAM; 31.35 GiB page-locked in RAM). Our per-stage dump prints on **every** fire, not just the first — four fires below. **The bits are always `0x7fc00000`** (canonical positive quiet NaN), never the CUDA reporter's `0x7FFFFFFF`. ### Environment | | | |---|---| | GPU | AMD Radeon AI PRO R9700 32 GB, `gfx1201`, single card, no helper GPU | | OS / kernel | NixOS, Linux 7.2.9, in-kernel amdgpu | | ROCm | `clr` 7.2.3, `hipblaslt` 7.2.3, `hipblas` 7.2.3, `rocm-runtime` 7.2.3, `rocm-comgr` 22.0.0-rocm | | Engine | 0.1.43 (`7695859a`), HIP/gfx1201, `/nix/store/1s8ca3glsa0arp6hk39xnqv6sc7rkcgp-strata-0.1.43/bin/strata` | | Model | Qwen3.8-Flash-Next UD-IQ4_XS (Unsloth), native pack | | Cache | `10679` GPU slots, 24.08 GiB VRAM; 31.35 GiB page-locked RAM; pre-filled from the profile | | SMU fw | 104.80.0 (`0x00685000`) | Command: ``` bin/strata --serve --pack /home/cjdell/Strata/pack/ud-iq4-xs --native .../Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00003.gguf --expert-profile .../expert-profile.bin --expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --mtp /home/cjdell/Strata/mtp/rt --max-context 262144 --kv int8 --kv-resident 32768 --resident-budget-gib 55 ``` Env: `HIP_VISIBLE_DEVICES=0`, `HSA_USERPTR_FOR_PAGED_MEM=0`, `STRATA_KERNEL_AUDIT=1`. ### The four fires (0.1.43) Every one is a **prompt read** (`before the first token`), CPU/miss path clean, first poison in the **GPU expert-cache HIT rows of a GDN layer**, and every non-finite value is `0x7fc00000`: Fire 1 (`#879`, 2026-10-13 01:36 BST, position 102,465): ``` layer trace: first poisoned GPU cache-hit rows at layer 20 (GDN) [input 21] first non-finite HIT value: row 5 (token 0, expert slot 5), col 2048, bits 0x7fc00000 kernel-stage audit: first non-finite in gate (gu kernel) of layer 47, flat 9696, bits 0x7fc00000 planned-GPU-row audit: layer 20, row 25 (token 2, slot 5), col 352, bits 0x7fc00000, expert 5 mapped miss rows: 0 of 102400 non-finite, max|x| 0.1887 ``` Fire 2 (2026-10-13 02:23, position 145,770): cache-hit rows layer 20 (input 21); HIT row 3 (slot 3) col 768; stage gu layer 47 flat 320; planned layer 20 row 14 (token 1, slot 4) col 1120 expert 4; miss 0/102400, max|x| 0.2536. Fire 3 (2026-10-13 02:30, position 163,011): cache-hit rows **layer 4** (input 5); HIT row 5 (slot 5) col 1472; stage gu layer 47 flat 1056; planned layer 4 row 0 (token 0, slot 0) col 2048 expert 0; miss 0/102400, max|x| 0.3728. Fire 4 (2026-10-13 12:21, position 131,417): cache-hit rows **layer 16** (input 17); HIT row 3 (slot 3) col 2080; stage gu layer 47 flat 384; planned layer 16 row 4 (token 0, slot 4) col 1568 expert 4; miss 0/102400, max|x| 0.3287. ### Two things we'd like you to read off this - **The bits are canonical qNaN `0x7fc00000`, never `0x7FFFFFFF`.** On HIP the first non-finite is an ordinary NaN from real arithmetic in all four fires, not the all-`0xFF` `INT32_MAX`-shaped write the CUDA reporter sees. Our `routed total (hits+misses)` probe reads `-1` (never poisoned); the CPU miss publish is clean every time (0 of 102,400). It is always the **GPU cache-hit expert row write** that first goes bad. - **The stage audit always says "gate (gu kernel) of layer 47"** while the layer trace names layer 4 / 16 / 20. Layer 47 is fixed across all four fires, the layer trace is not. Is that what you expect (the last layer's probe runs first / the record is last-wins), or is it a bug in the dump ordering? If it is real, layer 47's `gu` output looks like a constant first-touch point. ### ROCm version note MKheru's 2026-10-12 cross-build (0.1.43 on ROCm 10.0.0 = 0 fires; 7.2.1 libs = fires) points squarely at the 7.2.x runtime. We are on **7.2.3** and fire the same way, which is a third data point for "7.2.x libraries, not the compiler". If you want a ROCm-10 run on this exact box to confirm, say so and we'll build it. *(We carry two local clamps, both still unclamped upstream: `kv_q8.cu` and `src/prefill/kernels.cu` `kv_append_kernel` write `amax / 127` to fp16 without a clamp. They are on the int8-KV path and are not what closes ROCm/legacy-rocm-build#879 — flag if you want them A/B'd off.)*
Author
Owner

@MKheru commented on GitHub (Oct 13, 2026):

@cjdell thanks for the 7.2.3 data, it lines up with what we see. Two things since our last comment, and one suggestion.

0.1.43.1 does not change it on 7.2.x. We built 0.1.43.1 (with ROCm/legacy-rocm-build#1996's pinned-ring prompt copies) and ran it on
ROCm 7.2.1's libraries: 1 fire in 574 requests (about 3.7 expected at the 0.1.43 rate), plus two card hangs in 62
minutes. So ROCm/legacy-rocm-build#1996 does not remove it. Our daily server stays on 0.1.43 built and run on ROCm 10.0.0, and the watcher
that reads its engine log has recorded no fire since we switched on Oct 12.

Your fires are not the same trigger as ours. Ours came from short batched prompt reads (about 193 to 256 new
tokens, IQ3_XXS). Yours come from long prompts (100K to 163K tokens, UD-IQ4_XS). Same card, same 7.2.x line, but a
different path into it. So yes, a ROCm 10 run on your box would be worth a lot: it would test whether the long-prompt
fires go away too, which our box cannot show.

How we ran ROCm 10 (a container, so it does not touch the host):

FROM docker.io/rocm/dev-ubuntu-24.04:10.0.0-full
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
      build-essential cmake git ninja-build && apt-get clean
# the official image does not register /opt/rocm/lib with the loader
# ("libhipblaslt.so.1: cannot open shared object" otherwise)
RUN printf '/opt/rocm/lib\n/opt/rocm/lib64\n' > /etc/ld.so.conf.d/rocm.conf && ldconfig
ENV LD_LIBRARY_PATH=/opt/rocm/lib

We built 0.1.43 for gfx1201 inside that image and ran it in the same image, with /dev/kfd and /dev/dri passed
through. Inside, rocm_version.h says 10.0.0, the HIP runtime is 7.15.26333 and hipBLASLt is 1.4. ROCm 10.1.0 is
out now as well; we have only tested 10.0.0.

If you want to split it the way we did: run your 7.2.3-built engine against the ROCm 10 libraries, and the
ROCm 10-built engine against 7.2.3's. On our box the fires followed the libraries both ways.

<!-- gh-comment-id:6146773836 --> @MKheru commented on GitHub (Oct 13, 2026): @cjdell thanks for the 7.2.3 data, it lines up with what we see. Two things since our last comment, and one suggestion. **0.1.43.1 does not change it on 7.2.x.** We built 0.1.43.1 (with ROCm/legacy-rocm-build#1996's pinned-ring prompt copies) and ran it on ROCm 7.2.1's libraries: 1 fire in 574 requests (about 3.7 expected at the 0.1.43 rate), plus two card hangs in 62 minutes. So ROCm/legacy-rocm-build#1996 does not remove it. Our daily server stays on 0.1.43 built and run on ROCm 10.0.0, and the watcher that reads its engine log has recorded no fire since we switched on Oct 12. **Your fires are not the same trigger as ours.** Ours came from short batched prompt reads (about 193 to 256 new tokens, IQ3_XXS). Yours come from long prompts (100K to 163K tokens, UD-IQ4_XS). Same card, same 7.2.x line, but a different path into it. So yes, a ROCm 10 run on your box would be worth a lot: it would test whether the long-prompt fires go away too, which our box cannot show. **How we ran ROCm 10 (a container, so it does not touch the host):** ``` FROM docker.io/rocm/dev-ubuntu-24.04:10.0.0-full RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ build-essential cmake git ninja-build && apt-get clean # the official image does not register /opt/rocm/lib with the loader # ("libhipblaslt.so.1: cannot open shared object" otherwise) RUN printf '/opt/rocm/lib\n/opt/rocm/lib64\n' > /etc/ld.so.conf.d/rocm.conf && ldconfig ENV LD_LIBRARY_PATH=/opt/rocm/lib ``` We built 0.1.43 for gfx1201 inside that image and ran it in the same image, with `/dev/kfd` and `/dev/dri` passed through. Inside, `rocm_version.h` says 10.0.0, the HIP runtime is 7.15.26333 and hipBLASLt is 1.4. ROCm 10.1.0 is out now as well; we have only tested 10.0.0. If you want to split it the way we did: run your 7.2.3-built engine against the ROCm 10 libraries, and the ROCm 10-built engine against 7.2.3's. On our box the fires followed the libraries both ways.
Author
Owner

@Niko1221 commented on GitHub (Oct 13, 2026):

Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.

If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.

<!-- gh-comment-id:6155976993 --> @Niko1221 commented on GitHub (Oct 13, 2026): Thanks for the report. To keep the tracker current we are closing issues older than three days: [0.1.44](https://github.com/Niko1221/Strata/releases/tag/v0.1.44) is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1. If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.
Author
Owner

@shiftonetothree commented on GitHub (Oct 19, 2026):

Reproduction, with the captured request body (the prompt and its 48 tool schemas), the launch parameters and a replay script: https://github.com/shiftonetothree/strata-879-repro - python replay.py request/request.json --port 8080 sends that body unchanged and gets the same 503.

Reproduced on a 3080 and narrowed to one path. The prompt is 18442 tokens (48 tool schemas from an agent harness). With the default MMQ prompt path the engine returns non-finite logits (#879) at the last 5-token window every time; with STRATA_PREFILL_MMQ=0 the same request answers normally. The NaN is born in layer 1's MoE gate/up, MMQ path, three prefill chunks in a row.

Environment

  • engine 0.1.45 (release exe), Windows, RTX 3080 20 GB, 96 GB RAM
  • model Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S, args: --max-context 524288 --rope-scaling yarn --rope-scale 2 --kv int8 --kv-resident 32768 --spec 4 --spec-min-p 0.5 --mtp ... --prefill auto --expert-cache auto
  • client: an OpenAI-compatible agent (DeepSeek Harness) - stream: true, 48 tools, 4 messages, max_completion_tokens: 32768, stream_options.include_usage

Reproduce

Send the captured body (18442 tokens, 48 tools) to POST /v1/chat/completions.

Expected: an answer. Actual, every time:

strata serve: non-finite logits (#879) in a prompt window at position 18437 (row 0): its tokens are not emitted, the request ends (DONE nonfinite)
strata serve: prompt 18442 tokens = 0 reused + 18437 of 18442 read in 14475 ms (1273.8 tok/s), 0 generated in 0 ms

The server retries once, the retry fires at the same position, and the client gets the 503 the model's output became non-finite (NaN) twice in a row (#879).

With STRATA_PREFILL_MMQ=0 and nothing else changed, the same body answers:

strata serve: prompt 18442 tokens = 0 reused + 18442 read in 21633 ms (852.5 tok/s), 238 generated in 5214 ms (45.6 tok/s)

So the two runs read the same prompt, at 1273.8 vs 852.5 tok/s, and only the first one ends non-finite.

Where it dies (STRATA_DBG_NAN=1, used only to locate the failure, not to measure speed - it changes timing):

strata dbg: layer 1 (mmq 1, types 22/42, 476 experts): non-finite GU 89024000 H 44512000 Dm 178048000 bo 17804800 of T 8192
strata dbg: layer 1 (mmq 1, types 22/42, 10 experts): non-finite GU 94860800 H 47430400 Dm 189721600 bo 18972160 of T 7411
strata dbg: layer 1 (mmq 1, types 22/42, 10 experts): non-finite GU 36275200 H 18137600 Dm 72550400 bo 7255040 of T 2834
strata dbg: prompt end: last residual row 10240 non-finite (max |x| 0); PLE history 0 non-finite (max |x| 14.8); GDN state 0 0 non-finite (max |x| 1.86)
strata dbg: verify window at position 18437, row 0: 248320 of 248320 logits non-finite (token out 0)

All three chunks (8192 + 7411 + 2834 = 18437), the whole gate/up output and the whole down output of layer 1, at mmq 1. PLE and the GDN state are finite there.

What I ruled out (measured, not read)

  • Model data. I scanned the whole token_embd.weight (IQ4_XS, 248320 x 2560): 0 non-finite block scales, per-row max |v| median 0.0368, p99 0.0787, p99.9 0.1211, max 0.2381. Row 96202 is normal (0.0308).
  • PLE rows. The 16 rows the poison bigram selects ( 传 = ids 220, 96202) read straight out of per_layer_token_embd.weight: max |v| 0.019 to 0.033, block scales ~1e-4, like their neighbours.
  • KV int8. --kv int8 is in both runs above, so its quantizer is not the site.
  • The conversation cache. The first pass reports 0 reused, and the guard drops the session before the retry.
  • "prompt is just long". An 18380-token plain-text prompt and a 17877-token prompt with 72 tool schemas both answer with MMQ on.

The trigger is content, not length

Bisecting the captured body with MMQ on: dropping all 48 tools still fails; keeping only the system message and 你好 still fails. The smallest reducer I found is a system text that ends in 传 preceded by a space token (ids 220, 96202). As the whole system message, "x 传", " 传" and "abcdefgh 传" reproduce it; "传", "传传", "a传", "\n传" and " 转" do not. Caveat: that reducer only fires against a warm engine (a cached prefix); from a cold engine the same 58-token prompt passes. So the token path is not fully understood yet - the reliable reproducer remains the full 18442-token body.

Candidate sites (static reading, unverified: I cannot build here - nvcc 13.4 is present, cmake and MSVC are not)

  1. quantize_mmq_q8_1 in the vendored ggml-cuda/quantize.cu, DS4 layout: it writes d = amax/127 and the 32-value sum through make_half2, i.e. into fp16. d is inf above amax 8.32e6, and a sum of 32 same-sign values overflows 65504 earlier than that. Both are a clamp away from being finite. Which of the two actually overflows needs one measurement of the activation magnitude at the failing layer.
  2. The MMQ prompt path's borrowed expert slots (mmq_plan() in src/prefill/prefill.cpp, the 2466 CUDA0 slots the prompt borrows). STRATA_MMQ_DIRECT=1, STRATA_MMQ_GROUP_SORT=0/1 and --prefill 2048 are the three switches that separate this from (1) without a build.
  3. While there: the KV int8 quantizer in src/prefill/kernels.cu (hf(amax / 127)) has the same unclamped fp16 scale. Not this failure (see above), but the same class.

Workaround in use

set STRATA_PREFILL_MMQ=0 before starting the server. Cost measured here on the same 18442-token prompt: 852.5 vs 1273.8 tok/s of prompt read (21633 vs 14475 ms), i.e. about 30% slower prefill; short prompts are unaffected. Answers from the FP16 prompt path are not bit-identical to the MMQ path, which is expected.

Reproduction status

Reproduced locally: 4 failing requests across 3 engine starts of the same build, and 2 passes with MMQ off on the same body. The two candidate sites are unconfirmed static analysis; I have not built the engine.

<!-- gh-comment-id:6278026795 --> @shiftonetothree commented on GitHub (Oct 19, 2026): Reproduction, with the captured request body (the prompt and its 48 tool schemas), the launch parameters and a replay script: https://github.com/shiftonetothree/strata-879-repro - `python replay.py request/request.json --port 8080` sends that body unchanged and gets the same 503. Reproduced on a 3080 and narrowed to one path. The prompt is 18442 tokens (48 tool schemas from an agent harness). With the default MMQ prompt path the engine returns `non-finite logits (#879)` at the last 5-token window every time; with `STRATA_PREFILL_MMQ=0` the same request answers normally. The NaN is born in layer 1's MoE gate/up, MMQ path, three prefill chunks in a row. **Environment** - engine 0.1.45 (release exe), Windows, RTX 3080 20 GB, 96 GB RAM - model `Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S`, args: `--max-context 524288 --rope-scaling yarn --rope-scale 2 --kv int8 --kv-resident 32768 --spec 4 --spec-min-p 0.5 --mtp ... --prefill auto --expert-cache auto` - client: an OpenAI-compatible agent (DeepSeek Harness) - `stream: true`, 48 tools, 4 messages, `max_completion_tokens: 32768`, `stream_options.include_usage` **Reproduce** Send the captured body (18442 tokens, 48 tools) to `POST /v1/chat/completions`. Expected: an answer. Actual, every time: ``` strata serve: non-finite logits (#879) in a prompt window at position 18437 (row 0): its tokens are not emitted, the request ends (DONE nonfinite) strata serve: prompt 18442 tokens = 0 reused + 18437 of 18442 read in 14475 ms (1273.8 tok/s), 0 generated in 0 ms ``` The server retries once, the retry fires at the same position, and the client gets the 503 `the model's output became non-finite (NaN) twice in a row (#879)`. With `STRATA_PREFILL_MMQ=0` and nothing else changed, the same body answers: ``` strata serve: prompt 18442 tokens = 0 reused + 18442 read in 21633 ms (852.5 tok/s), 238 generated in 5214 ms (45.6 tok/s) ``` So the two runs read the same prompt, at 1273.8 vs 852.5 tok/s, and only the first one ends non-finite. **Where it dies** (`STRATA_DBG_NAN=1`, used only to locate the failure, not to measure speed - it changes timing): ``` strata dbg: layer 1 (mmq 1, types 22/42, 476 experts): non-finite GU 89024000 H 44512000 Dm 178048000 bo 17804800 of T 8192 strata dbg: layer 1 (mmq 1, types 22/42, 10 experts): non-finite GU 94860800 H 47430400 Dm 189721600 bo 18972160 of T 7411 strata dbg: layer 1 (mmq 1, types 22/42, 10 experts): non-finite GU 36275200 H 18137600 Dm 72550400 bo 7255040 of T 2834 strata dbg: prompt end: last residual row 10240 non-finite (max |x| 0); PLE history 0 non-finite (max |x| 14.8); GDN state 0 0 non-finite (max |x| 1.86) strata dbg: verify window at position 18437, row 0: 248320 of 248320 logits non-finite (token out 0) ``` All three chunks (8192 + 7411 + 2834 = 18437), the whole gate/up output and the whole down output of layer 1, at `mmq 1`. PLE and the GDN state are finite there. **What I ruled out** (measured, not read) - Model data. I scanned the whole `token_embd.weight` (IQ4_XS, 248320 x 2560): 0 non-finite block scales, per-row max |v| median 0.0368, p99 0.0787, p99.9 0.1211, max 0.2381. Row 96202 is normal (0.0308). - PLE rows. The 16 rows the poison bigram selects (` 传` = ids 220, 96202) read straight out of `per_layer_token_embd.weight`: max |v| 0.019 to 0.033, block scales ~1e-4, like their neighbours. - KV int8. `--kv int8` is in both runs above, so its quantizer is not the site. - The conversation cache. The first pass reports `0 reused`, and the guard drops the session before the retry. - "prompt is just long". An 18380-token plain-text prompt and a 17877-token prompt with 72 tool schemas both answer with MMQ on. **The trigger is content, not length** Bisecting the captured body with MMQ on: dropping all 48 tools still fails; keeping only the system message and `你好` still fails. The smallest reducer I found is a system text that ends in `传` preceded by a space token (ids 220, 96202). As the whole system message, `"x 传"`, `" 传"` and `"abcdefgh 传"` reproduce it; `"传"`, `"传传"`, `"a传"`, `"\n传"` and `" 转"` do not. Caveat: that reducer only fires against a warm engine (a cached prefix); from a cold engine the same 58-token prompt passes. So the token path is not fully understood yet - the reliable reproducer remains the full 18442-token body. **Candidate sites (static reading, unverified: I cannot build here - nvcc 13.4 is present, cmake and MSVC are not)** 1. `quantize_mmq_q8_1` in the vendored `ggml-cuda/quantize.cu`, DS4 layout: it writes `d = amax/127` and the 32-value `sum` through `make_half2`, i.e. into fp16. `d` is inf above `amax` 8.32e6, and a sum of 32 same-sign values overflows 65504 earlier than that. Both are a clamp away from being finite. Which of the two actually overflows needs one measurement of the activation magnitude at the failing layer. 2. The MMQ prompt path's borrowed expert slots (`mmq_plan()` in `src/prefill/prefill.cpp`, the 2466 CUDA0 slots the prompt borrows). `STRATA_MMQ_DIRECT=1`, `STRATA_MMQ_GROUP_SORT=0/1` and `--prefill 2048` are the three switches that separate this from (1) without a build. 3. While there: the KV int8 quantizer in `src/prefill/kernels.cu` (`hf(amax / 127)`) has the same unclamped fp16 scale. Not this failure (see above), but the same class. **Workaround in use** `set STRATA_PREFILL_MMQ=0` before starting the server. Cost measured here on the same 18442-token prompt: 852.5 vs 1273.8 tok/s of prompt read (21633 vs 14475 ms), i.e. about 30% slower prefill; short prompts are unaffected. Answers from the FP16 prompt path are not bit-identical to the MMQ path, which is expected. **Reproduction status** Reproduced locally: 4 failing requests across 3 engine starts of the same build, and 2 passes with MMQ off on the same body. The two candidate sites are unconfirmed static analysis; I have not built the engine.
Author
Owner

@shiftonetothree commented on GitHub (Oct 20, 2026):

Same hardware with Ubuntu 26.04 work very well.

<!-- gh-comment-id:6294929135 --> @shiftonetothree commented on GitHub (Oct 20, 2026): Same hardware with Ubuntu 26.04 work very well.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#385
No description provided.