STRIX_LEAN long-context numbers from my GTR9 Pro — plus two small questions when you have a moment

#6
by liusecret - opened

Thanks again — your STRIX_LEAN build is what lets my GTR9 Pro (Ryzen AI Max+ 395 / gfx1151, 128 GB unified, ROCm 7.2.4, kingjones30/ROCmFPX build) run a 177B-parameter model at full 256K. Nothing below needs a reply — just reporting back data and a couple of curiosities.

Measured, aligned to your card

Config: -dev ROCm0 -ngl 999 -fa on -fit off -t 16 -c 262144 -np 1 -ub 512 (default), KV q8_0, embedded template
prefill: 349.8 t/s, generation: 20.11 t/s, RSS: 70.1 GiB (256K context, long prompt, median)

Slightly above your reference on prefill, matching gen at depth, memory in the same band. And your ub finding holds — default 512 is right on this arch, nothing to sweep.

One curiosity about MTP
Your discussion #5 explained the converter drops the head and it needs graph support. I then saw Baekpica's ds4 runtime has Flash-Next's embedded MTP working end-to-end on DGX Spark — target-verified acceptance with rollback and auto-quench, ~+21% decode, acceptance in the high 80s. That made me wonder whether the hyper-connection stack is more portable than it looked, and whether llama.cpp-side support is on your radar. Genuinely just curious about your take — your 27B MTP head was worth +29% to me once the spec flags were right, so I'd expect NEXT to benefit similarly if it ever happens.

And a very low-priority thought
If you ever get bored of the STRIX_LEAN PLE tier — an uncensored STRIX (PLE Q8_0) would be a strict upgrade for the disk cost, per your own tier data (same GTT, same speed, better quality). Only if it's ever worth your time.

If another datapoint would help
If you'd like a second box on the depth ladder at some point (STRIX_LEAN + q8 KV + chat endpoint, vs lawjay's STRIX/raw), I'm happy to help — but no need if what you have already settles it. Decision's yours.

Thanks for everything — happy to run any A/B you want in return.

Thanks — this is the depth data I asked for, and it lands where it should. 349.8 t/s prefill is above my reference band (283–334 on ~3k prompts), 70.1 GiB at 256K sits right on my GTT curve (64.6 GiB at 32k → 73.7 at 262k), and your ub result matches mine. Good to have a second box confirm it.

On MTP — the status moved since #5, and I've published what I have so you can poke at it yourself:

https://huggingface.co/kingjones777/Qwen3.8-Flash-Next-MTP-Heads-GGUF

⛔ Fair warning up front: they don't load. Don't pull them expecting speed. But the reason turns out to be more specific than "no graph support," which is exactly why I'd rather have them in the open than sitting on my box.

In #5 I said our converter drops the head. That part is fixed — five heads in there, BF16 master plus Q4_0 ROCmFP4 FAST and STRIX, Q4_K_M and Q6_K. And the tensors are not missing. Every head carries all 35, including the exact one the loader complains about:

llama_model_load: error loading model: missing tensor 'blk.0.hc_attn_norm.weight'

while the file contains blk.48.hc_attn_norm.weight [10240] — along with the whole hc_attn_* / hc_ffn_* / output_hc_* stack, the nextn.* block, and the QSA indexer projections.

It's the layer index. The converter writes the MTP block at its absolute position in the parent model (48); the head's own metadata declares qwen4exp.block_count = 1, so the loader builds a single layer at index 0 and looks for blk.0.*.

What I have not proven is that renumbering is sufficient. Renaming fixes the lookup, but the qwen4exp graph still has to build the hyper-connection and nextn ops for a draft model, and I haven't shown that it does. What stopped me testing it quickly was tooling, not the model: stock gguf-py won't rewrite the ROCmFP4 tiers (bytes per row (2560) is not a multiple of Q4_0_ROCMFP4_FAST type size (17)), and my hand-rolled BF16 repack came out malformed. So the honest state is promising and unverified — and if you get a renumbered head to load, that's the most useful thing anyone could post.

