[GH-ISSUE #267] GLM router layer 43: deterministic non-finite scores / invalid expert IDs at ~409K context (IQ3_S, 2x gfx1201, 1M ctx, RAM tier + NVMe streaming) - NaN guard retries from token 0 forever #97

Open
opened 2026-10-29 21:20:47 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @eugenrepp on GitHub (Oct 18, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/267

Environment

Maya v1.1.15 (commit a4e1ff0), HIP source build
Model GLM-5.3-Flash, Maya-L IQ3_S (156.3 GB, 4 shards), --glm-pack Maya-L/pack
GPUs 2x AMD AI PRO R9700 (gfx1201), layer split [0,24) / [24,45), ~55% of routed experts in VRAM
ROCm 7.2.4 (hipBLASLt tuning table for gfx1201 loaded)
Host 123 GB RAM, NVMe; cold experts streamed from SSD (RAM tier capped at 80 GB)
Engine args --glm-pack .../Maya-L/pack --max-context 1048576 --expert-cache auto --prefill auto --kv-streaming on --expert-profile expert-profile-glm.bin --kv int8 --kv-resident 32768
Env STRATA_GLM_RAM_GB=80, STRATA_GLM_RESERVE_MB=4096, STRATA_GLM_RAM_HEADROOM_GB=16, STRATA_GLM_PREFILL_SUB=1024, STRATA_GLM_PREFILL_MB=4096
OS Linux, kernel 7.0.0-38-generic

What happened

An agentic session (multi-turn, tool calls, thinking on) was running on a 1M-context
instance. Decode was healthy at ~409K context (16-18 tok/s, spec drafts 58-100%
accepted, disk 3.7-7.6 reads/tok). Then:

  1. First fire during decode, after 52 emitted tokens (~409,186-token prompt):
glm nan guard: glm router: layer 43 decode invalid expert ID or non-finite score - this conversation's state is dropped; it is read again from token 0
[maya] done: 52 tokens in 8 s (16.4 tok/s) (length, cancel=False)
  1. The server's automatic retry from token 0 fails during the prompt read, deterministically:
glm nan guard: glm router: prompt layer 43 invalid expert ID or non-finite score (13768 of 65536 routes) - ...
glm nan guard: glm router: prompt layer 43 invalid expert ID or non-finite score (13864 of 65536 routes) - ...
  1. Every further retry fails identically. The guard fired 37x in total
    (1x decode, 36x prompt); from the second retry on, every fire reports exactly
    13864 of 65536 routes. The request ends with 0 tokens:
[maya] the engine reported an error: glm router: prompt layer 43 invalid expert ID or non-finite score (13864 of 65536 routes)
[maya] done: 0 tokens in 24 s (0.0 tok/s) (error, cancel=False)

Key properties

  • Deterministic in content, not transient. The identical count (13864 of
    65536) reproduced on every retry-from-0. Resending is futile.
  • 65,536 = one 8192-token prompt chunk x 8 routed experts per token.
    13,864 invalid routes = 21% - whole token rows of layer 43 are affected, so
    the non-finite values are present in the state the router reads, not a rare
    scoring outlier.
  • The engine stays healthy otherwise: small requests on the same instance
    answered normally throughout; no crash, no illegal memory access.
  • Layer 43 is a mid-trunk layer (trunk is 0..44); both fires name the same
    layer, which is not the last one - consistent with the poison being in the
    recurrent/KDA state or the streamed-expert path rather than the head.
  • Did not reproduce/error on other instances - but honestly: the same
    conversation was never replayed on them. A 262K instance (v1.1.13,
    STRATA_GLM_RAM_GB=106, all experts in RAM, no SSD streaming) ran a day of
    similar workload without this error (it had an unrelated #29 no-progress
    hang once); the 512K instances never received a prompt of this size.

Notes from reading the source (v1.1.15)

  • route_kernel (glm_batch.cu) already checks isfinite on logits and
    bias-adjusted scores and writes ids = -1 for affected tokens; the host-side
    count mismatch in glm_prefill.cu is what produces the "N of 65536 routes"
    message. So the report is: non-finite values reach layer 43's router input
    at a fixed position, deterministically.
  • This looks like the GLM-engine sibling of Niko1221/Strata#2519 (recurrent
    state overflow -> residual -> non-finite) and Strata#2452 (deterministic
    non-finite at a fixed prompt position on long context). Happy to add data.

