mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1712] Strata on 2x RX 7900 XTX (HIP, AVX-only CPU): Memory access fault by GPU node-2 ... Page not present with concurrent requests Dates below are day/month (2026), times are local (CEST, UTC+2). #683
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#683
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 @mantovaniluca91 on GitHub (Oct 9, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1712
Summary
With 2 or more concurrent requests (
"parallel": N, layer split on two RX 7900 XTX) the engine dies withMemory access fault by GPU node-2 (Agent handle: ...) on address 0x7e74...000. Reason: Page not present or supervisor privilege.(exit code -6). The server restarts it by itself in 1-2 minutes. The faulting address is always a host(system RAM) virtual address, and the fault always happens when a conversation enters or leaves a batch slot: right
after
strata batch: slot N takes ... tokens (copied in ... ms),conversation cache: restored N tokens (checkpoint)orstrata batch: slot N gave back N tokens of this conversation (its turn checkpoint).With 4 concurrent sessions it happens every 6-29 minutes. It still happens on 0.1.41, with the copy engine off
(
HSA_ENABLE_SDMA=0), withSTRATA_HIP_ADAPT_KERNEL_COPY=1, and with the KV cache fully in VRAM (no--kv-resident).With one request at a time it was ~0.5/hour on the old two-socket placement, and 0 in ~3.5 h after moving both GPUs under
the same CPU.
Side effect: the fault ends in a hardware reset of the card. Right after the page fault the card's MES firmware stops
answering (
MES failed to response msg=3,failed to remove hardware queue from MES), and amdgpu does a MODE1 resetof that XTX (
VRAM is lost due to GPU reset!; 9 resets of that card in ~22 h). The reset is then reported to every ROCmprocess on the machine: four unrelated processes that only use the two MI50s (llama.cpp servers and a PyTorch service,
in other containers that cannot see the XTX) print
HW Exception by GPU node-4 (Agent handle: ...) reason :GPU Hangatthe same second and exit (status 139 / SIGABRT). So one fault in Strata takes down every GPU service on the box for 1-2
minutes. The MES hang and the reset fan-out are driver/runtime behavior, not Strata's, but they make the fault expensive.
Kernel log below.
Environment
fb58e0d) from 09/10 10:34local-hip, archs gfx1100,isa_floor: avx(EXPERIMENTAL older-CPU build), vision cpu--trim-stage-weightsiommu=pt,amdgpu.ppfeaturemask=0xffffffffrocm/dev-ubuntu-24.04:7.2.4-complete(engine built and run inside it,--device /dev/kfd+ 2 render nodes)iq3_xxs, MTP rt,--kv int8 --kv-resident 32768reasoning_budget_tokens 4096,--max-context65536 / 131072 / 262144,parallel1-4,--batch-groups1/2/3/auto, optionally--conversation-cache-mib 16384 --conversation-cache-slots Nkernel.numa_balancing1 (also tested with 0)What we measured
conversation cache: restored ... (checkpoint)strata batch: slot 2 takes 21599 tokenskernel.numa_balancing=0conversation cache: parked/restored--remote-expert-optconversation cache: restored 26338 tokens (checkpoint)conversation cache: parkedSTRATA_HIP_ADAPT_KERNEL_COPY=1(its startup line was in the log)conversation cache: restored 26552 tokens (checkpoint)HSA_ENABLE_SDMA=0(checked in the engine's/proc/<pid>/environ)conversation cache: restored 30664 tokens (checkpoint)--kv-resident(KV fully in VRAM, 0KV streaminglines; slot sessions 7.5 GiB per card)strata batch: slot 2 gave back 25734 tokens of this conversation (its turn checkpoint)Excluded so far: GPUs on different sockets (both XTX now on NUMA node 0), conversation parking (09/10 08:38), automatic
NUMA balancing, the SDMA copy engine (both switches), KV streaming, the 0.1.40 -> 0.1.41 update. With the KV in VRAM the
faults may be somewhat rarer (1 in 57 min of 4-session load, ~120 restores) but they do not stop.
Not yet tested:
HSA_USERPTR_FOR_PAGED_MEM=0,GPU_PINNED_MIN_XFER_SIZE=1048576,--mmap-experts.One instance per card (no layer split) could not be judged: it runs, but too slowly on this CPU (see below), so in 10
minutes there were too few slot admissions to say anything about the fault.
Log excerpts
0.1.41, KV fully in VRAM (no
--kv-resident), 131k, 4 sessions (09/10 13:42 local):0.1.41,
HSA_ENABLE_SDMA=0, 262k with KV streaming (09/10 12:33 local):0.1.40, numa_balancing=0 (09/10 09:34 local):
Without parking (09/10 08:57):
Server side, every time:
the engine stopped unexpectedly (exit code -6)once per in-flight request, thenthe engine had stopped (exit code -6); starting it again. No OOM: 60+ GB of RAM were available during the tests.node-2is the first GPU visible in the container, i.e. the XTX running layers 0-26 (node-4/ PCI0000:09:00.0on the host).Kernel log of the same fault (09/10 13:43:58 local, 0.1.41, KV in VRAM, 131k; the last faulting address is the one the
engine reported,
0x732b48cce000):Other ROCm processes (MI50 only), same second:
Other findings that may help
/metricstotals.decode_msis far too small with batching. 12 batched requests wrote 3,711 tokens, and the sum oftheir
decode_msis 323.6 ms, while each request'sdecode_tok_ssays 34-36 tok/s (~109 s in total).output_tokens / decode_msthen gives "750 tok/s". The per-requestdecode_tok_slooks right.tools/visionbuilt with-DGGML_HIP=ON -DAMDGPU_TARGETS=gfx906 -DCMAKE_EXE_LINKER_FLAGS=-no-pie(ROCm 6.1.2;-no-pieis needed becauselibggml-hip.ais not PIC), started byserver.pythrough a wrapper that setsLD_LIBRARY_PATHto ROCm 6.1, with"vision": {"gpu": true, "cuda_device": 0}on a spare MI50 and
env.HIP_VISIBLE_DEVICES = "1,2"for the engine.parallel 4without batch-groups: 39-42 tok/s in total, no gain (the cards work in turn);--batch-groups 2: up to 59 tok/s in total, 17-32 tok/s per request.tokens, from
/metricsrequests), expert hit rate 99.8%; 19,557 of 24,576 experts in VRAM (13,918 at 262k).--shared-expert-arenaworks for two instances on one box. One instance per XTX ("gpu": [0]in each container,no layer split, ports 8480/8481), both with
--shared-expert-arena /shm/experts-iq3_xxs.arenaon a host /dev/shmdirectory: the second instance attached to the 40 GiB arena the first one created (
MAP_SHARED file ... (pack hash checked)), RAM stayed at ~40 GiB for both. On this AVX-only CPU it is not usable, though: each card holds ~9,560experts of all 48 layers, the decode hit rate falls to 75-85% and requests decode at 1.3-2.5 tok/s.
@mantovaniluca91 commented on GitHub (Oct 9, 2026):
Update, same day (0.1.41, same box, same 4-agent load, 262k, KV streaming, parking 4x16 GiB):
With
--batch-groups 1(no pipelining between the two cards) the fault is about 3x rarer, but it does not go away.--batch-groups auto(2 groups, "pipelined" in the log)--batch-groups 1--batch-groups 1The fault point is the same as before:
--pipeline-windowswas never set (default 0). Decode speed per request was the same with and without pipelining for thisagent load (median 34 vs 36 tok/s per turn, from
/metricsrequests).This may be related to #1578 (illegal memory access on a two-GPU layer split that goes away with
--pipeline-windows 0):pipelining makes it more frequent here too, but the remaining faults suggest the slot give-back / conversation-cache copy
path itself.
@mantovaniluca91 commented on GitHub (Oct 9, 2026):
Found it, I think - and there is a workaround:
--no-prefill-borrowmakes the fault go away on this box.Where it faults (rocm-debug-agent,
HSA_TOOLS_LIB=librocm-debug-agent.so.2): every faulting wave is inattn_chunk_kernel<1, false>, launched by the prompt read (prefill.cpp ~2764-2771: on gfx1100qsa_prompt_attn_batchreturns false, so every prompt chunk uses the decode kernel). Disassembly + registers:
s[24:25]=QsaAttnPools.page_table=m.ident_table(staged pools,pools_of(m.stage, m.ident_table), prefill.cpp:2757),a 65536-entry identity table (max-context 262144 / page_size 4, cudaMalloc at prefill.cpp ~1102).
p.page_table[cell / page_size](qsa_decode_attn.cu ~L117) withcell = ids[c0+t]up to 316467,i.e. index 77172..79116 > 65535: it reads ~40 KiB past the end of the table -> page not present -> MES hang -> MODE1 reset.
device said n_kv > 316k, while the conversation was ~29k tokens and the host positions are in range (the indexer's
p0 + n > max_cellsguard never fired). The device-sidesteps_dev/sel_idsdo not match what the host wrote.Why we think it is the borrowed slots:
steps_dev,sel_ids,sel_scoresand the stage pool are carved from the expert-cacheslots the prompt path borrows (
the prompt path borrows 2388 CUDA0 cache slots), and something else writes into them while theprompt is read. We did not find the writer.
Test (0.1.41, same box, same load: 4 agent sessions, 262k,
--batch-groups auto, KV streaming, parking 4x16 GiB):--no-prefill-borrow(
--no-prefill-borrowconfirmed in theengine startedline, and noborrows ... cache slotsline after start.)Other things that did NOT help, for the record:
STRATA_HIP_ADAPT_KERNEL_COPY=1,HSA_ENABLE_SDMA=0, KV fully in VRAM,--batch-groups 1(3x rarer, not gone), the expert arena in hugetlb pages,numa_balancing=0. Note that the first 8 faults(06-07/10, 0.1.39/0.1.40) happened with
parallel 1and no batch, so the borrowed-slot clobber is probably not batch-only.Suggestions: a bound check in
attn_chunk_kernel(cell < 0 || cell / page_size >= n_pages-> page -1) so a bad record does nottake the whole GPU down, and a look at who can write into the lent slots while a prompt is read on a layer split.
@mantovaniluca91 commented on GitHub (Oct 10, 2026):
Follow-up after a longer run:
--no-prefill-borrowremoves most of it, but not all. One more fault, and this one points at the step records.Run: 0.1.41,
--no-prefill-borrow, 6 agent sessions at 262k ("parallel": 6,--batch-groups auto= 2 pipelined groups of 3,--kv int8 --kv-resident 32768,--layer-split 27 --trim-stage-weights, conversation cache 6 GiB). One fault after 152 min(76 agent requests, 866 decode turns, median 28 tok/s per turn). Before, the default config faulted every 11-29 min with 4 sessions.
Same launch as before (rocm-debug-agent + disassembly):
attn_chunk_kernel<1,false>from the prefill fallback,prefill.cpp:2765-2771, first 32-query call (t0=0) of a T=2048 chunk,
pools_of(m.stage, m.ident_table). The register deltas matchthe carve exactly (q->ids = 131,073,280 B, ids->part_acc = 83,978,752 B). The engine log puts that chunk at p0 ~ 37,164 of a
39,316-token prompt.
What is wrong in it:
n_ids = step[kStepWidth]= 1712 for row z=0 and 41710 for row z=2. Both breakwidth <= cap (2051),and
qsa_step_fill(qsa.cu:709-714) can never produce them. The kernel does not clampn_idstocap(qsa_decode_attn.cu:~101).selection of 362 cells ending at 2651. For a chunk at p0 ~ 37k both should be 2051-wide sparse selections reaching ~37k.
sel_idsholds stale floats from the MoE set that shares the scratch region (prefill.cpp ~1183/1194),so the attention reads float bits as cell ids and faults ~944 MB past
ident_table.So in both cases (borrowed and owned buffers) the step record on the device is not the one the host built for that chunk: in the
first case n_kv > 316k, here widths of 1712 / 41710 and n_kv of 487.
steps_devis written only by the H2D at prefill.cpp:2159-2161as far as we can see. We did not find the writer. One correlation: both dumps end right after the pipelined batch drained
(
strata batch (pipelined, ...)stats line) and first-use captures of non-batch verify windows (capturing the 5-token window).Suggestions:
attn_chunk_kernelusemin(step[kStepWidth], cap)and mask any cell outside[0, n_pages * page_size)as page -1; clampn_bid/ width in the top-k.(
pos + 1 == n_kv,width == min(n_kv, cap),n_bid == n_kv / idx_block), printing layer, p0 and row once.Happy to run a debug build on this box (2x 7900 XTX, AVX-only Xeon) if that helps.
@Niko1221 commented on GitHub (Oct 10, 2026):
We tried to reproduce on 2x R9700 (gfx1201, Linux kernel 7.0, ROCm 7.14, layer split, IQ3_S, pre-release v0.1.42 engine) with an agent-style load: 4 sessions each over a long document (9K and 14K words, 20-30K tokens), 6 turns per conversation with 0.5-8 s pauses, --batch 4, --conversation-cache-mib 16384 --conversation-cache-slots 4, --kv-resident 32768, context 131072 and 262144, 40 minutes each. Run 1: 532 requests, 535 parks, 194 restores, 439 slot admissions, 199 give-backs; run 2: 453 requests, 606 parks, 148 restores, 377 admissions, 181 give-backs. No memory access fault, no engine restart. So it does not reproduce on R9700 (a different architecture, one socket, PCIe 4.0). What we cannot match from your report: gfx1100, a 2-socket Ivy Bridge Xeon with the AVX-only build, PCIe 3.0 x8 behind switches, kernel 6.8. Please try the two items you listed as untested: HSA_USERPTR_FOR_PAGED_MEM=0 (see #1705, the same mechanism) and GPU_PINNED_MIN_XFER_SIZE=1048576 in the server JSON env, and --mmap-experts.
@mantovaniluca91 commented on GitHub (Oct 10, 2026):
Thanks for trying it on the R9700s. Your load was text only, and that is probably why it did not show: on our box the fault needs an image request first. We now have a deterministic two-request reproduction, the faulting kernel, the root cause as far as we can measure it, and two small patches that make it go away (0/5 vs 5/5). Everything below is on 0.1.41, 2x RX 7900 XTX (gfx1100), ROCm 7.2.4 in the container, layer split 27,
--max-context 262144 --kv int8 --kv-resident 32768 --spec 4 --mtp --no-prefill-borrow --batch-groups auto --conversation-cache-mib 6144,parallel 4, vision encoder on a separate card (cuda_device).Reproduction (fresh engine every time, one request at a time, each a new conversation, temperature 0, json_schema grammar)
--no-prefill-borrowthe prompt chunk is a fixed 2048 (generate.cpp:2148-2151), so B is read in two chunks.B faults about 3.4 s in, every time. The
STRATA_TRACElines end withprompt chunk 2048 of 2135on CUDA0 (while CUDA1 runsprompt chunk 0 of 2048). The trigger needs all three of these:The fault (rocm-debug-agent, two captures, identical register values)
strata::kernels::(anonymous namespace)::block_topk_kernel(float const*, int const*, long, long, int*),stopped, reason: MEMORY_VIOLATION, 7-8 waves all at the same pc. From the registers: it is the call at prefill.cpp:2669 with t0 = 0 (s14:s15 - s12:s13 = 0x1006100 = 2048*2051*4 + 256, i.e. sel_ids then sel_scores in the T=2048 carve),s4 = 3*65538(qi*max_blocks),s6 = 2051(cap),s10 = 3(qi). Query 3 of chunk p0=2048 (pos 2051) is the first query of the prompt that leaves the identity path, so its record should be {2051, 2052, 513, 2051}. On the device the kernel read n_bid = 0x3c7601f2 (the bits of the float 0.0150), and n_kv / width look like float data too. The radix loop then readssc[t*per]0.5-1.5 GB past sel_scores. block_scores does not fault because its grid is bounded byactive, which comes from steps_host.The whole record is garbage, and the garbage is identical bit for bit in two separate runs. That is why the synthetic pair does not fault: different stale data, and the garbage record happens to take the identity path (
n_kv <= width) instead of the radix path.What it is NOT (each tested on A→B from a fresh engine, all still fault)
--conversation-cache-mib 0;--max-context 131072(on HIP the prompt path uses the ref kernel either way, qsa_select.cu:1323-1335);--adapt-every 0 --adapt-swaps 0;STRATA_HIP_WMMA=1;STRATA_PF_STEP_SYNC=1;--batch-groups 1(really replacingauto; the engine log confirms 1 group); without--mtp(--speccannot be dropped with a native pack). And your three suggestions:HSA_USERPTR_FOR_PAGED_MEM=0: worse, it faults after 3 requests.GPU_PINNED_MIN_XFER_SIZE=1048576in the server env: still faults, and the image request goes from 22 s to 161 s.--mmap-experts: still faults.An instrumented build that reads
steps_devback at 15+ points of the chunk never showed a dirty record and did not fault on A→B (0/3, even with deferred D2H copies and no host sync; its only restart was the debug agent's ownrocm-dbgapierror). So the problem is timing-sensitive, which pointed at the copy rather than the arithmetic.Root cause, as far as we can measure: the pageable H2D of the step records
steps_devhas exactly one writer, thecudaMemcpyAsyncat prefill.cpp:2160. Its source ism.steps_host, astd::vector(pageable), and the return value is not checked. Right before it, the image request has uploaded about 1,200 embedding rows withcudaMemcpyAsyncfrom pageableimg_rows(prefill.cpp:2107-2113), and the first text request after it rewrites the M-RoPE table. Our reading: on this ROCm/gfx1100 combination, a pageable async H2D through the runtime's staging path can deliver stale bytes after that traffic.Two patches, five alternating rounds from the same install, same two requests, fresh engine each time (production binary / A / B):
A changes nothing but the source memory of that one copy, so the pageable copy is the culprit. B removes the copy entirely, and it would also cover any other writer. The 09/10
attn_chunk_kernelfaults (ids pastident_table, "foreign" records with width 1712/41710 and n_kv 487) look like the same thing one step later: a garbage step record gives a garbage selection, and the attention reads it.Suggestions:
tok_host(prefill.cpp:2090) and the image rows have the same exposure.layer.hpp:263-272already asks for pinned, fixed sources for step uploads; the prompt path does not follow it. Check the return values.block_topk_kernel(and the reg/wide/cluster variants,block_scores_kernel,attn_chunk_kernel):n_kv >= 0, n_bid == n_kv/R, n_bid + 1 < max_blocks, 0 <= width <= min(cap, n_kv). On failure set a flag and fail the request, instead of a page fault that resets the GPU.Side finding: rocm-debug-agent stops the reset cascade
Without it, every fault here becomes MES hang → MODE1 reset of the XTX → "HW Exception ... GPU Hang" in every ROCm process on the box, so the services on our two other cards die too. With
HSA_TOOLS_LIB=/opt/rocm/lib/librocm-debug-agent.so.2in the engineenv(plus the host'slibdw.so.1inlib_dirs, since the image lacks it), we had a few dozen faults tonight and no reset at all: the faulting waves are halted, the engine exits, and the server restarts it in about 90 s, while the other cards' processes never noticed. The cost was nil for us (16 delivery notes in 472 s vs 471 s). Caveats:unset HSA_TOOLS_LIB(it runs a different ROCm);rocm-dbgapi: fatal error: wave_... not found in queue_N), which restarts the engine (also without a reset).It might be worth a line in docs/AMD_HIP.md for multi-card AMD boxes.
Patches (against 0.1.41; comments translated)
B (what we are running now in a long test: bolle loop, then bolle + 2 agent sessions, until 02:00):
A (the diagnostic one, 41 lines): a
PinnedSteps { int32_t* p; size_t n; cudaEvent_t ev; }member inPrefill::Impl, allocated withcudaHostAllocnext tosteps_host.resize. At prefill.cpp:2160:cudaEventSynchronize(ev),memcpysteps_host into the pinned buffer,cudaMemcpyAsyncfrom it (return checked),cudaEventRecord(ev, m.cs). I can post it in full if useful.Happy to run anything else on this box (2x 7900 XTX + 2x MI50, AVX-only Xeon). We'll post the result of the overnight run with B.
@mantovaniluca91 commented on GitHub (Oct 11, 2026):
Thanks for c1905fc. We tried both switches on our box the same morning: results are below, after the overnight and quality runs.
1. Overnight, production config (4 slots at 262k), real load.
Memory access faultat all. The delivery-note loop alone ran 60 minutes: 156 notes, including the image+text pair that faulted every time before. The engine still restarted 4 times in 75 minutes, each time on the agent's own error (rocm-dbgapi: fatal error: wave_... not found in queue_N). With the agent attached we cannot tell whether those restarts hide a real fault, so we took the agent out.ple_pageablefallback. In the non-mapped branches C also covers the expert routing (ids_hostD2H at 2976,slot_host/src_hostat 3168/3169,bounds_hostat 3252) and the peerP.src/P.bounds. Each bounce slot is reused only after its own event. The ring is borrowed from a global pool, because the second stage runs on a freshstd::asyncthread per chunk.grp_hostis mapped, so the pageable copies that C actually changes at runtime are the draft, token and image-row uploads.2. Quality, same engine C and same config, notes alone. This is our gold set of 16 real delivery notes with 37 reference lines, hand-entered in our ERP. Vision runs on a separate MI50 (gfx906,
cuda_device).The C median is 21.2 s. The mean splits into 10.2 s vision, 8.2 s structure and 3.8 s arbiter. There were 0 faults.
3. c1905fc on gfx1100 (0.1.41 + C, same config).
STRATA_HIP_WMMA=1andSTRATA_SELECT_WMMA=1, both checked in the engine's environment. The log showsSTRATA_HIP_WMMA: the prompt attention on matrix cores on (gfx1100).--no-prefill-borrow) and pipelined across two cards, which may explain part of it.4. Four-hour stress on the real engine. Same setup: C with both switches, production config.
max_tokensunder the strict grammar.Where this leaves us. On this box, B removes the deterministic fault. C has held our heaviest realistic load for two hours, and then a four-hour stress with 6 clients on 4 slots. Its quality is better than our current model. We plan to run C in production until there is an upstream fix. Two questions:
Patch C against 0.1.41 (prefill.cpp, qsa.cu, qsa.hpp)
@Niko1221 commented on GitHub (Oct 11, 2026):
Thank you for tracing this so far, down to the upload line and the two patches; that made it a small change on our side.
0.1.43 takes your patch A in our own form: a prompt chunk's QSA step records, and the batched token ids (same shape: a vector refilled every chunk), now go up from a pinned buffer guarded by an event, and a failed upload is reported instead of ignored. Without pinned RAM it falls back to the old copy. It gives the same answers (identity gate on an R9700 and an RTX 3060, a 20K-token prompt byte-identical) and costs nothing measurable on prompt speed.
We have no RX 7000 card, so we could not run your image-then-text repro ourselves. Could you try it on 0.1.43 and tell us whether the fault is gone? If it still happens, the engine's last lines before the fault would help.