It does line up with what you're seeing on ds4: the math is portable, it's the llama.cpp-side plumbing that's missing. If that runtime is consuming the embedded head successfully, the index convention is the first thing I'd diff.

Meanwhile --spec-type ngram-mod is worth running on Flash-Next — on ROCm acceptance is 0.750 on code, 1.000 on prose. Not on Vulkan/gfx1151: same config, it collapses to 0.000 / 0.188.

Uncensored STRIX (PLE Q8_0) — reasonable ask, it's on the list, no date promised.

On the A/B — yes, and here's the one I'd take. You have the only 256K numbers anyone has posted, so: the depth ladder on STRIX_LEAN — pp/gen and GTT resident at 32k / 64k / 128k / 256k, and whether ngram-mod acceptance holds as depth grows. Acceptance at depth is the number nobody has, and it decides whether spec decode is worth anything in a long coding session.

Thanks again for the build and for the patience. I've completed the depth ladder on STRIX_LEAN (gfx1151, ROCm 7.2.4, kingjones30/ROCmFPX build, 128 GB) and hit two distinct crashes along the way. Full data and repro details below — the crash logs are the most useful thing I can hand you, so they come first.

Environment / config

-dev ROCm0 -ngl 999 -fa 1 -fit off -t 16 -c 262144 -np 1 -ub 512
KV q8_0/q8_0, embedded template, reasoning_effort: low, temperature 0, Chinese investment-analysis corpus (Chinese text touches the PLE n-gram table differently than your source-code corpus — worth keeping in mind when comparing to your numbers)
  1. Baseline (no speculation) depth ladder — all four rungs completed
    depth prompt_n pp t/s gen t/s RSS
    32K 26,180 345.5 19.77 69.9 GiB
    64K 52,280 302.8 16.36 70.4 GiB
    128K 104,480 225.5 11.92 71.3 GiB
    256K 208,880 149.5 7.64 73.0 GiB

pp is above your reference at every rung; gen matches at 32K then falls off more steeply than your card — I attribute most of that delta to the Chinese corpus (different n-gram/PLE hit distribution) plus prompt depth. RSS tracks your GTT curve (69.9 → 73.0 GiB), so memory behaviour reproduces your findings exactly qwen4exp_crash.log.

  1. ngram-mod — works at 32K (better than plain!), crashes at 64K

    32K: pp 340.6, gen 17.8 t/s — acceptance strong (acc rate/pos 1.000 across positions), so ngram-mod is helping at this depth on ROCm, reproducing your "0.75/1.000 on ROCm" claim at least at 32K.
    64K: prefill completes (246.3 t/s, 52,280 tok), then crash. Sequence from the log:
    slot restores a context checkpoint, then discards an invalidated one
    speculative replay stalled at pos 52289 (2 consecutive checkpoint restores) - dropping draft, decoding without speculation
    plain decode runs ~100 tokens at 19.38 t/s (so decode itself is fine)
    then: ROCm error: unspecified launch failure → hipMemcpyAsync(D2H) → abort, core dumped

So: ngram-mod + QSA checkpoint-restore path is unstable past ~32K on this build — the replay-stall/restore loop corrupts something, and the crash surfaces at the HIP memcpy layer during subsequent decode, not inside the ngram matcher itself. I have the full log. This is the "acceptance at depth" answer you asked for, in an unfortunate form: the answer is "it doesn't survive depth in the current build."

  1. Second crash — identical-prompt re-request hits common_context_seq_rm

Before I found the mid-prompt workaround, a second request with a prompt identical to the slot contents asserted:

slot update_slots: id 0 | task 19 | n_past was set to 26179
common/common.cpp:1514: failed to remove sequence 0 with p0=26179, p1=-1