What I can provide

  • The full engine log (glm stat / glm spec / glm kv lines around every
    fire) and the wrapper log.
  • A fresh 409K+ prompt of different content was not tried yet; the instance
    now runs capped at 512K. If useful, I can spin up a test instance and bisect
    the context threshold.
Originally created by @eugenrepp on GitHub (Oct 18, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/267 ## Environment | | | |---|---| | Maya | v1.1.15 (commit a4e1ff0), HIP source build | | Model | GLM-5.3-Flash, Maya-L IQ3_S (156.3 GB, 4 shards), `--glm-pack Maya-L/pack` | | GPUs | 2x AMD AI PRO R9700 (gfx1201), layer split [0,24) / [24,45), ~55% of routed experts in VRAM | | ROCm | 7.2.4 (hipBLASLt tuning table for gfx1201 loaded) | | Host | 123 GB RAM, NVMe; cold experts streamed from SSD (RAM tier capped at 80 GB) | | Engine args | `--glm-pack .../Maya-L/pack --max-context 1048576 --expert-cache auto --prefill auto --kv-streaming on --expert-profile expert-profile-glm.bin --kv int8 --kv-resident 32768` | | Env | `STRATA_GLM_RAM_GB=80`, `STRATA_GLM_RESERVE_MB=4096`, `STRATA_GLM_RAM_HEADROOM_GB=16`, `STRATA_GLM_PREFILL_SUB=1024`, `STRATA_GLM_PREFILL_MB=4096` | | OS | Linux, kernel 7.0.0-38-generic | ## What happened An agentic session (multi-turn, tool calls, thinking on) was running on a 1M-context instance. Decode was healthy at ~409K context (16-18 tok/s, spec drafts 58-100% accepted, disk 3.7-7.6 reads/tok). Then: 1. **First fire during decode, after 52 emitted tokens** (~409,186-token prompt): ``` glm nan guard: glm router: layer 43 decode invalid expert ID or non-finite score - this conversation's state is dropped; it is read again from token 0 [maya] done: 52 tokens in 8 s (16.4 tok/s) (length, cancel=False) ``` 2. **The server's automatic retry from token 0 fails during the prompt read, deterministically:** ``` glm nan guard: glm router: prompt layer 43 invalid expert ID or non-finite score (13768 of 65536 routes) - ... glm nan guard: glm router: prompt layer 43 invalid expert ID or non-finite score (13864 of 65536 routes) - ... ``` 3. **Every further retry fails identically.** The guard fired 37x in total (1x decode, 36x prompt); from the second retry on, every fire reports exactly `13864 of 65536 routes`. The request ends with 0 tokens: ``` [maya] the engine reported an error: glm router: prompt layer 43 invalid expert ID or non-finite score (13864 of 65536 routes) [maya] done: 0 tokens in 24 s (0.0 tok/s) (error, cancel=False) ``` ## Key properties - **Deterministic in content, not transient.** The identical count (13864 of 65536) reproduced on every retry-from-0. Resending is futile. - **65,536 = one 8192-token prompt chunk x 8 routed experts per token.** 13,864 invalid routes = 21% - whole token rows of layer 43 are affected, so the non-finite values are present in the state the router reads, not a rare scoring outlier. - **The engine stays healthy otherwise:** small requests on the same instance answered normally throughout; no crash, no illegal memory access. - Layer 43 is a mid-trunk layer (trunk is 0..44); both fires name the same layer, which is not the last one - consistent with the poison being in the recurrent/KDA state or the streamed-expert path rather than the head. - Did **not** reproduce/error on other instances - but honestly: the same conversation was never replayed on them. A 262K instance (v1.1.13, `STRATA_GLM_RAM_GB=106`, all experts in RAM, no SSD streaming) ran a day of similar workload without this error (it had an unrelated #29 no-progress hang once); the 512K instances never received a prompt of this size. ## Notes from reading the source (v1.1.15) - `route_kernel` (glm_batch.cu) already checks `isfinite` on logits and bias-adjusted scores and writes `ids = -1` for affected tokens; the host-side count mismatch in glm_prefill.cu is what produces the "N of 65536 routes" message. So the report is: non-finite values reach layer 43's router input at a fixed position, deterministically. - This looks like the GLM-engine sibling of Niko1221/Strata#2519 (recurrent state overflow -> residual -> non-finite) and Strata#2452 (deterministic non-finite at a fixed prompt position on long context). Happy to add data. ## What I can provide - The full engine log (`glm stat` / `glm spec` / `glm kv` lines around every fire) and the wrapper log. - A fresh 409K+ prompt of different content was not tried yet; the instance now runs capped at 512K. If useful, I can spin up a test instance and bisect the context threshold.
Author
Owner

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

Reproduced on the 512K instance — occurs earlier than ~409K

Reproduced on the 512K instance (config maya-l-512k-80-hip-vision.json, same HW, Maya v1.1.15, started 18.10., no restart since):

At 191,457-token prompts (37 % of the 512K window) the same non-finite scores appear in layer 44 (the last layer):

  • 1× decode event: NaN after 111 decode tokens
  • then prompt layer 44 … (1368 of 65536 routes) — deterministically on every re-read from token 0 (13 consecutive requests, each done: 0 tokens in ~24 s, error), until the client gave up (max_retries_exhausted)
  • a single earlier event appeared at layer 12 with a 141,629-token prompt (decode, after 451 tokens); the following small requests ran fine again

Small prompts work fine — the engine stays alive, only the poisoned long prompt is deterministic.

The 512K context cap is therefore not a reliable workaround, and the trigger threshold is lower than the ~409K originally reported. Logs and a client request dump are on file; happy to provide more detail if useful.

<!-- gh-comment-id:6291129496 --> @eugenrepp commented on GitHub (Oct 20, 2026): ## Reproduced on the 512K instance — occurs earlier than ~409K Reproduced on the 512K instance (config `maya-l-512k-80-hip-vision.json`, same HW, Maya v1.1.15, started 18.10., no restart since): At **191,457-token prompts** (37 % of the 512K window) the same non-finite scores appear in **layer 44** (the last layer): - 1× decode event: NaN after 111 decode tokens - then `prompt layer 44 … (1368 of 65536 routes)` — deterministically on every re-read from token 0 (13 consecutive requests, each `done: 0 tokens in ~24 s, error`), until the client gave up (`max_retries_exhausted`) - a single earlier event appeared at **layer 12** with a **141,629-token** prompt (decode, after 451 tokens); the following small requests ran fine again Small prompts work fine — the engine stays alive, only the poisoned long prompt is deterministic. **The 512K context cap is therefore not a reliable workaround**, and the trigger threshold is lower than the ~409K originally reported. Logs and a client request dump are on file; happy to provide more detail if useful.
Author
Owner

@tellmewhattodo commented on GitHub (Oct 23, 2026):

A different trigger path: short context + non-deterministic + recoverable

Reporting a second shape of this guard, because it appears to be the case the report above explicitly calls healthy.

What we saw

The same guard fires, but at a short context:

glm router: layer 44 decode invalid expert ID or non-finite score
glm router: layer 38 prompt invalid expert ID or non-finite score (80 of 1200 routes)

Environment

Maya v1.1.21 (commit 451f9cb), CUDA 13.0 source build
Model GLM-5.3-Flash via --glm-pack
GPUs 2x NVIDIA Blackwell (sm_120), layer split across both
Engine args --glm-pack ... --max-context 32768 --expert-cache auto --prefill auto --kv-streaming on --expert-profile ...
Env a CPU-lane thread count only; no routing-affinity variable set
Engine source unmodified (clean git diff on the router and state files)

Why this looks like a separate path from the report above

report above this one
Prompt length ~409K / 191K / 141K tokens short (--max-context 32768)
Reproducibility deterministic: re-reading from token 0 fails again with the identical count non-deterministic: the same prompt succeeds most times
After a fire conversation permanently unusable; 37 consecutive retries failed the next run is fine; no restart needed
Frequency every re-read 2 failures in 14 runs
Hardware 2x AMD R9700 (gfx1201, ROCm) 2x NVIDIA Blackwell (sm_120, CUDA 13.0)
Version v1.1.15 v1.1.21

The report above states: "Small prompts work fine — the engine stays alive, only the poisoned long prompt is deterministic." What we see is a failure in exactly that regime.

What the guard is actually checking

Reading the routing kernel, the check is:

s_sel[e] = a.bias ? p + a.bias[e] : p;
if (a.affinity > 0.0f && ...) s_sel[e] += a.affinity;
if (!isfinite(a.logits[e]) || !isfinite(s_sel[e])) atomicMax(&bad, 1);

With no affinity set, s_sel reduces to a sigmoid of logits, so the condition reduces to the router's raw logits already being non-finite — not a rare scoring outlier at selection time. That is consistent with the report above (whole token rows affected), and is why this does not look like a scheduling or expert-placement problem on our side.

Questions

  1. Is the short-context, non-deterministic shape plausibly the same underlying cause as the long-context deterministic one, or a different one?
  2. If different: are there known conditions under which the router logits go non-finite at short context? We have not found one.
  3. Given ours is recoverable (a plain re-run succeeds), is "retry once" the intended handling, versus the non-recoverable case above where retrying from token 0 is futile?

Caveat

We did not keep the raw engine log for the failing runs, and we have not yet attempted to reproduce on current main. We can try to reproduce with full logs capture on request. Frequency is 2/14, so we cannot estimate a rate.

<!-- gh-comment-id:6370936666 --> @tellmewhattodo commented on GitHub (Oct 23, 2026): ## A different trigger path: short context + non-deterministic + recoverable Reporting a second shape of this guard, because it appears to be the case the report above explicitly calls healthy. ### What we saw The same guard fires, but at a **short** context: ``` glm router: layer 44 decode invalid expert ID or non-finite score glm router: layer 38 prompt invalid expert ID or non-finite score (80 of 1200 routes) ``` ### Environment | | | |---|---| | Maya | v1.1.21 (commit 451f9cb), CUDA 13.0 source build | | Model | GLM-5.3-Flash via `--glm-pack` | | GPUs | 2x NVIDIA Blackwell (sm_120), layer split across both | | Engine args | `--glm-pack ... --max-context 32768 --expert-cache auto --prefill auto --kv-streaming on --expert-profile ...` | | Env | a CPU-lane thread count only; no routing-affinity variable set | | Engine source | **unmodified** (clean `git diff` on the router and state files) | ### Why this looks like a separate path from the report above | | report above | this one | |---|---|---| | Prompt length | ~409K / 191K / 141K tokens | **short** (`--max-context 32768`) | | Reproducibility | **deterministic**: re-reading from token 0 fails again with the identical count | **non-deterministic**: the same prompt succeeds most times | | After a fire | conversation permanently unusable; 37 consecutive retries failed | **the next run is fine**; no restart needed | | Frequency | every re-read | **2 failures in 14 runs** | | Hardware | 2x AMD R9700 (gfx1201, ROCm) | 2x NVIDIA Blackwell (sm_120, CUDA 13.0) | | Version | v1.1.15 | v1.1.21 | The report above states: *"Small prompts work fine — the engine stays alive, only the poisoned long prompt is deterministic."* What we see is a failure in exactly that regime. ### What the guard is actually checking Reading the routing kernel, the check is: ```cuda s_sel[e] = a.bias ? p + a.bias[e] : p; if (a.affinity > 0.0f && ...) s_sel[e] += a.affinity; if (!isfinite(a.logits[e]) || !isfinite(s_sel[e])) atomicMax(&bad, 1); ``` With no affinity set, `s_sel` reduces to a sigmoid of `logits`, so the condition reduces to **the router's raw logits already being non-finite** — not a rare scoring outlier at selection time. That is consistent with the report above (whole token rows affected), and is why this does not look like a scheduling or expert-placement problem on our side. ### Questions 1. Is the short-context, non-deterministic shape plausibly the **same** underlying cause as the long-context deterministic one, or a different one? 2. If different: are there known conditions under which the router logits go non-finite at short context? We have not found one. 3. Given ours is recoverable (a plain re-run succeeds), is "retry once" the intended handling, versus the non-recoverable case above where retrying from token 0 is futile? ### Caveat We did not keep the raw engine log for the failing runs, and we have not yet attempted to reproduce on current `main`. We can try to reproduce with full logs capture on request. Frequency is 2/14, so we cannot estimate a rate.
Sign in to join this conversation.
No labels
pull-request
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
mw00/project-maya#97
No description provided.