mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#681
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @foomip on GitHub (Oct 9, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1705
What happened
Long-context serving on an RX 7900 XTX (gfx1100, Linux) died repeatedly with the two paths this engine already
instruments: the prompt watchdog (
no progress for 60 s … (issue #29)) and the verify window, whose #649 trace ended inRELEASE-NOT-DRAINED. Nine engine deaths in one day (2026-10-08, 10:16 to 23:42), all during long-context work(positions 31 860 to 200 523 in the trace dumps), all while the box was under memory reclaim. Adding
"HSA_USERPTR_FOR_PAGED_MEM": "0"to the server JSONenvblock stopped them: the next long run did 283 requests in4 h 54 m, up to 245 625 tokens, with no hang, no timeout and no watchdog event.
This is the mechanism already documented in
docs/AMD_HIP.md("Linux: verify timeouts while the kernel reclaims hostmemory") and reported for the R9700 in #750 — reported here as a second machine, on a different GPU and ROCm version,
with the extra evidence that the two published workarounds are the same mechanism seen from two ends, and with one
detail that is not in the docs: on this box the trigger was Pop!_OS's default
vm.swappiness=180zram setup.Two code-level observations at the end, which are the parts that may want a change in Strata rather than in the config.
Environment
12:47; the upgrade to 0.1.41 was at 16:40), HIP backend
7.10.0a20251120(
_rocm_sdk_core/_rocm_sdk_devel/_rocm_sdk_libraries_gfx110X_dgpu), hipBLASLt tuning tabletools/hip/gfx1100-hipblaslt-100200.txtlayer % 4 == 3), native GGUF inplace,
--resident-budget-gib 55(resident RAM mode: 40.65 GiB page-locked experts),--max-context 262144,--kv q4_0 --kv-resident 32768,--spec 4 --spec-min-p 0.5 --batch-mtp,parallel: 2,--batch 2envat the time of the failures:STRATA_HIPBLASLT_TUNING,GPU_PINNED_MIN_XFER_SIZE=1048576(already set fromthe #920 note), plus the diagnostics named below
Symptom — two distinct classes, both fatal
Class A, the prompt path (watchdog stops the engine, exit
-6):The device had completed all 48 layers (
48 of 48 jobs claimed, 48 done,the GPU rang 48) while the host sat in theprompt path for 60 s.
Class B, the verify window (the server ends the engine; the console adds that the waits were released and the GPU did not
finish within 5 s):
Nine events on 2026-10-08 (times are the restart the server did right after each):
(request -1)(request -1)(decode -1)The two classes differ in one measurable way, which is what makes them worth separating: after the sentinel release,
class A's GPU work is already done (the host had not seen the ring), class B's never drains (the device was still inside
the step).
Evidence
RELEASE-NOT-DRAINEDevents stopped at the same point in the layer, and the tracenames it. At 22:57 the same window recorded
out-proj(16)=20628.0 router+ring(…)for layer 8 andout-proj(16)=22180.5 router+ring(…)for layer 9, then layer 10 recordedpre(0)=23267.0 … out-proj(16)=23468.0and norouter+ringmarker at all — i.e. it stopped inside the publish ofthat layer's ring to host memory (
verify.cpp:310names marker 17router+ring). At 23:42 the same: layers 2 and 3recorded their markers, layer 4 ended at
out-proj(16)=5636.6with norouter+ring. The stall was 23.5 ms and 5.6 msinto the window respectively, then nothing for the whole timeout.
/proc/<pid>/task/*/stat(30 MB of dumps) shows the main threadSTATE=R WCHAN=0with ~100 jiffies/turn during every class-A stall: spinning on a ring the device had alreadywritten, one core saturated, no thread in
D,io wait causesall zero.PSI memory some avg10=5.55%at the 23:42 hang (0.00% now); the engine reported32 838 major page faultsand687 MiB in swap; ~9.4 GiB of the box was in zram swap;vm.swappiness=180(Pop!_OS default via
/usr/bin/pop-zram-config).journalctl -kcarriesamdgpu_amdkfd_restore_userptr_worker 3884: restore worker triggers a page restore failedandsvm_range_restore_pages ... invalid nodein clusters at 10:11, 11:27–11:37,12:43 and 17:22 — each before a hang. Zero since 23:48. (Caveat: those lines print on count doubling, so silence
is weak evidence.)
requests in 128–192 k and 8 above 192 k succeeded that day, and the longest clean prompt that evening was 203 908
tokens. Failure counts track tokens processed, not context size.
What was ruled out, one variable at a time
Each row is a separate restart of the server with one change, judged on the same workload.
STRATA_PF_STEP_SYNC=1(diagnostic)STRATA_VERIFY_TRACE=1(#649 trace)zfs_arc_max)MemAvailable87 GiB at the timeSTRATA_DOORBELL_STORE=1STRATA_HC_SPLIT=0(plain hc read)HIP_HOST_COHERENT=1parallel: 2/--batch 2/--batch-mtpas a preconditionPSI io63–85% for 18 h from an unrelatedgit lfs pull)HSA_USERPTR_FOR_PAGED_MEM=0The fix, and the paired numbers
Before (same machine, same model, same args, 17:22–23:42): 7 engine deaths in ~6 h 20 m, longest clean gap 74 min,
prompt reads 614–1 128 tok/s, prompt-step outliers to 19 585 ms.
After (engine 0.1.41, 06:11:21 → 11:05): 4 h 54 m, 283 requests, median prompt 72 242 tokens, largest 245 625,
25 requests above 150 k, zero hangs, zero timeouts, zero prompt-step outliers, zero engine deaths. Four cold full
prompts in that window: 203 272 tokens in 209 982 ms (968 tok/s), 204 295 in 211 431 ms (966), 205 311 in 211 132 ms
(972), 212 721 in 229 558 ms (927). Decode 34.8–40.4 tok/s with
--spec 4drafts accepted (e.g. 266 of 320), whichmatches the pre-change decode rate.
PSI memory0.00%, kernel userptr-restore warnings 0.Two honest caveats about attribution:
swapoff -aat 23:48:28 and theenvedit, with the engine starting at23:48:58. Both act on the same mechanism — the kernel moving host pages the GPU can see — so the finding is
"one mechanism, two mitigations", not "switch X". Swap was re-enabled at 11:49 with
vm.swappiness=20and theswitch left in; that run was clean for its first 29 minutes, which is the useful configuration and still short.
with/against number like the #750 report does; the 927–972 tok/s above is a before/after comparison across
different prompt mixes, not an interleaved A/B.
A structural change I can see from userland, which supports the mechanism: with the switch on, the engine's
VmRSSfell from 78–94 GiB to 6.3 GiB while the log still reports
resident RAM mode: 40.65 GiB of experts in RAM (page-locked)and the decode hit rate stays 84–89.5%, andUnevictable/Mlockedstay at 8 MiB. The 40 GiB appears tobe held outside the process's page tables now (about 57 GiB of
usedmemory is not attributed to any process or to/proc/meminfocategories), i.e. it is no longer paged host memory the kernel may move. That is an inference fromaccounting, not a driver counter.
Two things in Strata that look like bugs
death_note()only scans the last 4096 bytes of the log (serve/server.py:781-796). WithSTRATA_VERIFY_TRACE=1the trace dumps are ~30 KB, so theissue #29line is pushed out of the tail and the serverreports the fallback "running out of RAM" note for what was a caught hang. It sent me chasing memory for an hour.
Either scan further back or keep the last watchdog line as state.
STRATA_DOORBELL_STOREonly covers the verify path.g_doorbell_storeis read insrc/core/verify.cpp:130andapplied at
:1339, but the prompt path publishes throughdoorbell_ring()(src/core/layer.cpp:391→src/kernels/cuda/elementwise.cu:428, kernel at:209), which is an unconditional increment. So the A/B switchcannot test the class-A path at all, and the banner ("doorbell stored") reads as if it had. The comment at
elementwise.cu:189about the cloned-literal host expression suggests the same fix applies there.What I did not test
runs — I did not verify byte-identical answers with and without it.
rocm-smireset comparison, no driver downgrade/upgrade test.point, but class A never produced a
RELEASE-line to compare against.Suggested doc addition
docs/AMD_HIP.mdlists the two workarounds separately. On zram distributions they are one thing: Pop!_OS shipsvm.swappiness=180via/usr/bin/pop-zram-config, which maximises exactly the page movement that suspends the queues.Worth a line: "on a zram box, check
vm.swappinesstoo — and note thatswapoff -aon Pop!_OS leaves swap disableduntil reboot, because
pop-zram-configexits early when/dev/zram0already exists."Related
#649 (same symptom, gfx1030, same model family, also runs
STRATA_HC_SPLIT=0), #1103 (gfx1030 verify timeouts fixed bya ROCm wheel change), #884 / #1691 (gfx906), #872 (gfx1100 7900 XTX, IQ3_S at 262 144, whole-machine restarts on
Windows), #750 and #920 in
docs/AMD_HIP.md.Engine log
strata-unsloth-ud-iq4_xs.logattached: 14 565 lines, 2026-10-08 00:00:51 → 2026-10-09 11:18:43, covering all nineevents and the clean run after the fix. Checked before attaching: it holds prompt token counts, layer numbers, timings
and the engine command line (so, file paths) — no prompt or completion text.
@foomip commented on GitHub (Oct 9, 2026):
strata-unsloth-ud-iq4_xs.log
@CC-David-CC commented on GitHub (Oct 10, 2026):
i needed those logs. The supplied log now resolves to another watchdog explanation
if the software hillclimber can't find this i will test some much older software i have.
I promise - even if i have to spam Rory to hit up Lisa - i have 5 million tokens to spend on this
@foomip commented on GitHub (Oct 10, 2026):
Thanks man, just for your FYI after the config changes in the run script it has been running rock solid on my side for 2 days continuous use.
@Niko1221 commented on GitHub (Oct 10, 2026):
Evaluated on R9700 (a third machine for the mechanism). With HSA_USERPTR_FOR_PAGED_MEM=0 vs unset, 6 interleaved pairs with exact settings: the ids are identical in every run. Speed on our shared box was too noisy to call (decode swings 4-100 tok/s between runs of the same arm because other jobs share the CPU), and prompt speed went +8% to +12% in one run and -0.3% to -2% in another, so no speed claim either way. We do not make it a default (we cannot reproduce the reclaim stalls, and the driver effect is machine specific), but the docs already list it and we will add your zram/swappiness note. Your first code finding is fixed: the server's death note now scans the last 256 KB of the log for the watchdog line (issue #29), so a long verify trace no longer hides it. The DOORBELL_STORE coverage of the prompt path (doorbell_ring) is noted for later.
@CC-David-CC commented on GitHub (Oct 11, 2026):
https://github.com/Niko1221/Strata/pull/1931
@HackityAnn commented on GitHub (Oct 11, 2026):
A fourth machine for this mechanism, with one difference worth knowing: here
HSA_USERPTR_FOR_PAGED_MEM=0did notend it,
GPU_PINNED_MIN_XFER_SIZE=1048576did.Setup: engine 0.1.41 (HIP), 2x RX 9070 XT / RX 9070 (gfx1201) layer split (
layer_split28), Qwen3.8-Flash-NextIQ3_S,
--resident-expertswithSTRATA_RESIDENT_PIN=0(as setup writes it for ROCm: 25.5 GiB pageable residentcopy),
--trim-stage-weights --pipeline-windows 2, 204800 ctx, KV int8,--spec 4. Ubuntu 26.04, kernel 7.0.0-31,ROCm 10.0 (
/opt/rocm/lib), 64 GB RAM (59.5 GiB usable), 24 GB swap file on LUKS. Workload: a coding agent (Pi)running long tasks up to 170K tokens, with compaction.
Symptom: the class A stall from this issue, about once per 30 min of agent load (7 in ~4 h):
reading the prompt (batched): waiting for the GPU (attention, router) at layer N, pool all done, host idle, on either card (layers 2, 25,26 and 41). Always on a big prompt read: after the agent's compaction (re-read from token ~10.5K) or after a restart
lost the KV cache. Never on the same model with
--mmap-expertson one card (its config already hadGPU_PINNED_MIN_XFER_SIZE).Trace (amdgpu dynamic debug on KFD evict/restore +
svm_range_evict, a 1 s sampler, snapshots while queues stayevicted): at the stall,
kswapd0(and the dm-crypt worker writing swap) invalidated SVM ranges of the engine, KFDlogged
Evicting process pid N queuesfor every GPU, and the matchingRestoringcame 86 s later, so the 60 swatchdog fired first. During those 86 s the box thrashed (memory PSI full 16 %, IO 32 %, ~0.9 GB swapped out and ~0.7 GB
in) and one engine thread sat in D at
lock_mm_and_find_vma. Mapping the evicted ranges onto/proc/<pid>/maps:the 25.51 GiB anonymous resident copy, the mmapped
experts.bin, and some heap.A/B, same task (one long agent task each, same box):
HSA_USERPTR_FOR_PAGED_MEM=0GPU_PINNED_MIN_XFER_SIZE=1048576STRATA_WATCHDOG_S=300With
HSA_USERPTR_FOR_PAGED_MEM=0the engine created no userptr BOs, but the copies' sources were still registered asSVM ranges, so reclaim kept evicting the queues.
GPU_PINNED_MIN_XFER_SIZEmakes HIP stage those copies instead, andthe SVM evictions disappeared. Big prompt re-reads also got faster: a full 84K read took 48 s, against 94K in 155 s
before.
vm.swappiness=10made no difference to the amount swapped, so it was not the lever here.Suggestion: setup already writes
STRATA_RESIDENT_PIN=0for ROCm in--low-ram residentmode. WritingGPU_PINNED_MIN_XFER_SIZE=1048576next to it would close this for that configuration, the same way the engine alreadysets it for
STRATA_ARENA_MMAP=1. The docs section could also say thatHSA_USERPTR_FOR_PAGED_MEM=0may not be enoughwhen the evictions are SVM evictions (
evicting svmsin the amdgpu debug log).Not measured: whether
GPU_PINNED_MIN_XFER_SIZEcosts decode speed in this mode (the task times above were not slower).@GodYtteria commented on GitHub (Oct 13, 2026):
Same mechanism seen on NVIDIA too (Vulkan engine, T550 Laptop 4 GB, CachyOS with zram swap,
vm.swappiness150): a cold 16K-token prompt had one batch take 56 s instead of 25 s in 3 of 7 runs. Atvm.swappiness=0, 0 of 4 runs (97.3-97.6 tok/s). A load-time warning when swappiness > 60 with swap on might save others the search.@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.