Trigger: sim_best = 1.000 (LCP match) → full-reuse branch → n_past == task.n_tokens() → assert in common_context_seq_rm. Reproduces with cache_prompt on/off and with a trailing-token difference (template swallowed the trailing whitespace). Workaround that worked: add a mid-prompt wording difference to the second request (keeps the prefix identical for reuse, but f_keep < 1.000, so the reuse branch doesn't hit the assert). Worth a look at the QSA hybrid-index path — this feels like the "identical re-request" case isn't covered.

  1. Separate: mlock fails on NEXT

warning: failed to mlock 39373176832-byte buffer: Cannot allocate memory

~37 GiB weight buffer exceeds the default RLIMIT_MEMLOCK on this box, so --mlock is silently ineffective on NEXT (worked fine on your 27B/A3B builds at 18-23 GiB). Anyone running NEXT with --mlock should know it's not locking. I removed --mlock for the runs above.

Next step from me: once you've had a chance to look at the two crash logs, I'll continue the ngram depth runs (64K/128K/256K) with whatever workaround you suggest — or with a fresh-server-per-rung approach to sidestep the checkpoint-restore path, and report acceptance at depth if it survives. Both crash logs available on request; happy to run any A/B that would help you isolate them.

Thanks for building this — it's genuinely the most capable thing I've run on the 395.

Here's the complete report from my GTR9 Pro testing of your Qwen3.8-Flash-Next-Uncensored-ROCmFP4-STRIX_LEAN across the last week. Baseline data is complete and reproducible; the speculation depth test exposed what I believe is a hardware-level stability issue worth your attention before anyone else hits it.

Environment
GTR9 Pro: Ryzen AI Max+ 395 / Radeon 8060S gfx1151, 128 GB unified, ROCm 7.2.4
kingjones30/ROCmFPX build, -dev ROCm0 -ngl 999 -fa 1 -fit off -t 16 -c 262144 -np 1 -ub 512
KV q8_0/q8_0, embedded template, reasoning_effort: low, temperature 0, Chinese investment-analysis corpus (Chinese text differs from your code corpus in PLE n-gram hit distribution — kept this in mind when comparing to your numbers)

  1. Baseline (no speculation) depth ladder — all four rungs completed successfully
    depth prompt_n pp t/s gen t/s RSS
    32K 26,180 345.5 19.77 69.9 GiB
    64K 52,280 302.8 16.36 70.4 GiB
    128K 104,480 225.5 11.92 71.3 GiB
    256K 208,880 149.5 7.64 73.0 GiB

pp is above your reference at every rung; gen matches at 32K then falls off steeper than your card — I attribute most of the delta to the Chinese corpus plus prompt depth. RSS tracks your GTT curve exactly (69.9 → 73.0 GiB), so memory behaviour fully reproduces your findings.

  1. ngram-mod: works at 32K, then crashes — and the crash kills the GPU

    32K: pp 340.6, gen 17.8 t/s, acceptance at 1.000 across positions — ngram-mod is helping here and reproduces your "0.75/1.000 on ROCm" claim at this depth.
    64K: prefill completes (246.3 t/s, 52,280 tok), then the sequence from the log:
    slot restores a context checkpoint, discards an invalidated one
    speculative replay stalled at pos 52289 (2 consecutive checkpoint restores) - dropping draft, decoding without speculation
    plain decode runs ~100 tokens at 19.38 t/s (decode itself is fine)
    ROCm error: unspecified launch failure → hipMemcpyAsync(D2H) → abort, core dumped
    After the crash, the GPU never recovered. dmesg shows: failed to wait on sdma queue reset done → Ring sdma0 reset failure → GPU reset begin! → and then 5 repeated drm_sched_job_timedout + amdgpu_device_gpu_recover cycles, every ~123 s, with no reset ever succeeding.
    Consequence: every subsequent llama-server process (including fresh ones) sat in D-state (uninterruptible sleep) forever — kill -9 could not remove them, SSH eventually became unresponsive, and only a hard power-off recovered the box.

So the honest answer to your "does ngram acceptance survive depth" question is: it survives to 32K, and beyond that the current build not only crashes — it wedges the SDMA queue and takes the whole GPU down with it. Anyone running qwen4exp + ngram-mod at depth on a 395 should treat this as a stability hazard until it's fixed. This is the single most important finding of my testing.

  1. Second crash — identical-prompt re-request hits common_context_seq_rm

A second request whose prompt is identical to the slot contents asserts:

slot update_slots: id 0 | task 19 | n_past was set to 26179
common/common.cpp:1514: failed to remove sequence 0 with p0=26179, p1=-1

Trigger: sim_best = 1.000 (LCP full match) → full-reuse branch → n_past == task.n_tokens() → assert. Reproduces with cache_prompt on/off, and a trailing-token difference got swallowed by the template (sim_best stayed 1.000). Workaround that worked: add a mid-prompt wording difference to the second request — prefix stays identical for reuse, but f_keep < 1.000, so the reuse branch is never taken with an equal-length prompt. This looks like an uncovered "identical re-request" case in the QSA hybrid-index path, worth a look.

  1. mlock fails on NEXT — --mlock silently does nothing
    warning: failed to mlock 39373176832-byte buffer (after previously locking 0 bytes): Cannot allocate memory

The 37 GiB weight buffer exceeds the default RLIMIT_MEMLOCK (15.6 GiB) on this box, so mlock fails with a warning and the weights aren't locked. Runs in this report were done without --mlock. Anyone serving NEXT with --mlock should know it's not locking.

  1. Workaround summary (what I used to get the baseline data)

    Mid-prompt wording difference between pref/gen requests avoids the seq_rm assert
    No --mlock (fails on NEXT anyway)
    Otherwise identical config across all runs

Data on request: both crash logs (process-level abort + dmesg SDMA wedge), the exact configs, and raw timings. Happy to run any A/B that would help you isolate either crash, or re-test anything once you have a candidate fix — especially the SDMA wedge, since that one has hardware-level consequences.

This is the most useful report anyone has filed on these repos, and the SDMA wedge is the part I want to deal with first — that has hardware-level consequences and it happened following a recommendation on my own card, so it's on me.

Straight answer: I think I've found it, and it's my fork's bug.

qwen4exp doesn't use the normal KV memory. It uses llama_memory_hybrid_idx — attention cache, recurrent cache, and a third one, mem_idx, the QSA indexer cache my fork added to carry the Qwen Sparse Attention index. The problem:

class llama_memory_hybrid_idx : public llama_memory_hybrid

The base class defines state_write / state_read. llama_memory_hybrid_idx does not override them. So when the server writes or restores a context checkpoint it serialises the attention and recurrent caches and silently leaves mem_idx behind. After a restore, the QSA index is describing a different position than the KV caches are.

That is exactly your failure shape:

  1. checkpoint restore → indexer desyncs from the KV caches
  2. speculative replay stalled at pos 52289 (2 consecutive checkpoint restores) — that line is my own livelock guard from issue #58 firing. Its comment claims a plain decode "cannot change the generated output." Your log falsifies that. The guard rescues the control flow; the memory state is already inconsistent.
  3. ~100 tokens of plain decode succeed, then a kernel indexes off a stale index → unspecified launch failure → SDMA queue wedge.

The depth dependence follows: at 32K you don't accumulate checkpoint restores, at 64K+ you do.

Try this — it should be a complete workaround, and it's the run I most want:

-ctxcp 0 -cpent -1

--ctx-checkpoints 0 plus --checkpoint-every-n-tokens -1. If no checkpoints are created the restore path never runs, so the desync can't happen. If that carries ngram-mod to 256K it confirms the diagnosis and gives everyone a safe config today. The real fix is a state_write/state_read override on llama_memory_hybrid_idx that includes mem_idx.

⛔ I have not reproduced this myself. Reproducing it means deliberately wedging a GPU that is currently serving, so I'm not doing that on this box. I'm working entirely from your log — which is why that -ctxcp 0 run is worth more than anything I can assert from here.

Second crash — your diagnosis is right, and so is your workaround.

common/common.cpp:1514: failed to remove sequence 0 with p0=26179, p1=-1

common_context_seq_rm aborts whenever llama_memory_seq_rm returns false. In the hybrid-idx path there is exactly one place it can return false — when the recurrent cache refuses:

if (!get_mem_recr()->seq_rm(seq_id, p0, p1)) {
    return false;
}

With p0 == n_past and p1 == -1 you are asking it to remove an empty range, and the recurrent cache refuses rather than treating it as a no-op. Your mid-prompt difference works because it keeps f_keep < 1.000 so the full-reuse branch is never taken. The fix belongs at the caller: an empty range should be a no-op, not an abort. (Two lines further down, mem_idx->seq_rm(...)'s return value is discarded entirely — a quieter version of the same bug.)

mlock — confirmed, and you were right to drop it.

ulimit -l on my 395 is 16,182,856 KB, about 15.4 GiB, which matches your ~15.6. A 37 GiB weight buffer cannot lock without LimitMEMLOCK=infinity. But don't raise it for NEXT: the PLE n-gram table is a sparse lookup, and mmap only faults in the pages your prompt actually touches — I measure 63.3 GiB resident out of a 98.5 GiB file. Locking would drag in the ~35 GiB you never read. The failure did you a favour. None of my own configs use --mlock.

And your baseline ladder is the number nobody had. pp 345.5 → 149.5, gen 19.77 → 7.64 across 32K → 256K, RSS 69.9 → 73.0 GiB. That RSS curve reproducing mine on a completely different corpus — Chinese investment text vs my source code — is strong independent confirmation, because it says the PLE working set is bounded by the table's structure rather than by what you happen to be prompting with.

I'm putting a warning on the Flash-Next cards about ngram-mod at depth, credited to you.

If you run one thing, make it -ctxcp 0. Send the dmesg alongside it.

Quick follow-up on the evidence situation.

Bad news on the SDMA wedge logs. That crash was severe enough that the GPU ended up unrecoverable — I had to hard power-cycle the box, and the kernel's ring buffer (dmesg) was cleared on reboot. So the boot-time lines I pasted earlier (failed to wait on sdma queue reset done → Ring sdma0 reset failure → GPU reset begin! → repeated drm_sched_job_timedout) are what I have of that event — they were captured while the wedge was happening, but I no longer have a file to hand you. I won't pretend otherwise: the full dmesg from that kernel session is gone.

What I do have, and can share right now: the qwen4exp_crash.log from the identical-request crash (the common_context_seq_rm assert path — 26K prompt, second request, sim_best = 1.000, failed to remove sequence 0 with p0=26179, p1=-1). That file is verified present and unchanged qwen4exp_crash.log. Link: (https://gist.github.com/liusecret000/3395315c77d3bea4460161e2601a49d3).

Good news — the run you asked for is planned: I'll run --ctx-checkpoints 0 --checkpoint-every-n-tokens -1 with ngram-mod through the depth ladder (64K/128K/256K) as you specified, and send you the results plus a fresh dmesg captured after each run so you can confirm the SDMA queue stays clean this time. If checkpoint-disabled speculation carries to 256K, that's your diagnosis confirmed and a safe config for everyone on 395.

Will report back once the run is done.

Ran the -ctxcp 0 -cpent -1 test you asked for. Results below — the diagnosis is confirmed for 64K/128K, but 256K exposed a separate crash path worth your attention.

Config: same as before (gfx1151, ROCm 7.2.4, kingjones30/ROCmFPX, -c 262144 -np 1 -t 16 -ub 512, KV q8_0, embedded template, no mlock), ngram-mod on, --ctx-checkpoints 0 --checkpoint-every-n-tokens -1.

64K and 128K — your diagnosis confirmed

64K: prefill completes, gen works, no restore-related crash. -ctxcp 0 removes the checkpoint-restore path entirely, and the desync you identified never gets a chance to fire.
128K: pp 227.4 t/s, gen 9.95 t/s, RSS 68.9 GiB — and ngram acceptance at depth, the number you said nobody had: draft acceptance = 0.76562 (49 accepted / 64 generated), mean acceptance length = 13.25, acceptance rate/pos holds at 1.000 through position 10 then falls off.
So ngram-mod now survives to 128K with solid acceptance. That's a datapoint your cards didn't have before.

256K — second crash path, checkpoint-independent

Prefill completes (pp 144.16 t/s, prompt_n 208,880), then the crash hits at decode start:

E ggml_cuda_compute_forward: FLASH_ATTN_EXT failed
E ROCm error: an illegal memory access was encountered

This is not the mem_idx desync path — with -ctxcp 0 there are no checkpoints to restore, so the OLD failure mode is gone, yet it still dies. Different signature from the original 64K crash too (that one was hipMemcpyAsync after replay-stall ~100 tokens in; this one is flash-attention at the very first decode steps). So there's a second, independent bug: flash-attn at 208K+ depth performs an illegal memory access during decode.

Good news this time: the GPU survived. dmesg after the crash is clean — only the normal boot-time sdma init lines (detected ip block number 7 , ring sdma_32768.3.3 ib test pass), no job_timedout, no gpu_recover, no reset attempts. Process-level abort only; no hard power-cycle needed. Different from the first 64K wedge, which took the whole GPU down. So -ctxcp 0 did fix the SDMA-wedge path; the remaining 256K crash is a separate flash-attn issue that kills the process but not the card.

Summary for you: -ctxcp 0 -cpent -1 is now a usable safe config for ngram-mod up to 128K on this model (acceptance 0.766 at 128K), and it eliminates the SDMA-wedge path entirely. The 256K flash-attn illegal-access crash is a second item for your list — happy to test any fix you want (e.g. the flash-attn extension fallback, or a non-fa decode path at depth), or to re-run on a candidate patch.

Full logs for the 256K crash available on request.(https://gist.github.com/liusecret000/3395315c77d3bea4460161e2601a49d3)

Don't lose sleep over the dmesg — it doesn't cost us anything.

I never diagnosed the wedge from that file. I diagnosed it from the source: llama_memory_hybrid_idx inherits state_write/state_read from the hybrid base and overrides neither, so checkpoints serialise attn+recurrent and silently drop the QSA indexer. The boot-time lines you already pasted — Ring sdma0 reset failure → GPU reset begin! → repeated drm_sched_job_timedout — are the full signature I needed. A second copy wouldn't tell me anything the mechanism doesn't.

So you don't lose the next one: make journald persistent, then a hard power-cycle can't erase it.

sudo mkdir -p /var/log/journal && sudo systemctl restart systemd-journald

After that, journalctl -k -b -1 reads the previous boot's kernel log — exactly the window you lost this time. Pair it with dmesg -w | tee ~/wedge-$(date +%s).log running during the ladder and you have belt-and-suspenders.

The crash log you did keep — confirmed, and it's already fixed.

Your gist matches the assert exactly: common.cpp:1514: failed to remove sequence 0 with p0=26179, p1=-1, sim_best=1.000, f_keep=1.000, n_past rewound to 26179 to force one unevaluated token, then the recurrent cache refuses to remove that final token and the caller aborts. That's the whole path.

Fixed in one commit on my tree, and I verified this one on hardware (it's the safe one to reproduce — it aborts the server, it doesn't wedge the GPU): the byte-identical re-request that used to hit the assert now returns clean, /health ok, zero abort lines in the journal. Two parts:

  • llama_memory_hybrid_idx::seq_rm now treats an empty range as a no-op and honours the indexer cache's own refusal instead of discarding it.
  • a guard on the common.cpp caller path so an empty removal degrades to a no-op rather than GGML_ABORT.

The SDMA wedge fix is in the same commit — but I have NOT verified that one, and I won't, because verifying it means deliberately wedging a GPU that's serving. It's the state_write/state_read override that serialises mem_idx into every checkpoint, so a restore can no longer leave the QSA index pointing at a different position than the KV caches. Mechanically it closes the exact desync your log shows — but "mechanically closes it" and "proven on a 395 at 256K" are different claims, and only your run makes the second one.

Which is why your -ctxcp 0 -cpent -1 ladder is the important run. It needs no rebuild, it's the safe config for every 395 owner today, and if ngram-mod carries to 256K with clean dmesg per rung, that confirms the diagnosis outright. Fresh dmesg after each rung is exactly the right verification — that's the thing I can't produce from here.

On the permanent fix: it's committed but not yet on the public fork you clone, so git pull won't get it. If you'd rather validate the real fix than the workaround, say the word and I'll hand you the patch (3 files, ~50 lines — the two memory-layer changes plus the caller guard) or push it to the fork. Your call — the -ctxcp 0 path already gets you unblocked without any of that.

This is genuinely good testing. The acceptance-at-depth number is one nobody had, and you found two real bugs getting it. Looking forward to the ladder.

Here's the real fix — apply it and you can validate the permanent version, not just the workaround.

Patch: https://huggingface.co/kingjones777/Qwen3.8-Flash-Next-ROCmFP4-STRIX-GGUF/raw/main/qwen4exp-qsa-checkpoint-fix.patch
sha256: e7ff24007e18ae000ba65fa949b9e97454a944fa4e6ba5cac749c7c88a2c77da

It's 3 files / 52 lines, and I verified it applies clean against the exact pre-fix tree your crash log came from — git apply --check passes, and the common.cpp:1514 it patches is the GGML_ABORT("...failed to remove sequence...") line verbatim from your gist. It ships as a patch on top, the same way qwen4exp itself does — it's not on the public fork's main yet.

Apply and rebuild:

cd ~/ROCmFPX
curl -fL -O https://huggingface.co/kingjones777/Qwen3.8-Flash-Next-ROCmFP4-STRIX-GGUF/raw/main/qwen4exp-qsa-checkpoint-fix.patch
sha256sum qwen4exp-qsa-checkpoint-fix.patch   # expect e7ff24007e18ae000ba65fa949b9e97454a944fa4e6ba5cac749c7c88a2c77da
git apply qwen4exp-qsa-checkpoint-fix.patch
cmake --build build --target llama-server -j$(nproc)

What it changes:

  • llama_memory_hybrid_idx::state_write/state_read now serialise the QSA indexer cache (mem_idx) into every checkpoint — this is the SDMA-wedge fix. A restore can no longer leave the index pointing at a different position than the KV caches.
  • seq_rm treats an empty range as a no-op and honours the indexer cache's refusal, plus a guard on the common.cpp caller — this is the identical-request abort fix, the one I verified on hardware.

How I'd validate it — and this is better data than the workaround: with the patch in, run ngram-mod through the ladder with checkpoints ON (drop -ctxcp 0, keep your normal config). If 64K/128K/256K all survive with clean dmesg per rung, that's the permanent fix proven on a 395 — the desync closed at the source, not sidestepped. If you'd rather not rebuild yet, -ctxcp 0 -cpent -1 still gets you there without it.

Honest line I'll hold to: the seq_rm half I've confirmed here; the wedge half I have not, because confirming it means deliberately wedging a GPU. Your patched run is what turns "mechanically closes it" into "proven." No rush — run it when it suits you.

Thanks for the patch and the sha-pinned instructions — really appreciate you shipping the permanent fix rather than leaving us on the workaround. I've confirmed what it does (state_write/state_read for mem_idx, plus the seq_rm no-op and caller guard) and it's exactly the right pair for the two paths we hit.

I'm going to hold off applying it for now, to be upfront:

The -ctxcp 0 -cpent -1 config works for my current use, and I'm not running ngram-mod in production anyway — it was net-negative speed for my corpus (17.8 vs 19.77 t/s at 32K), so NEXT without speculation is my daily driver.
I'd rather rebuild and validate the permanent fix when I have a clean block of time — your patched-run request deserves a proper ladder with checkpoints ON and per-rung dmesg, not a rushed one. When I do, I'll post the results here.

One thing this whole exercise made clear, and it's worth putting on the record: the issues we found (seq_rm abort, the mem_idx desync behind the SDMA wedge, the 256K flash-attn illegal-access) were all sitting there before MTP ever reaches this model in llama.cpp. Whoever ships the NEXT MTP head next will land on those same holes — so the testing wasn't just about ngram-mod, it effectively pre-surveyed the ground MTP support will have to stand on. That's the part I'm glad we could do, and your fixes are what make it payable.

Good luck with the fork — happy to validate the patch properly whenever it suits both of us.

Same platform as Karsa's reports: Ryzen AI Max+ 395 (gfx1151), 128 GB unified, ROCm 7.2.4, kingjones30/ROCmFPX build, running the Uncensored STRIX_LEAN at -c 262144 -np 1 -t 16 -fa 1 -fit off, ngram-mod with --ctx-checkpoints 0 --checkpoint-every-n-tokens -1. Two observations for the thread.

  1. Cross-request prompt caching does not engage at all.
    Identical ~2.9k-token prompt, 3 consecutive requests: /v1/chat/completions with cache_prompt:true → usage.prompt_tokens_details.cached_tokens = 0 every time; native /completion with cache_prompt:true → no reuse either (6.5s → 5.7s). Server runs default --cache-prompt (enabled). journald additionally shows a per-request prompt_save line:
    prompt_save: saving prompt with length 2881, total state size = 192.455 MiB (draft: 0.000 MiB)
    State size scales ≈ 128 MiB fixed + ~24.5 KB/token (≈2.3 GiB @ 93k, ≈6.2 GiB @ 262k).
    Questions: is cross-request KV/state reuse (incl. the mem_idx QSA indexer) supported at all on qwen4exp? Is prompt_save executed unconditionally per request, and is a save ever restorable? Is there a flag to disable it when reuse can't work? Net effect here: every large request fully re-prefills (93k ≈ 270 tok/s effective, matching Karsa's depth ladder), TTFT ≈ minutes at 100k+.

  2. ngram-mod replay stalls fire routinely in production.
    speculative replay stalled at pos 2879 (2 consecutive checkpoint restores) - dropping draft, decoding without speculation
    draft acceptance = 0.00000 (0 accepted / 19 generated)
    44 such events in the first day (positions 2.9k → 53k); the guard always recovered and decode continued without speculation. This looks like the #25819-class livelock (near-miss drafts at 20/21). Given the earlier SDMA-wedge report, is a guard-recovered stall considered safe, or can the memory desync still cascade into a wedge? Any tuning (n-match / draft n-max) that reduces stall frequency?
    Also: for --cache-reuse N — does a positive value change prefix reuse on this arch, or is it irrelevant while the state can't be retained?

Thanks for the great work — the fork has been rock-solid apart from these two.

Quick follow-up with a useful contrast data point on the caching question.>
Same host, two different builds:

  • :8099 — Qwen3.8-Flash-Next (Uncensored, qwen4exp arch) on the self-built kingjones30/ROCmFPX image (HIP/ROCm backend): identical ~2.9k-token prompt ×3 with cache_prompt:true → cached_tokens = 0 every time; native /completion also no reuse.
  • :8083 — Qwen3-VL-30B-A3B (standard transformer arch) on the kyuz0 toolbox vulkan-radv-performance build (Vulkan RADV backend, build 10654): proper caching WORKS, including image tokens:

text-only ×2, cache_prompt:true: #1 cached=3 → #2 cached=16/17 (~0.2s)

same image+text ×2: #1 cached=285/294 → #2 cached=293/294 (~0.1s)

Note the image test's first call already reported 285/294 cached — the vision-tower tokens from an earlier request were still retained. So the Vulkan/upstream-lineage build does cross-request KV reuse fine, while the qwen4exp ROCmFPX build never engages it.

That points the failure at the qwen4exp side specifically — presumably the llama_memory_hybrid_idx mem_idx (QSA indexer) state not being retained across requests, the same component behind the checkpoint/SDMA-wedge saga.

Question stands: is cross-request state reuse supported at all for qwen4exp in the fork, and if not, is disabling prompt_save per-request an option?

Sign up or log in to comment