[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

Closed
opened 2026-11-04 01:45:03 +07:00 by bsakaguchi · 7 comments
Owner

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 with
Memory 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) or
strata 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), with STRATA_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 reset
of that XTX (VRAM is lost due to GPU reset!; 9 resets of that card in ~22 h). The reset is then reported to every ROCm
process 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 Hang at
the 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

Strata 0.1.40 / 0.1.40.1 (tests 06-09/10); 0.1.41 (fb58e0d) from 09/10 10:34
Build local-hip, archs gfx1100, isa_floor: avx (EXPERIMENTAL older-CPU build), vision cpu
GPUs used 2x Radeon RX 7900 XTX 24 GB (gfx1100), layer split 27 (0-26 / 27-47), --trim-stage-weights
Other GPUs in the box 2x Instinct MI50 32 GB (gfx906) running llama.cpp (ROCm 6.1.2), not visible to Strata's container
PCIe Intel S2600CP (C602), PCIe 3.0 x8 slots; each XTX sits behind its own Navi switch
CPU / RAM 2x Xeon E5-2630 v2 (Ivy Bridge, AVX, no AVX2), 12 cores, 2 NUMA nodes, 125 GB DDR3
OS / kernel Ubuntu 22.04.5, kernel 6.8.0-138-generic, in-kernel amdgpu, iommu=pt, amdgpu.ppfeaturemask=0xffffffff
ROCm container rocm/dev-ubuntu-24.04:7.2.4-complete (engine built and run inside it, --device /dev/kfd + 2 render nodes)
Model Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS (ISTA-DASLab), native pack iq3_xxs, MTP rt, --kv int8 --kv-resident 32768
Server config reasoning_budget_tokens 4096, --max-context 65536 / 131072 / 262144, parallel 1-4, --batch-groups 1/2/3/auto, optionally --conversation-cache-mib 16384 --conversation-cache-slots N
THP / NUMA THP madvise; kernel.numa_balancing 1 (also tested with 0)

What we measured

date config concurrent duration faults
06-07/10 0.1.39-0.1.40, 64k, parallel 1, XTX on two sockets (node 0 + node 1) 1 ~15 h 7 (~0.5/h), always at the start of a request after a pause
08/10 day 0.1.40, XTX moved under the same socket, 64k-262k, parallel 1/2/4, batch-groups 1-2, no parking 1-4, short tests ~3.5 h engine time 0
08/10 17:38 262k, parallel 4, batch-groups 2, parking 4x16 GiB 4 agent sessions 75 min 2 (17:58, 18:39), both right after conversation cache: restored ... (checkpoint)
09/10 08:38 same, no parking 4 ~35 min 1 after ~15 min, right after strata batch: slot 2 takes 21599 tokens
09/10 09:25 same as 08/10 17:38 (parking) with kernel.numa_balancing=0 4 ~15 min 1 after ~6 min, right after conversation cache: parked/restored
09/10 09:52 262k, parallel 3, batch-groups 3, parking 3 3 22 min 1 after 22 min
09/10 10:34 0.1.41, 262k, parallel 4, batch-groups auto, parking 4x16 GiB, without --remote-expert-opt 4 29 min 1 after 29 min, right after conversation cache: restored 26338 tokens (checkpoint)
09/10 11:06 0.1.41, same, parallel 3 3 24 min 1 after 24 min, right after conversation cache: parked
09/10 11:37 0.1.41, 4 at 262k + STRATA_HIP_ADAPT_KERNEL_COPY=1 (its startup line was in the log) 4 25 min 1 after 25 min, right after conversation cache: restored 26552 tokens (checkpoint)
09/10 12:14 0.1.41, 4 at 262k + HSA_ENABLE_SDMA=0 (checked in the engine's /proc/<pid>/environ) 4 19 min 1 after 19 min, right after conversation cache: restored 30664 tokens (checkpoint)
09/10 12:42 0.1.41, 4 at 262k, no --kv-resident (KV fully in VRAM, 0 KV streaming lines; slot sessions 7.5 GiB per card) 4 30 min 0 (37 restores, 116 slot admissions)
09/10 13:15 0.1.41, same (KV in VRAM) at 131k 4 27 min 1 after 27 min, right after 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):

strata batch: slot 0 takes 31592 tokens (copied in 278.8 ms)
strata serve: prompt 31592 tokens = 31591 reused + 1 read in 6 ms (179.1 tok/s), 1 generated in 27 ms (37.5 tok/s), drafts accepted 0 of 0, 0 checkpoints
strata serve: decode expert cache hit rate: 100.0% (480 hits / 480 lookups)
strata serve: conversation cache: parked 31592 tokens in 200.5 ms; parked=4 bytes=4109642032 evictions=46 snapshot_bytes=600915304 reused_kv_bytes=0
strata batch: slot 2 gave back 25734 tokens of this conversation (its turn checkpoint) in 253.1 ms
Memory access fault by GPU node-2 (Agent handle: 0x94e5490) on address 0x732b48cce000. Reason: Page not present or supervisor privilege.

0.1.41, HSA_ENABLE_SDMA=0, 262k with KV streaming (09/10 12:33 local):

strata serve: conversation cache: dropped 1 superseded copy of this conversation; parked=2
strata serve: conversation cache: parked 56599 tokens in 787.4 ms; parked=3 bytes=3569736360 evictions=15 snapshot_bytes=1220564336 reused_kv_bytes=0
strata serve: conversation cache: restored 30664 tokens (checkpoint) in 230.0 ms; parked=3 bytes=4586586976
Memory access fault by GPU node-2 (Agent handle: 0x8b054a0) on address 0x7a39932e1000. Reason: Page not present or supervisor privilege.

0.1.40, numa_balancing=0 (09/10 09:34 local):

strata serve: conversation cache: restored 30012 tokens (checkpoint) in 192.5 ms; parked=4 bytes=7663099208
strata batch: slot 0 takes 31087 tokens (copied in 540.8 ms)
strata serve: prompt 31087 tokens = 30012 reused + 1075 read in 2469 ms (435.3 tok/s), 1 generated in 30 ms (33.3 tok/s), drafts accepted 0 of 0, 5 checkpoints
strata serve: decode expert cache hit rate: 100.0% (480 hits / 480 lookups)
strata serve: KV streaming: 54.89% of 15402 block reads hit VRAM, 28.0 MiB read from RAM
strata serve: conversation cache: parked 31087 tokens in 277.3 ms; parked=4 bytes=6721475160 evictions=19 snapshot_bytes=1622688976 reused_kv_bytes=458098944
Memory access fault by GPU node-2 (Agent handle: 0x1e5a3400) on address 0x7e747485b000. Reason: Page not present or supervisor privilege.

Without parking (09/10 08:57):

strata batch: slot 2 takes 21599 tokens (copied in 490.4 ms)
strata serve: prompt 21599 tokens = 17796 reused + 3803 read in 3382 ms (1124.5 tok/s), 1 generated in 28 ms (35.8 tok/s), drafts accepted 0 of 0, 4 checkpoints
strata serve: decode expert cache hit rate: 100.0% (480 hits / 480 lookups)
strata serve: KV streaming: 97.11% of 1716048 block reads hit VRAM, 199.5 MiB read from RAM
Memory access fault by GPU node-2 (Agent handle: 0xd5ee3c0) on address 0x70d707d16000. Reason: Page not present or supervisor privilege.

Server side, every time: the engine stopped unexpectedly (exit code -6) once per in-flight request, then
the engine had stopped (exit code -6); starting it again. No OOM: 60+ GB of RAM were available during the tests.
node-2 is the first GPU visible in the container, i.e. the XTX running layers 0-26 (node-4 / PCI 0000:09:00.0 on 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):

amdgpu 0000:09:00.0: amdgpu: [gfxhub] page fault (src_id:0 ring:24 vmid:8 pasid:32783, for process strata pid 2716527 thread strata pid 2716527)
amdgpu 0000:09:00.0: amdgpu:   in page starting at address 0x0000732b48cce000 from client 10
amdgpu 0000:09:00.0: amdgpu: GCVM_L2_PROTECTION_FAULT_STATUS:0x00000000
amdgpu 0000:09:00.0: amdgpu:          Faulty UTCL2 client ID: CB/DB (0x0)
amdgpu 0000:09:00.0: amdgpu:          MORE_FAULTS: 0x0
amdgpu 0000:09:00.0: amdgpu:          WALKER_ERROR: 0x0
amdgpu 0000:09:00.0: amdgpu:          PERMISSION_FAULTS: 0x0
amdgpu 0000:09:00.0: amdgpu:          MAPPING_ERROR: 0x0
amdgpu 0000:09:00.0: amdgpu:          RW: 0x0
   (five such faults in the same second, pages 0x732acdc6b000, 0x732ad92af000, 0x732ad57df000, 0x732b48cce000, 0x732ac96e4000)
[drm:mes_v11_0_submit_pkt_and_poll_completion.constprop.0 [amdgpu]] *ERROR* MES failed to response msg=3
amdgpu 0000:09:00.0: amdgpu: failed to remove hardware queue from MES, doorbell=0x1004
amdgpu 0000:09:00.0: amdgpu: MES might be in unrecoverable state, issue a GPU reset
amdgpu 0000:09:00.0: amdgpu: Failed to evict queue 3   (then 2, 1, 0)
amdgpu 0000:09:00.0: amdgpu: GPU reset begin!
amdgpu: sq_intr: error, detail 0x00000000, type 2, sh 1, priv 1, wave_id 0, simd_id 0, wgp_id 0   (x10)
[drm:amdgpu_mes_unmap_legacy_queue [amdgpu]] *ERROR* failed to unmap legacy queue   (x8)
amdgpu 0000:09:00.0: amdgpu: MODE1 reset
[drm] VRAM is lost due to GPU reset!
amdgpu 0000:09:00.0: amdgpu: GPU reset(9) succeeded!

Other ROCm processes (MI50 only), same second:

HW Exception by GPU node-4 (Agent handle: 0x573d53a658e0) reason :GPU Hang      (x4, then exit status 139 / SIGABRT)

Other findings that may help

  1. /metrics totals.decode_ms is far too small with batching. 12 batched requests wrote 3,711 tokens, and the sum of
    their decode_ms is 323.6 ms, while each request's decode_tok_s says 34-36 tok/s (~109 s in total).
    output_tokens / decode_ms then gives "750 tok/s". The per-request decode_tok_s looks right.
  2. The GPU image encoder works on AMD with a stock build. tools/vision built with -DGGML_HIP=ON -DAMDGPU_TARGETS=gfx906 -DCMAKE_EXE_LINKER_FLAGS=-no-pie (ROCm 6.1.2; -no-pie is needed because libggml-hip.a is not PIC), started by
    server.py through a wrapper that sets LD_LIBRARY_PATH to ROCm 6.1, with "vision": {"gpu": true, "cuda_device": 0}
    on a spare MI50 and env.HIP_VISIBLE_DEVICES = "1,2" for the engine.
    • Speed: 1.1 s per image instead of 91 s on the CPU, +1.4 GiB of VRAM.
    • Output: per-row cosine vs the CPU encoder, median 0.9993 (min 0.954).
    • Real task, 16 delivery notes: 17.4 s per document instead of 150 s; 32/37 fields right vs 33/37 with the CPU encoder.
    • No source change needed.
  3. Throughput on this box (0.1.40, IQ3_XXS, 2x XTX, layer split 27, trim):
    • one request: 68-80 tok/s decode;
    • fresh prompts: 116k tokens read in 49 s (2,431 tok/s), 229k in 116 s; decode 59-61 tok/s at 230k context;
    • parallel 4 without batch-groups: 39-42 tok/s in total, no gain (the cards work in turn);
    • with --batch-groups 2: up to 59 tok/s in total, 17-32 tok/s per request.
    • 0.1.41, 4 agent sessions at 131k, KV in VRAM, batch-groups auto: median 36 tok/s per request (112 turns of 200+
      tokens, from /metrics requests), expert hit rate 99.8%; 19,557 of 24,576 experts in VRAM (13,918 at 262k).
  4. --shared-expert-arena works 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.arena on a host /dev/shm
    directory: 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,560
    experts of all 48 layers, the decode hit rate falls to 75-85% and requests decode at 1.3-2.5 tok/s.
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 with `Memory 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)` or `strata 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`), with `STRATA_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 reset** of that XTX (`VRAM is lost due to GPU reset!`; 9 resets of that card in ~22 h). The reset is then reported to **every ROCm process 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 Hang` at the 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 | | | |---|---| | Strata | 0.1.40 / 0.1.40.1 (tests 06-09/10); 0.1.41 (fb58e0d) from 09/10 10:34 | | Build | `local-hip`, archs gfx1100, `isa_floor: avx` (EXPERIMENTAL older-CPU build), vision cpu | | GPUs used | 2x Radeon RX 7900 XTX 24 GB (gfx1100), layer split 27 (0-26 / 27-47), `--trim-stage-weights` | | Other GPUs in the box | 2x Instinct MI50 32 GB (gfx906) running llama.cpp (ROCm 6.1.2), not visible to Strata's container | | PCIe | Intel S2600CP (C602), PCIe 3.0 x8 slots; each XTX sits behind its own Navi switch | | CPU / RAM | 2x Xeon E5-2630 v2 (Ivy Bridge, AVX, no AVX2), 12 cores, 2 NUMA nodes, 125 GB DDR3 | | OS / kernel | Ubuntu 22.04.5, kernel 6.8.0-138-generic, in-kernel amdgpu, `iommu=pt`, `amdgpu.ppfeaturemask=0xffffffff` | | ROCm | container `rocm/dev-ubuntu-24.04:7.2.4-complete` (engine built and run inside it, `--device /dev/kfd` + 2 render nodes) | | Model | Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS (ISTA-DASLab), native pack `iq3_xxs`, MTP rt, `--kv int8 --kv-resident 32768` | | Server config | `reasoning_budget_tokens 4096`, `--max-context` 65536 / 131072 / 262144, `parallel` 1-4, `--batch-groups` 1/2/3/auto, optionally `--conversation-cache-mib 16384 --conversation-cache-slots N` | | THP / NUMA | THP madvise; `kernel.numa_balancing` 1 (also tested with 0) | ## What we measured | date | config | concurrent | duration | faults | |---|---|---:|---|---:| | 06-07/10 | 0.1.39-0.1.40, 64k, parallel 1, XTX on **two sockets** (node 0 + node 1) | 1 | ~15 h | 7 (~0.5/h), always at the start of a request after a pause | | 08/10 day | 0.1.40, XTX moved under the **same socket**, 64k-262k, parallel 1/2/4, batch-groups 1-2, no parking | 1-4, short tests | ~3.5 h engine time | **0** | | 08/10 17:38 | 262k, parallel 4, batch-groups 2, **parking 4x16 GiB** | 4 agent sessions | 75 min | **2** (17:58, 18:39), both right after `conversation cache: restored ... (checkpoint)` | | 09/10 08:38 | same, **no parking** | 4 | ~35 min | **1** after ~15 min, right after `strata batch: slot 2 takes 21599 tokens` | | 09/10 09:25 | same as 08/10 17:38 (parking) with **`kernel.numa_balancing=0`** | 4 | ~15 min | **1** after ~6 min, right after `conversation cache: parked/restored` | | 09/10 09:52 | 262k, parallel 3, batch-groups 3, parking 3 | 3 | 22 min | **1** after 22 min | | 09/10 10:34 | **0.1.41**, 262k, parallel 4, batch-groups auto, parking 4x16 GiB, without `--remote-expert-opt` | 4 | 29 min | **1** after 29 min, right after `conversation cache: restored 26338 tokens (checkpoint)` | | 09/10 11:06 | 0.1.41, same, parallel 3 | 3 | 24 min | **1** after 24 min, right after `conversation cache: parked` | | 09/10 11:37 | 0.1.41, 4 at 262k + `STRATA_HIP_ADAPT_KERNEL_COPY=1` (its startup line was in the log) | 4 | 25 min | **1** after 25 min, right after `conversation cache: restored 26552 tokens (checkpoint)` | | 09/10 12:14 | 0.1.41, 4 at 262k + `HSA_ENABLE_SDMA=0` (checked in the engine's `/proc/<pid>/environ`) | 4 | 19 min | **1** after 19 min, right after `conversation cache: restored 30664 tokens (checkpoint)` | | 09/10 12:42 | 0.1.41, 4 at 262k, **no `--kv-resident`** (KV fully in VRAM, 0 `KV streaming` lines; slot sessions 7.5 GiB per card) | 4 | 30 min | **0** (37 restores, 116 slot admissions) | | 09/10 13:15 | 0.1.41, same (KV in VRAM) at **131k** | 4 | 27 min | **1** after 27 min, right after `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): ``` strata batch: slot 0 takes 31592 tokens (copied in 278.8 ms) strata serve: prompt 31592 tokens = 31591 reused + 1 read in 6 ms (179.1 tok/s), 1 generated in 27 ms (37.5 tok/s), drafts accepted 0 of 0, 0 checkpoints strata serve: decode expert cache hit rate: 100.0% (480 hits / 480 lookups) strata serve: conversation cache: parked 31592 tokens in 200.5 ms; parked=4 bytes=4109642032 evictions=46 snapshot_bytes=600915304 reused_kv_bytes=0 strata batch: slot 2 gave back 25734 tokens of this conversation (its turn checkpoint) in 253.1 ms Memory access fault by GPU node-2 (Agent handle: 0x94e5490) on address 0x732b48cce000. Reason: Page not present or supervisor privilege. ``` 0.1.41, `HSA_ENABLE_SDMA=0`, 262k with KV streaming (09/10 12:33 local): ``` strata serve: conversation cache: dropped 1 superseded copy of this conversation; parked=2 strata serve: conversation cache: parked 56599 tokens in 787.4 ms; parked=3 bytes=3569736360 evictions=15 snapshot_bytes=1220564336 reused_kv_bytes=0 strata serve: conversation cache: restored 30664 tokens (checkpoint) in 230.0 ms; parked=3 bytes=4586586976 Memory access fault by GPU node-2 (Agent handle: 0x8b054a0) on address 0x7a39932e1000. Reason: Page not present or supervisor privilege. ``` 0.1.40, numa_balancing=0 (09/10 09:34 local): ``` strata serve: conversation cache: restored 30012 tokens (checkpoint) in 192.5 ms; parked=4 bytes=7663099208 strata batch: slot 0 takes 31087 tokens (copied in 540.8 ms) strata serve: prompt 31087 tokens = 30012 reused + 1075 read in 2469 ms (435.3 tok/s), 1 generated in 30 ms (33.3 tok/s), drafts accepted 0 of 0, 5 checkpoints strata serve: decode expert cache hit rate: 100.0% (480 hits / 480 lookups) strata serve: KV streaming: 54.89% of 15402 block reads hit VRAM, 28.0 MiB read from RAM strata serve: conversation cache: parked 31087 tokens in 277.3 ms; parked=4 bytes=6721475160 evictions=19 snapshot_bytes=1622688976 reused_kv_bytes=458098944 Memory access fault by GPU node-2 (Agent handle: 0x1e5a3400) on address 0x7e747485b000. Reason: Page not present or supervisor privilege. ``` Without parking (09/10 08:57): ``` strata batch: slot 2 takes 21599 tokens (copied in 490.4 ms) strata serve: prompt 21599 tokens = 17796 reused + 3803 read in 3382 ms (1124.5 tok/s), 1 generated in 28 ms (35.8 tok/s), drafts accepted 0 of 0, 4 checkpoints strata serve: decode expert cache hit rate: 100.0% (480 hits / 480 lookups) strata serve: KV streaming: 97.11% of 1716048 block reads hit VRAM, 199.5 MiB read from RAM Memory access fault by GPU node-2 (Agent handle: 0xd5ee3c0) on address 0x70d707d16000. Reason: Page not present or supervisor privilege. ``` Server side, every time: `the engine stopped unexpectedly (exit code -6)` once per in-flight request, then `the engine had stopped (exit code -6); starting it again`. No OOM: 60+ GB of RAM were available during the tests. `node-2` is the first GPU visible in the container, i.e. the XTX running layers 0-26 (`node-4` / PCI `0000:09:00.0` on 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`): ``` amdgpu 0000:09:00.0: amdgpu: [gfxhub] page fault (src_id:0 ring:24 vmid:8 pasid:32783, for process strata pid 2716527 thread strata pid 2716527) amdgpu 0000:09:00.0: amdgpu: in page starting at address 0x0000732b48cce000 from client 10 amdgpu 0000:09:00.0: amdgpu: GCVM_L2_PROTECTION_FAULT_STATUS:0x00000000 amdgpu 0000:09:00.0: amdgpu: Faulty UTCL2 client ID: CB/DB (0x0) amdgpu 0000:09:00.0: amdgpu: MORE_FAULTS: 0x0 amdgpu 0000:09:00.0: amdgpu: WALKER_ERROR: 0x0 amdgpu 0000:09:00.0: amdgpu: PERMISSION_FAULTS: 0x0 amdgpu 0000:09:00.0: amdgpu: MAPPING_ERROR: 0x0 amdgpu 0000:09:00.0: amdgpu: RW: 0x0 (five such faults in the same second, pages 0x732acdc6b000, 0x732ad92af000, 0x732ad57df000, 0x732b48cce000, 0x732ac96e4000) [drm:mes_v11_0_submit_pkt_and_poll_completion.constprop.0 [amdgpu]] *ERROR* MES failed to response msg=3 amdgpu 0000:09:00.0: amdgpu: failed to remove hardware queue from MES, doorbell=0x1004 amdgpu 0000:09:00.0: amdgpu: MES might be in unrecoverable state, issue a GPU reset amdgpu 0000:09:00.0: amdgpu: Failed to evict queue 3 (then 2, 1, 0) amdgpu 0000:09:00.0: amdgpu: GPU reset begin! amdgpu: sq_intr: error, detail 0x00000000, type 2, sh 1, priv 1, wave_id 0, simd_id 0, wgp_id 0 (x10) [drm:amdgpu_mes_unmap_legacy_queue [amdgpu]] *ERROR* failed to unmap legacy queue (x8) amdgpu 0000:09:00.0: amdgpu: MODE1 reset [drm] VRAM is lost due to GPU reset! amdgpu 0000:09:00.0: amdgpu: GPU reset(9) succeeded! ``` Other ROCm processes (MI50 only), same second: ``` HW Exception by GPU node-4 (Agent handle: 0x573d53a658e0) reason :GPU Hang (x4, then exit status 139 / SIGABRT) ``` ## Other findings that may help 1. **`/metrics` `totals.decode_ms` is far too small with batching.** 12 batched requests wrote 3,711 tokens, and the sum of their `decode_ms` is 323.6 ms, while each request's `decode_tok_s` says 34-36 tok/s (~109 s in total). `output_tokens / decode_ms` then gives "750 tok/s". The per-request `decode_tok_s` looks right. 2. **The GPU image encoder works on AMD with a stock build.** `tools/vision` built with `-DGGML_HIP=ON -DAMDGPU_TARGETS=gfx906 -DCMAKE_EXE_LINKER_FLAGS=-no-pie` (ROCm 6.1.2; `-no-pie` is needed because `libggml-hip.a` is not PIC), started by `server.py` through a wrapper that sets `LD_LIBRARY_PATH` to ROCm 6.1, with `"vision": {"gpu": true, "cuda_device": 0}` on a spare MI50 and `env.HIP_VISIBLE_DEVICES = "1,2"` for the engine. - Speed: 1.1 s per image instead of 91 s on the CPU, +1.4 GiB of VRAM. - Output: per-row cosine vs the CPU encoder, median 0.9993 (min 0.954). - Real task, 16 delivery notes: 17.4 s per document instead of 150 s; 32/37 fields right vs 33/37 with the CPU encoder. - No source change needed. 3. **Throughput on this box** (0.1.40, IQ3_XXS, 2x XTX, layer split 27, trim): - one request: 68-80 tok/s decode; - fresh prompts: 116k tokens read in 49 s (2,431 tok/s), 229k in 116 s; decode 59-61 tok/s at 230k context; - `parallel 4` without batch-groups: 39-42 tok/s in total, no gain (the cards work in turn); - with `--batch-groups 2`: up to 59 tok/s in total, 17-32 tok/s per request. - 0.1.41, 4 agent sessions at 131k, KV in VRAM, batch-groups auto: median 36 tok/s per request (112 turns of 200+ tokens, from `/metrics` `requests`), expert hit rate 99.8%; 19,557 of 24,576 experts in VRAM (13,918 at 262k). 4. **`--shared-expert-arena` works 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.arena` on a host /dev/shm directory: 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,560 experts of all 48 layers, the decode hit rate falls to 75-85% and requests decode at 1.3-2.5 tok/s.
Author
Owner

@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.

config duration slot admissions faults
--batch-groups auto (2 groups, "pipelined" in the log) 6 runs, 19-29 min each ~100-160 per run 1 per run
--batch-groups 1 30 min 162 (102 give-backs, 19 restores) 0
--batch-groups 1 65 min 354 (213 give-backs, 45 restores) 1

The fault point is the same as before:

strata batch: slot 3 takes 17705 tokens (copied in 261.4 ms)
strata serve: conversation cache: parked 17705 tokens in 179.1 ms; parked=4 bytes=3493607936 evictions=56 snapshot_bytes=974770560 reused_kv_bytes=266692608
strata batch: slot 0 gave back 25894 tokens of this conversation (its turn checkpoint) in 304.0 ms
Memory access fault by GPU node-2 (Agent handle: 0x20b1a4a0) on address 0x73af4046d000. Reason: Page not present or supervisor privilege.

--pipeline-windows was never set (default 0). Decode speed per request was the same with and without pipelining for this
agent load (median 34 vs 36 tok/s per turn, from /metrics requests).

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.

<!-- gh-comment-id:6082813334 --> @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.** | config | duration | slot admissions | faults | |---|---|---:|---:| | `--batch-groups auto` (2 groups, "pipelined" in the log) | 6 runs, 19-29 min each | ~100-160 per run | 1 per run | | `--batch-groups 1` | 30 min | 162 (102 give-backs, 19 restores) | 0 | | `--batch-groups 1` | 65 min | 354 (213 give-backs, 45 restores) | 1 | The fault point is the same as before: ``` strata batch: slot 3 takes 17705 tokens (copied in 261.4 ms) strata serve: conversation cache: parked 17705 tokens in 179.1 ms; parked=4 bytes=3493607936 evictions=56 snapshot_bytes=974770560 reused_kv_bytes=266692608 strata batch: slot 0 gave back 25894 tokens of this conversation (its turn checkpoint) in 304.0 ms Memory access fault by GPU node-2 (Agent handle: 0x20b1a4a0) on address 0x73af4046d000. Reason: Page not present or supervisor privilege. ``` `--pipeline-windows` was never set (default 0). Decode speed per request was the same with and without pipelining for this agent load (median 34 vs 36 tok/s per turn, from `/metrics` `requests`). 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.
Author
Owner

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

Found it, I think - and there is a workaround: --no-prefill-borrow makes 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 in
attn_chunk_kernel<1, false>, launched by the prompt read (prefill.cpp ~2764-2771: on gfx1100 qsa_prompt_attn_batch
returns 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).
  • the faulting load is p.page_table[cell / page_size] (qsa_decode_attn.cu ~L117) with cell = 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.
  • the selected cells are a clean, sorted, block-aligned top-k (255334..316467), so the step record the kernels read on the
    device said n_kv > 316k, while the conversation was ~29k tokens and the host positions are in range (the indexer's
    p0 + n > max_cells guard never fired). The device-side steps_dev / sel_ids do not match what the host wrote.

Why we think it is the borrowed slots: steps_dev, sel_ids, sel_scores and the stage pool are carved from the expert-cache
slots the prompt path borrows (the prompt path borrows 2388 CUDA0 cache slots), and something else writes into them while the
prompt 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):

config runs result
default (prompt buffers borrowed from the expert cache) 7 runs 7 faults, after 11-29 min (~100-170 slot admissions)
--no-prefill-borrow 1 run, 90 min 0 faults: 430 slot admissions, 182 give-backs, 136 conversation restores, 41 agent requests done

(--no-prefill-borrow confirmed in the engine started line, and no borrows ... cache slots line 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 1 and 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 not
take the whole GPU down, and a look at who can write into the lent slots while a prompt is read on a layer split.

<!-- gh-comment-id:6089508447 --> @mantovaniluca91 commented on GitHub (Oct 9, 2026): Found it, I think - and there is a workaround: **`--no-prefill-borrow` makes 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 in `attn_chunk_kernel<1, false>`, launched by the **prompt read** (prefill.cpp ~2764-2771: on gfx1100 `qsa_prompt_attn_batch` returns 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). - the faulting load is `p.page_table[cell / page_size]` (qsa_decode_attn.cu ~L117) with `cell = 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. - the selected cells are a clean, sorted, block-aligned top-k (255334..316467), so the step record the kernels read on the device said n_kv > 316k, while the conversation was ~29k tokens and the host positions are in range (the indexer's `p0 + n > max_cells` guard never fired). The device-side `steps_dev` / `sel_ids` do not match what the host wrote. **Why we think it is the borrowed slots:** `steps_dev`, `sel_ids`, `sel_scores` and the stage pool are carved from the expert-cache slots the prompt path borrows (`the prompt path borrows 2388 CUDA0 cache slots`), and something else writes into them while the prompt 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):** | config | runs | result | |---|---|---| | default (prompt buffers borrowed from the expert cache) | 7 runs | 7 faults, after 11-29 min (~100-170 slot admissions) | | `--no-prefill-borrow` | 1 run, 90 min | **0 faults**: 430 slot admissions, 182 give-backs, 136 conversation restores, 41 agent requests done | (`--no-prefill-borrow` confirmed in the `engine started` line, and no `borrows ... cache slots` line 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 1` and 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 not take the whole GPU down, and a look at who can write into the lent slots while a prompt is read on a layer split.
Author
Owner

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

Follow-up after a longer run: --no-prefill-borrow removes 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 match
the 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:

  • The attention reads n_ids = step[kStepWidth] = 1712 for row z=0 and 41710 for row z=2. Both break width <= cap (2051),
    and qsa_step_fill (qsa.cu:709-714) can never produce them. The kernel does not clamp n_ids to cap (qsa_decode_attn.cu:~101).
  • The ids rows show the top-k also saw foreign records: row 0 holds the identity 0..486 (top-k saw n_kv = 487), row 2 a sorted
    selection of 362 cells ending at 2651. For a chunk at p0 ~ 37k both should be 2051-wide sparse selections reaching ~37k.
  • Past what the top-k wrote, sel_ids holds 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_dev is written only by the H2D at prefill.cpp:2159-2161
as 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:

  1. Defensive, so a bad record cannot reset the GPU (and, here, kill the processes on the other cards): in attn_chunk_kernel use
    min(step[kStepWidth], cap) and mask any cell outside [0, n_pages * page_size) as page -1; clamp n_bid / width in the top-k.
  2. To find the writer: a check kernel after the steps upload and again before the attention loop
    (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.

<!-- gh-comment-id:6094867502 --> @mantovaniluca91 commented on GitHub (Oct 10, 2026): Follow-up after a longer run: `--no-prefill-borrow` removes 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 match the 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:** - The attention reads `n_ids = step[kStepWidth]` = **1712** for row z=0 and **41710** for row z=2. Both break `width <= cap (2051)`, and `qsa_step_fill` (qsa.cu:709-714) can never produce them. The kernel does not clamp `n_ids` to `cap` (qsa_decode_attn.cu:~101). - The ids rows show the top-k also saw foreign records: row 0 holds the identity 0..486 (top-k saw n_kv = 487), row 2 a sorted selection of 362 cells ending at 2651. For a chunk at p0 ~ 37k both should be 2051-wide sparse selections reaching ~37k. - Past what the top-k wrote, `sel_ids` holds 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_dev` is written only by the H2D at prefill.cpp:2159-2161 as 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:** 1. Defensive, so a bad record cannot reset the GPU (and, here, kill the processes on the other cards): in `attn_chunk_kernel` use `min(step[kStepWidth], cap)` and mask any cell outside `[0, n_pages * page_size)` as page -1; clamp `n_bid` / width in the top-k. 2. To find the writer: a check kernel after the steps upload and again before the attention loop (`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.
Author
Owner

@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.

<!-- gh-comment-id:6099706521 --> @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.
Author
Owner

@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)

  1. Request A: an image request (vision): a scanned page, about 1803 prompt tokens, then decode (we tried 200, 300 and 825 generated tokens: all three trigger it).
  2. Request B, right after: the first text-only request after the image, a new conversation of 2142 prompt tokens. With --no-prefill-borrow the 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_TRACE lines end with prompt chunk 2048 of 2135 on CUDA0 (while CUDA1 runs prompt chunk 0 of 2048). The trigger needs all three of these:

Sequence Result
A (image) then B faults almost every time: every run from 15:30 to 20:10, then it held twice in a 20-minute window, then 5 of 5 in the final controlled run
B alone OK
nine text-only requests in a row ending with B OK
a text-only request that decodes to cell 2637, then B OK (so it is not the decode length alone: it needs the image)
A, then a short single-chunk text request, then B OK (only the first text request after an image is exposed)
synthetic image + synthetic text of the same sizes (2190-token text, 2 chunks) OK: the bytes involved are data-dependent, see below
the full delivery-note sequence while 2 agent sessions run in batch OK (there the main session only reads prompts, "1 generated", and decoding happens in the slots)

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 reads sc[t*per] 0.5-1.5 GB past sel_scores. block_scores does not fault because its grid is bounded by active, 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 replacing auto; the engine log confirms 1 group); without --mtp (--spec cannot 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=1048576 in 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_dev back 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 own rocm-dbgapi error). 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_dev has exactly one writer, the cudaMemcpyAsync at prefill.cpp:2160. Its source is m.steps_host, a std::vector (pageable), and the return value is not checked. Right before it, the image request has uploaded about 1,200 embedding rows with cudaMemcpyAsync from pageable img_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):

Engine Faults
0.1.41 as shipped 5 of 5
A: same upload, but from a pinned buffer (event-guarded, return checked) 0 of 5
B: step records written on the device by a tiny kernel, rewritten before the indexer append and before the selection of each QSA layer 0 of 5

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_kernel faults (ids past ident_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:

  1. Use pinned sources for every async H2D in the prompt path, not only the step records: tok_host (prefill.cpp:2090) and the image rows have the same exposure. layer.hpp:263-272 already asks for pinned, fixed sources for step uploads; the prompt path does not follow it. Check the return values.
  2. Or write the step records on the device (patch B below). They are a pure function of the position.
  3. Validate the record in 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.2 in the engine env (plus the host's libdw.so.1 in lib_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:

  • the vision encoder inherits the engine env, so we start it through a wrapper that does unset HSA_TOOLS_LIB (it runs a different ROCm);
  • the agent sometimes dies on its own (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/src/kernels/cuda/qsa.cu
+++ b/src/kernels/cuda/qsa.cu
@@ -696,6 +696,26 @@
 // ================= host entry points =================
 
+static __global__ void steps_fill_kernel(int32_t* st, int64_t p0, int64_t n, int64_t idx_block, int64_t wcap) {
+    const int64_t t = (int64_t) blockIdx.x * blockDim.x + threadIdx.x;
+    if (t >= n) return;
+    const int64_t pos = p0 + t, n_kv = pos + 1;
+    int32_t* r = st + t * kStepCount;
+    r[kStepPos] = (int32_t) pos;
+    r[kStepNKv] = (int32_t) n_kv;
+    r[kStepNBid] = (int32_t) (n_kv / idx_block);
+    r[kStepWidth] = (int32_t) (n_kv < wcap ? n_kv : wcap);   // = qsa_selection_width(n_kv, s)
+}
+
+void qsa_steps_fill_dev(int32_t* steps, int64_t p0, int64_t n, const QsaShapes& s, void* stream) {
+    if (steps == nullptr || n <= 0) return;
+    if (p0 < 0) fail("qsa_steps_fill_dev: p0 < 0");
+    const int64_t wcap = s.idx_top_k + s.idx_block - 1;   // qsa_selection_width's bound
+    steps_fill_kernel<<<(unsigned) ((n + 255) / 256), 256, 0, (cudaStream_t) stream>>>(steps, p0, n,
+                                                                                  (int64_t) s.idx_block, wcap);
+    check_launch("qsa_steps_fill_dev");
+}
+
 void qsa_step_fill(int32_t* host_step, int64_t pos, const QsaShapes& s) {
--- a/include/strata/kernels/qsa.hpp
+++ b/include/strata/kernels/qsa.hpp
@@ -172,6 +172,9 @@
 void qsa_step_fill(int32_t* host_step, int64_t pos, const QsaShapes& s);
 
+/// The records qsa_step_fill writes for positions p0 .. p0+n-1, written on the device by one kernel on `stream`.
+void qsa_steps_fill_dev(int32_t* steps, int64_t p0, int64_t n, const QsaShapes& s, void* stream);
+
--- a/src/prefill/prefill.cpp
+++ b/src/prefill/prefill.cpp
@@ -2157,8 +2157,8 @@
         for (int64_t t = 0; t < T; ++t) strata::kernels::qsa_step_fill(m.steps_host.data() + t * strata::kernels::kStepCount, p0 + t, s);
-        cudaMemcpyAsync(m.steps_dev, m.steps_host.data(), (size_t) T * strata::kernels::kStepCount * 4,
-                        cudaMemcpyHostToDevice, m.cs);
+        // steps_host stays for `active`; the device records are written on the device
+        strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs);
@@ -2634,6 +2634,7 @@
                     const strata::kernels::QsaIndexerBuffers ib{st.idx_tail, st.idx_dead, st.idx_pooled, st.idx_block_pos};
+                    strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs);   // again, before the indexer append
                     pt.mark(kPfQsaIdx, cs);
@@ -2651,6 +2652,7 @@
                     } catch (const std::exception& e) { err = std::string("prefill indexer: ") + e.what(); return false; }
+                    strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs);   // and before the selection
                     pt.mark(kPfQsaSel, cs);

A (the diagnostic one, 41 lines): a PinnedSteps { int32_t* p; size_t n; cudaEvent_t ev; } member in Prefill::Impl, allocated with cudaHostAlloc next to steps_host.resize. At prefill.cpp:2160: cudaEventSynchronize(ev), memcpy steps_host into the pinned buffer, cudaMemcpyAsync from 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.

<!-- gh-comment-id:6101558908 --> @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) 1. **Request A**: an image request (vision): a scanned page, about 1803 prompt tokens, then decode (we tried 200, 300 and 825 generated tokens: all three trigger it). 2. **Request B**, right after: the **first text-only request** after the image, a new conversation of **2142 prompt tokens**. With `--no-prefill-borrow` the 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_TRACE` lines end with `prompt chunk 2048 of 2135` on CUDA0 (while CUDA1 runs `prompt chunk 0 of 2048`). The trigger needs all three of these: | Sequence | Result | |---|---| | A (image) then B | **faults almost every time**: every run from 15:30 to 20:10, then it held twice in a 20-minute window, then 5 of 5 in the final controlled run | | B alone | OK | | nine text-only requests in a row ending with B | OK | | a text-only request that decodes to cell 2637, then B | OK (so it is not the decode length alone: it needs the image) | | A, then a short single-chunk text request, then B | OK (only the **first** text request after an image is exposed) | | synthetic image + synthetic text of the same sizes (2190-token text, 2 chunks) | OK: the bytes involved are data-dependent, see below | | the full delivery-note sequence while 2 agent sessions run in batch | OK (there the main session only reads prompts, "1 generated", and decoding happens in the slots) | ## 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 reads `sc[t*per]` 0.5-1.5 GB past sel_scores. block_scores does not fault because its grid is bounded by `active`, 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 replacing `auto`; the engine log confirms 1 group); without `--mtp` (`--spec` cannot 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=1048576` in 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_dev` back 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 own `rocm-dbgapi` error). 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_dev` has exactly one writer, the `cudaMemcpyAsync` at prefill.cpp:2160. Its source is `m.steps_host`, a `std::vector` (pageable), and the return value is not checked. Right before it, the image request has uploaded about 1,200 embedding rows with `cudaMemcpyAsync` from pageable `img_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): | Engine | Faults | |---|---| | 0.1.41 as shipped | **5 of 5** | | A: same upload, but from a **pinned** buffer (event-guarded, return checked) | **0 of 5** | | B: step records **written on the device** by a tiny kernel, rewritten before the indexer append and before the selection of each QSA layer | **0 of 5** | 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_kernel` faults (ids past `ident_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:** 1. Use pinned sources for every async H2D in the prompt path, not only the step records: `tok_host` (prefill.cpp:2090) and the image rows have the same exposure. `layer.hpp:263-272` already asks for pinned, fixed sources for step uploads; the prompt path does not follow it. Check the return values. 2. Or write the step records on the device (patch B below). They are a pure function of the position. 3. Validate the record in `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.2` in the engine `env` (plus the host's `libdw.so.1` in `lib_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: - the vision encoder inherits the engine env, so we start it through a wrapper that does `unset HSA_TOOLS_LIB` (it runs a different ROCm); - the agent sometimes dies on its own (`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): ```diff --- a/src/kernels/cuda/qsa.cu +++ b/src/kernels/cuda/qsa.cu @@ -696,6 +696,26 @@ // ================= host entry points ================= +static __global__ void steps_fill_kernel(int32_t* st, int64_t p0, int64_t n, int64_t idx_block, int64_t wcap) { + const int64_t t = (int64_t) blockIdx.x * blockDim.x + threadIdx.x; + if (t >= n) return; + const int64_t pos = p0 + t, n_kv = pos + 1; + int32_t* r = st + t * kStepCount; + r[kStepPos] = (int32_t) pos; + r[kStepNKv] = (int32_t) n_kv; + r[kStepNBid] = (int32_t) (n_kv / idx_block); + r[kStepWidth] = (int32_t) (n_kv < wcap ? n_kv : wcap); // = qsa_selection_width(n_kv, s) +} + +void qsa_steps_fill_dev(int32_t* steps, int64_t p0, int64_t n, const QsaShapes& s, void* stream) { + if (steps == nullptr || n <= 0) return; + if (p0 < 0) fail("qsa_steps_fill_dev: p0 < 0"); + const int64_t wcap = s.idx_top_k + s.idx_block - 1; // qsa_selection_width's bound + steps_fill_kernel<<<(unsigned) ((n + 255) / 256), 256, 0, (cudaStream_t) stream>>>(steps, p0, n, + (int64_t) s.idx_block, wcap); + check_launch("qsa_steps_fill_dev"); +} + void qsa_step_fill(int32_t* host_step, int64_t pos, const QsaShapes& s) { --- a/include/strata/kernels/qsa.hpp +++ b/include/strata/kernels/qsa.hpp @@ -172,6 +172,9 @@ void qsa_step_fill(int32_t* host_step, int64_t pos, const QsaShapes& s); +/// The records qsa_step_fill writes for positions p0 .. p0+n-1, written on the device by one kernel on `stream`. +void qsa_steps_fill_dev(int32_t* steps, int64_t p0, int64_t n, const QsaShapes& s, void* stream); + --- a/src/prefill/prefill.cpp +++ b/src/prefill/prefill.cpp @@ -2157,8 +2157,8 @@ for (int64_t t = 0; t < T; ++t) strata::kernels::qsa_step_fill(m.steps_host.data() + t * strata::kernels::kStepCount, p0 + t, s); - cudaMemcpyAsync(m.steps_dev, m.steps_host.data(), (size_t) T * strata::kernels::kStepCount * 4, - cudaMemcpyHostToDevice, m.cs); + // steps_host stays for `active`; the device records are written on the device + strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs); @@ -2634,6 +2634,7 @@ const strata::kernels::QsaIndexerBuffers ib{st.idx_tail, st.idx_dead, st.idx_pooled, st.idx_block_pos}; + strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs); // again, before the indexer append pt.mark(kPfQsaIdx, cs); @@ -2651,6 +2652,7 @@ } catch (const std::exception& e) { err = std::string("prefill indexer: ") + e.what(); return false; } + strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs); // and before the selection pt.mark(kPfQsaSel, cs); ``` **A** (the diagnostic one, 41 lines): a `PinnedSteps { int32_t* p; size_t n; cudaEvent_t ev; }` member in `Prefill::Impl`, allocated with `cudaHostAlloc` next to `steps_host.resize`. At prefill.cpp:2160: `cudaEventSynchronize(ev)`, `memcpy` steps_host into the pinned buffer, `cudaMemcpyAsync` from 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.
Author
Owner

@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.

  • Patch B with the rocm-debug-agent attached. No Memory access fault at 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.
  • Patch C, without the debug agent. C is B plus one change: every other async copy of the prompt path whose host side is pageable goes through pinned bounce buffers. Those copies are the draft tokens and bounds (prefill.cpp ~1374/1378), the prompt token ids (2090), the image rows (2111) and the PLE rows in the ple_pageable fallback. In the non-mapped branches C also covers the expert routing (ids_host D2H at 2976, slot_host/src_host at 3168/3169, bounds_host at 3252) and the peer P.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 fresh std::async thread per chunk.
  • Result with C: 2 h 06 min, 0 faults, 0 engine restarts. The load was 4 agent sessions on real read-only requests plus the delivery-note loop with images: 104 notes (36 of them arbitrated) and 66 agent requests, with min free RAM 19 GiB. In the default config grp_host is 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).

lines correct mean time per note
C 33/37 22.3 s
the 27B we run today 30/37 34.8 s

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).

  • Switches and checks. STRATA_HIP_WMMA=1 and STRATA_SELECT_WMMA=1, both checked in the engine's environment. The log shows STRATA_HIP_WMMA: the prompt attention on matrix cores on (gfx1100).
  • Prompt read, new prompt with a random prefix, so no cache, median of 2 runs:
    • 4K: 877 t/s off -> 1171 t/s on (+33%; the first run with the switches off was a cold one, so this one is noisy);
    • 16K: 1519 -> 1815 t/s (+19%).
  • The 16K gain is below your numbers. With both switches yours add up to roughly +37%. Our prompt is split in 2048-token chunks (--no-prefill-borrow) and pipelined across two cards, which may explain part of it.
  • Delivery notes with the switches on: 33/37 lines, the same as without. The mean drops to 19.0 s per note (22.3 s without; median 17.3 s), and the note number is now correct on 16/16 notes, against 15/16 without. There were 0 faults, so we are keeping both switches.

4. Four-hour stress on the real engine. Same setup: C with both switches, production config.

  • Load. 6 clients run together on the 4 slots, so conversations keep entering and leaving the slots through the conversation cache:
    • 2 agent sessions on real read-only requests;
    • 2 delivery-note loops, 4 minutes apart;
    • 2 clients that pick at random between a new 32K/64K/128K prompt, a synthetic image followed by a long synthetic text (the #1712 trigger) and a short chat question.
  • Result: 240 min, 0 faults, 0 engine restarts, with min free RAM 23 GiB.
    • 250 delivery notes in 14 complete passes. Every pass scored 32 or 33/37 and had 0 read errors.
    • 49 agent requests, 41 long prompts, 54 chats and 50 image→text pairs.
  • The failures. All of them were client-side limits under that load, and there was nothing in the engine log.
    • 16 agent requests hit our 900 s cap.
    • 32 times the structured-text step after the image hit its 300 s client timeout, or returned 502 after about 250-300 s. We read the 502 as the long synthetic JSON hitting max_tokens under the strict grammar.
  • Speed under this load. The write speed per request drops to about 15-20 t/s, against 55 t/s alone. Prompt reading stays at 1000-1700 t/s on a fixed 6K probe.

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:

  • Does 0.1.42 touch the pageable host-to-device copies in the prompt path?
  • Would you take B or C upstream, or would you rather fix it your way? Patch C against 0.1.41 is below, and we can test any build of yours.
Patch C against 0.1.41 (prefill.cpp, qsa.cu, qsa.hpp)
--- a/src/prefill/prefill.cpp
+++ b/src/prefill/prefill.cpp
@@ -51,6 +51,98 @@
 #include <thread>
 #include <vector>
 
+// floria 10/10/2026 (#1712, patch C). On this box (2x RX 7900 XTX, ROCm 7.2.4) an async copy from PAGEABLE host memory in the
+// prompt path delivered wrong bytes after an image request (the step records: 5 faults in 5 runs; from a pinned source: 0 in 5).
+// Every async copy of the prompt path whose host side is pageable goes through these two instead: the bytes are moved into a
+// PINNED bounce slot first, so the runtime's pageable path is never used. A slot is refilled only after the copy that last
+// read it is done (an event recorded right after that copy), so the caller may overwrite its source right after the call
+// (exactly what a pageable copy allowed).
+// C2 (review): the rings are LEASED, not thread_local-owned. A layer split's later stage runs on a NEW std::async thread
+// for every chunk (run_impl via next_run_): a ring owned by the thread was allocated again (up to 64 cudaHostAlloc) and
+// freed (64 cudaFreeHost from a thread-exit destructor, its copies possibly still in flight) chunk after chunk. A thread
+// takes a free ring on first use and gives it back when it ends; rings are never freed (a few MB for the whole process,
+// and no CUDA call from a thread-exit or process-exit destructor). A ring is used by one thread at a time.
+// Events instead of the stream handle: a slot waits for ITS copy only (not the whole stream's later work), and never
+// holds a stream handle that a destroyed Prefill could have left dangling.
+namespace {
+struct FloriaRing {
+    struct Slot { void* p = nullptr; size_t cap = 0; cudaEvent_t ev = nullptr; int ev_dev = -1; bool pending = false; };
+    std::vector<Slot> ring = std::vector<Slot>(64);
+    size_t next = 0;
+};
+std::mutex& floria_ring_mu() { static auto* mu = new std::mutex(); return *mu; }
+std::vector<FloriaRing*>& floria_free_rings() { static auto* v = new std::vector<FloriaRing*>(); return *v; }
+struct FloriaLease {
+    FloriaRing* r = nullptr;
+    FloriaLease() {
+        std::lock_guard<std::mutex> lk(floria_ring_mu());
+        auto& f = floria_free_rings();
+        if (f.empty()) r = new FloriaRing();
+        else { r = f.back(); f.pop_back(); }
+    }
+    ~FloriaLease() { std::lock_guard<std::mutex> lk(floria_ring_mu()); floria_free_rings().push_back(r); }
+};
+FloriaRing& floria_ring() { thread_local FloriaLease lease; return *lease.r; }
+
+cudaError_t floria_slot(size_t bytes, FloriaRing::Slot*& out) {
+    FloriaRing& b = floria_ring();
+    FloriaRing::Slot& sl = b.ring[b.next];
+    b.next = (b.next + 1) % b.ring.size();
+    if (sl.pending) {                                 // the copy that last read this slot is done before it is refilled
+        const cudaError_t e = cudaEventSynchronize(sl.ev);
+        sl.pending = false;
+        if (e != cudaSuccess) return e;
+    }
+    if (sl.cap < bytes) {
+        if (sl.p) { cudaFreeHost(sl.p); sl.p = nullptr; sl.cap = 0; }   // idle: its last copy was waited for above
+        const size_t cap = std::max(bytes, (size_t) 65536);
+        const cudaError_t e = cudaHostAlloc(&sl.p, cap, cudaHostAllocPortable);
+        if (e != cudaSuccess) { sl.p = nullptr; return e; }
+        sl.cap = cap;
+    }
+    out = &sl;
+    return cudaSuccess;
+}
+
+// after the async copy out of `sl` was queued on `s` (whose device is the current one, as for every call site)
+void floria_busy(FloriaRing::Slot& sl, cudaStream_t s) {
+    int dev = -1;
+    cudaGetDevice(&dev);
+    if (sl.ev != nullptr && sl.ev_dev != dev) { cudaEventDestroy(sl.ev); sl.ev = nullptr; sl.ev_dev = -1; }   // idle
+    if (sl.ev == nullptr) {
+        if (cudaEventCreateWithFlags(&sl.ev, cudaEventDisableTiming) == cudaSuccess) sl.ev_dev = dev;
+        else sl.ev = nullptr;
+    }
+    if (sl.ev != nullptr && cudaEventRecord(sl.ev, s) == cudaSuccess) { sl.pending = true; return; }
+    cudaGetLastError();                               // no event: the copy is waited for here instead
+    cudaStreamSynchronize(s);
+}
+
+cudaError_t floria_h2d(void* dst, const void* src, size_t bytes, cudaStream_t s) {
+    if (bytes == 0) return cudaSuccess;
+    FloriaRing::Slot* sl = nullptr;
+    cudaError_t e = floria_slot(bytes, sl);
+    if (e != cudaSuccess) { std::fprintf(stderr, "strata prefill: [floria patch C] h2d bounce: %s\n", cudaGetErrorString(e)); return e; }
+    std::memcpy(sl->p, src, bytes);
+    e = cudaMemcpyAsync(dst, sl->p, bytes, cudaMemcpyHostToDevice, s);
+    if (e == cudaSuccess) floria_busy(*sl, s);
+    else std::fprintf(stderr, "strata prefill: [floria patch C] h2d: %s\n", cudaGetErrorString(e));
+    return e;
+}
+
+// D2H into pageable memory: into the bounce slot, the stream drained, then copied out (synchronous: the bytes are there on return)
+cudaError_t floria_d2h_sync(void* dst, const void* src, size_t bytes, cudaStream_t s) {
+    if (bytes == 0) return cudaSuccess;
+    FloriaRing::Slot* sl = nullptr;
+    cudaError_t e = floria_slot(bytes, sl);
+    if (e == cudaSuccess) e = cudaMemcpyAsync(sl->p, src, bytes, cudaMemcpyDeviceToHost, s);
+    if (e == cudaSuccess) e = cudaStreamSynchronize(s);
+    if (e == cudaSuccess) std::memcpy(dst, sl->p, bytes);
+    else std::fprintf(stderr, "strata prefill: [floria patch C] d2h: %s\n", cudaGetErrorString(e));
+    return e;
+}
+}  // namespace
+
 #ifndef STRATA_PREFILL_MMQ
 // A build without the llama.cpp sources (no STRATA_NATIVE_EXPERTS): no MMQ, the FP16 expert path everywhere.
 namespace strata::prefill::mmq {
@@ -1371,11 +1463,11 @@
         const int64_t nb = std::min(B, n - b0), c0 = cell0 + b0;
         for (int64_t i = 0; i < nb; ++i) tk[(size_t) i] = next_tokens[b0 + i];
         const int32_t bh[4] = {0, (int32_t) nb, 0, (int32_t) (nb * g.hc)};
-        if (q8 && cudaMemcpyAsync(bnd, bh, sizeof bh, cudaMemcpyHostToDevice, m.cs) != cudaSuccess) {
+        if (q8 && floria_h2d(bnd, bh, sizeof bh, m.cs) != cudaSuccess) {   // floria patch C
             err = "prefill: the draft bounds' upload failed";
             return false;
         }
-        if (cudaMemcpyAsync(tok, tk.data(), (size_t) nb * 4, cudaMemcpyHostToDevice, m.cs) != cudaSuccess) {
+        if (floria_h2d(tok, tk.data(), (size_t) nb * 4, m.cs) != cudaSuccess) {   // floria patch C
             err = "prefill: the draft tokens' upload failed";
             return false;
         }
@@ -2087,8 +2179,7 @@
             else m.tok_host[(size_t) t] = (int32_t) tok;
         }
         if (batched) {
-            if (cudaMemcpyAsync(m.tok_dev, m.tok_host.data(), (size_t) T * sizeof(int32_t), cudaMemcpyHostToDevice,
-                                m.cs) != cudaSuccess) {
+            if (floria_h2d(m.tok_dev, m.tok_host.data(), (size_t) T * sizeof(int32_t), m.cs) != cudaSuccess) {   // floria patch C
                 err = "prefill: the token id upload failed";
                 return false;
             }
@@ -2108,7 +2199,7 @@
         for (int64_t t = 0; hand_in_ == nullptr && !batched && t < T; ++t) {
             const float* row = embd_rows ? embd_rows[p0 + t] : nullptr;
             if (row) {
-                if (cudaMemcpyAsync(m.emb + t * N, row, (size_t) N * 4, cudaMemcpyHostToDevice, m.cs) != cudaSuccess) {
+                if (floria_h2d(m.emb + t * N, row, (size_t) N * 4, m.cs) != cudaSuccess) {   // floria patch C
                     err = "prefill: the image embedding upload failed";
                     return false;
                 }
@@ -2134,7 +2225,10 @@
                 err = ple_next_err;
                 return false;
             }
-            if (cudaMemcpyAsync(m.ple_emb, m.ple_emb_host[ple_buf], (size_t) T * N * 4, cudaMemcpyHostToDevice, m.cs) !=
+            // floria patch C2: the pageable fallback (no RAM left to pin, or STRATA_TEST_PAGEABLE=1) through a pinned slot
+            if ((m.ple_pageable[ple_buf].empty()
+                     ? cudaMemcpyAsync(m.ple_emb, m.ple_emb_host[ple_buf], (size_t) T * N * 4, cudaMemcpyHostToDevice, m.cs)
+                     : floria_h2d(m.ple_emb, m.ple_emb_host[ple_buf], (size_t) T * N * 4, m.cs)) !=
                     cudaSuccess ||
                 cudaEventRecord(m.ple_copied[ple_buf], m.cs) != cudaSuccess) {
                 err = std::string("prefill: the PLE rows' upload failed: ") + cudaGetErrorString(cudaGetLastError());
@@ -2157,8 +2251,13 @@
         for (int64_t t = 0; t < T; ++t) { prev[0] = prev[1]; prev[1] = (int32_t) tokens[c0 + t]; }
         // ---- the QSA step records of every position in the chunk
         for (int64_t t = 0; t < T; ++t) strata::kernels::qsa_step_fill(m.steps_host.data() + t * strata::kernels::kStepCount, p0 + t, s);
-        cudaMemcpyAsync(m.steps_dev, m.steps_host.data(), (size_t) T * strata::kernels::kStepCount * 4,
-                        cudaMemcpyHostToDevice, m.cs);
+        // floria 10/10/2026 (#1712, patch B): i passi li scrive un kernel sul dispositivo, non una copia dall'host
+        strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs);
+        {
+            static bool detto = false;
+            if (!detto) { detto = true; std::fprintf(stderr, "strata prefill: [floria patch C] step records written on the device, "
+                                                 "pageable prompt-path copies through pinned bounce slots\n"); }
+        }
 
         int64_t qsa_index = 0, gdn_index = 0;
         for (int64_t l = 0; l < LB; ++l) (core::is_qsa_layer(g, l) ? qsa_index : gdn_index) += 1;
@@ -2634,6 +2733,7 @@
                     // the indexer appends, token by token; then scores + selection for many queries at once:
                     // a query reads completed blocks (final once completed) and `dead` for its own tail block
                     const strata::kernels::QsaIndexerBuffers ib{st.idx_tail, st.idx_dead, st.idx_pooled, st.idx_block_pos};
+                    strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs);   // floria patch B: di nuovo, prima dell'indicizzatore
                     pt.mark(kPfQsaIdx, cs);
                     // C-2: the chunk's appends in three launches instead of one per token (the same end state:
                     // the queries below read it only after the whole chunk is appended). STRATA_INDEXER_PER_TOKEN=1: the old
@@ -2651,6 +2751,7 @@
                                                                        strata::kernels::rope_scaling(), m.cs);
                         }
                     } catch (const std::exception& e) { err = std::string("prefill indexer: ") + e.what(); return false; }
+                    strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs);   // floria patch B: e prima della selezione
                     pt.mark(kPfQsaSel, cs);
                     for (int64_t t0 = 0; t0 < T; t0 += m.sel_batch) {
                         const int64_t nb = std::min(m.sel_batch, T - t0);
@@ -2973,7 +3074,7 @@
                         int32_t* slot_h = grp_mapped ? m.grp_host + m.grp_tk : m.slot_host.data();
                         int32_t* src_h = grp_mapped ? m.grp_host + 2 * m.grp_tk : m.src_host.data();
                         if (grp_mapped) copy_i32(m.grp_dev, m.ids, T * K, m.cs);
-                        else cudaMemcpyAsync(m.ids_host.data(), m.ids, (size_t) T * K * 4, cudaMemcpyDeviceToHost, m.cs);
+                        else floria_d2h_sync(m.ids_host.data(), m.ids, (size_t) T * K * 4, m.cs);   // floria patch C
                         const bool cpu_maybe = pool_hold.held && !stream_all && m.src != nullptr &&
                                                lay.native && !m.pp && !lay.fmt.empty();
                         // auto shares only while the layers that share cost less per non-resident expert than their
@@ -3165,8 +3266,8 @@
                             copy_i32(m.slot_dev, m.grp_dev + m.grp_tk, T * K, m.cs);
                             copy_i32(m.src_dev, m.grp_dev + 2 * m.grp_tk, T * K, m.cs);
                         } else {
-                            cudaMemcpyAsync(m.slot_dev, m.slot_host.data(), (size_t) T * K * 4, cudaMemcpyHostToDevice, m.cs);
-                            cudaMemcpyAsync(m.src_dev, m.src_host.data(), (size_t) T * K * 4, cudaMemcpyHostToDevice, m.cs);
+                            floria_h2d(m.slot_dev, m.slot_host.data(), (size_t) T * K * 4, m.cs);   // floria patch C
+                            floria_h2d(m.src_dev, m.src_host.data(), (size_t) T * K * 4, m.cs);
                         }
                         n_order = order.size();
                         // set_cpu_pool: the CPU's experts on a thread while this one streams and runs the GPU's; their
@@ -3249,8 +3350,7 @@
                                 std::memcpy(bh, m.bounds_host.data(), m.bounds_host.size() * 4);
                                 copy_i32(m.bounds_dev, m.grp_dev + 3 * m.grp_tk, (int64_t) m.bounds_host.size(), m.cs);
                             } else {
-                                cudaMemcpyAsync(m.bounds_dev, m.bounds_host.data(), m.bounds_host.size() * 4,
-                                                cudaMemcpyHostToDevice, m.cs);
+                                floria_h2d(m.bounds_dev, m.bounds_host.data(), m.bounds_host.size() * 4, m.cs);   // floria patch C
                             }
                         } else {
                             gather_rows16(m.mixed_h, m.src_dev, m.Xs, T * K, N, m.cs);
@@ -3288,8 +3388,11 @@
                             P.back_at = rows_local;
                             P.back_rows = rows_peer;
                             if (P.p2p) {
-                                cudaMemcpyAsync(P.src, src_h + rows_local,   // multi-GPU: the mapped table when on
-                                                (size_t) rows_peer * 4, cudaMemcpyHostToDevice, ps);
+                                if (grp_mapped)
+                                    cudaMemcpyAsync(P.src, src_h + rows_local,   // multi-GPU: the mapped table when on
+                                                    (size_t) rows_peer * 4, cudaMemcpyHostToDevice, ps);
+                                else   // floria patch C2: src_host is a pageable vector
+                                    floria_h2d(P.src, src_h + rows_local, (size_t) rows_peer * 4, ps);
                             } else {
                                 std::memcpy(P.host_src, src_h + rows_local, (size_t) rows_peer * 4);
                                 copy_i32(P.src, P.host_src, rows_peer, ps);
@@ -3323,7 +3426,7 @@
                                             P.bounds_host[std::min(P.groups[g2].second, P.groups[g2].first + i)] -
                                             P.bounds_host[P.groups[g2].first];
                                 if (P.p2p || P.bounds_host.size() > PeerPrefill::kHostBounds) {
-                                    cudaMemcpyAsync(P.bounds, P.bounds_host.data(), P.bounds_host.size() * 4, cudaMemcpyHostToDevice, ps);
+                                    floria_h2d(P.bounds, P.bounds_host.data(), P.bounds_host.size() * 4, ps);   // floria patch C
                                 } else {
                                     std::memcpy(P.host_bounds, P.bounds_host.data(), P.bounds_host.size() * 4);
                                     copy_i32(P.bounds, P.host_bounds, (int64_t) P.bounds_host.size(), ps);
@@ -3454,7 +3557,7 @@
                                         P.bounds_host[n + 1 + g2 * (MMQ_GROUP + 1) + i] =
                                             P.bounds_host[std::min(n, g2 * MMQ_GROUP + i)] - P.bounds_host[g2 * MMQ_GROUP];
                                 if (P.p2p || P.bounds_host.size() > PeerPrefill::kHostBounds) {
-                                    cudaMemcpyAsync(P.bounds, P.bounds_host.data(), P.bounds_host.size() * 4, cudaMemcpyHostToDevice, ps);
+                                    floria_h2d(P.bounds, P.bounds_host.data(), P.bounds_host.size() * 4, ps);   // floria patch C
                                 } else {
                                     std::memcpy(P.host_bounds, P.bounds_host.data(), P.bounds_host.size() * 4);
                                     copy_i32(P.bounds, P.host_bounds, (int64_t) P.bounds_host.size(), ps);
--- a/include/strata/kernels/qsa.hpp
+++ b/include/strata/kernels/qsa.hpp
@@ -172,6 +172,11 @@
 /// and a caller computing them by hand is a caller who can compute them differently.
 void qsa_step_fill(int32_t* host_step, int64_t pos, const QsaShapes& s);
 
+/// floria 10/10/2026 (#1712, patch B): the records qsa_step_fill writes for positions p0 .. p0+n-1, written ON THE
+/// DEVICE by one kernel on `stream` into `steps` (n * kStepCount int32): no host copy can deliver stale bytes, and
+/// the prompt path rewrites them right before every reader.
+void qsa_steps_fill_dev(int32_t* steps, int64_t p0, int64_t n, const QsaShapes& s, void* stream);
+
 
 /// One token's K and V into the paged FP16 cache, at logical cell `pos`.
 ///
--- a/src/kernels/cuda/qsa.cu
+++ b/src/kernels/cuda/qsa.cu
@@ -696,6 +696,26 @@
 
 // ================= host entry points =================
 
+static __global__ void floria_steps_fill_kernel(int32_t* st, int64_t p0, int64_t n, int64_t idx_block, int64_t wcap) {
+    const int64_t t = (int64_t) blockIdx.x * blockDim.x + threadIdx.x;
+    if (t >= n) return;
+    const int64_t pos = p0 + t, n_kv = pos + 1;
+    int32_t* r = st + t * kStepCount;
+    r[kStepPos] = (int32_t) pos;
+    r[kStepNKv] = (int32_t) n_kv;
+    r[kStepNBid] = (int32_t) (n_kv / idx_block);
+    r[kStepWidth] = (int32_t) (n_kv < wcap ? n_kv : wcap);   // = qsa_selection_width(n_kv, s)
+}
+
+void qsa_steps_fill_dev(int32_t* steps, int64_t p0, int64_t n, const QsaShapes& s, void* stream) {
+    if (steps == nullptr || n <= 0) return;
+    if (p0 < 0) fail("qsa_steps_fill_dev: p0 < 0");
+    const int64_t wcap = s.idx_top_k + s.idx_block - 1;   // qsa_selection_width's bound
+    floria_steps_fill_kernel<<<(unsigned) ((n + 255) / 256), 256, 0, (cudaStream_t) stream>>>(steps, p0, n,
+                                                                                         (int64_t) s.idx_block, wcap);
+    check_launch("qsa_steps_fill_dev");
+}
+
 void qsa_step_fill(int32_t* host_step, int64_t pos, const QsaShapes& s) {
     if (host_step == nullptr) return;
     if (pos < 0) fail("qsa_step_fill: pos < 0");
<!-- gh-comment-id:6108266817 --> @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.** - **Patch B with the rocm-debug-agent attached.** No `Memory access fault` at 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. - **Patch C, without the debug agent.** C is B plus one change: every other async copy of the prompt path whose host side is pageable goes through pinned bounce buffers. Those copies are the draft tokens and bounds (prefill.cpp ~1374/1378), the prompt token ids (2090), the image rows (2111) and the PLE rows in the `ple_pageable` fallback. In the non-mapped branches C also covers the expert routing (`ids_host` D2H at 2976, `slot_host`/`src_host` at 3168/3169, `bounds_host` at 3252) and the peer `P.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 fresh `std::async` thread per chunk. - **Result with C: 2 h 06 min, 0 faults, 0 engine restarts.** The load was 4 agent sessions on real read-only requests plus the delivery-note loop with images: 104 notes (36 of them arbitrated) and 66 agent requests, with min free RAM 19 GiB. In the default config `grp_host` is 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`). | | lines correct | mean time per note | |---|---|---| | **C** | **33/37** | **22.3 s** | | the 27B we run today | 30/37 | 34.8 s | 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).** - **Switches and checks.** `STRATA_HIP_WMMA=1` and `STRATA_SELECT_WMMA=1`, both checked in the engine's environment. The log shows `STRATA_HIP_WMMA: the prompt attention on matrix cores on (gfx1100)`. - **Prompt read**, new prompt with a random prefix, so no cache, median of 2 runs: - 4K: 877 t/s off -> 1171 t/s on (+33%; the first run with the switches off was a cold one, so this one is noisy); - 16K: 1519 -> 1815 t/s (+19%). - **The 16K gain is below your numbers.** With both switches yours add up to roughly +37%. Our prompt is split in 2048-token chunks (`--no-prefill-borrow`) and pipelined across two cards, which may explain part of it. - **Delivery notes with the switches on:** 33/37 lines, the same as without. The mean drops to **19.0 s** per note (22.3 s without; median 17.3 s), and the note number is now correct on 16/16 notes, against 15/16 without. There were 0 faults, so we are keeping both switches. **4. Four-hour stress on the real engine.** Same setup: C with both switches, production config. - **Load.** 6 clients run together on the 4 slots, so conversations keep entering and leaving the slots through the conversation cache: - 2 agent sessions on real read-only requests; - 2 delivery-note loops, 4 minutes apart; - 2 clients that pick at random between a new 32K/64K/128K prompt, a synthetic image followed by a long synthetic text (the #1712 trigger) and a short chat question. - **Result: 240 min, 0 faults, 0 engine restarts**, with min free RAM 23 GiB. - 250 delivery notes in 14 complete passes. Every pass scored 32 or 33/37 and had 0 read errors. - 49 agent requests, 41 long prompts, 54 chats and 50 image→text pairs. - **The failures.** All of them were client-side limits under that load, and there was nothing in the engine log. - 16 agent requests hit our 900 s cap. - 32 times the structured-text step after the image hit its 300 s client timeout, or returned 502 after about 250-300 s. We read the 502 as the long synthetic JSON hitting `max_tokens` under the strict grammar. - **Speed under this load.** The write speed per request drops to about 15-20 t/s, against 55 t/s alone. Prompt reading stays at 1000-1700 t/s on a fixed 6K probe. **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: - Does 0.1.42 touch the pageable host-to-device copies in the prompt path? - Would you take B or C upstream, or would you rather fix it your way? Patch C against 0.1.41 is below, and we can test any build of yours. <details><summary>Patch C against 0.1.41 (prefill.cpp, qsa.cu, qsa.hpp)</summary> ```diff --- a/src/prefill/prefill.cpp +++ b/src/prefill/prefill.cpp @@ -51,6 +51,98 @@ #include <thread> #include <vector> +// floria 10/10/2026 (#1712, patch C). On this box (2x RX 7900 XTX, ROCm 7.2.4) an async copy from PAGEABLE host memory in the +// prompt path delivered wrong bytes after an image request (the step records: 5 faults in 5 runs; from a pinned source: 0 in 5). +// Every async copy of the prompt path whose host side is pageable goes through these two instead: the bytes are moved into a +// PINNED bounce slot first, so the runtime's pageable path is never used. A slot is refilled only after the copy that last +// read it is done (an event recorded right after that copy), so the caller may overwrite its source right after the call +// (exactly what a pageable copy allowed). +// C2 (review): the rings are LEASED, not thread_local-owned. A layer split's later stage runs on a NEW std::async thread +// for every chunk (run_impl via next_run_): a ring owned by the thread was allocated again (up to 64 cudaHostAlloc) and +// freed (64 cudaFreeHost from a thread-exit destructor, its copies possibly still in flight) chunk after chunk. A thread +// takes a free ring on first use and gives it back when it ends; rings are never freed (a few MB for the whole process, +// and no CUDA call from a thread-exit or process-exit destructor). A ring is used by one thread at a time. +// Events instead of the stream handle: a slot waits for ITS copy only (not the whole stream's later work), and never +// holds a stream handle that a destroyed Prefill could have left dangling. +namespace { +struct FloriaRing { + struct Slot { void* p = nullptr; size_t cap = 0; cudaEvent_t ev = nullptr; int ev_dev = -1; bool pending = false; }; + std::vector<Slot> ring = std::vector<Slot>(64); + size_t next = 0; +}; +std::mutex& floria_ring_mu() { static auto* mu = new std::mutex(); return *mu; } +std::vector<FloriaRing*>& floria_free_rings() { static auto* v = new std::vector<FloriaRing*>(); return *v; } +struct FloriaLease { + FloriaRing* r = nullptr; + FloriaLease() { + std::lock_guard<std::mutex> lk(floria_ring_mu()); + auto& f = floria_free_rings(); + if (f.empty()) r = new FloriaRing(); + else { r = f.back(); f.pop_back(); } + } + ~FloriaLease() { std::lock_guard<std::mutex> lk(floria_ring_mu()); floria_free_rings().push_back(r); } +}; +FloriaRing& floria_ring() { thread_local FloriaLease lease; return *lease.r; } + +cudaError_t floria_slot(size_t bytes, FloriaRing::Slot*& out) { + FloriaRing& b = floria_ring(); + FloriaRing::Slot& sl = b.ring[b.next]; + b.next = (b.next + 1) % b.ring.size(); + if (sl.pending) { // the copy that last read this slot is done before it is refilled + const cudaError_t e = cudaEventSynchronize(sl.ev); + sl.pending = false; + if (e != cudaSuccess) return e; + } + if (sl.cap < bytes) { + if (sl.p) { cudaFreeHost(sl.p); sl.p = nullptr; sl.cap = 0; } // idle: its last copy was waited for above + const size_t cap = std::max(bytes, (size_t) 65536); + const cudaError_t e = cudaHostAlloc(&sl.p, cap, cudaHostAllocPortable); + if (e != cudaSuccess) { sl.p = nullptr; return e; } + sl.cap = cap; + } + out = &sl; + return cudaSuccess; +} + +// after the async copy out of `sl` was queued on `s` (whose device is the current one, as for every call site) +void floria_busy(FloriaRing::Slot& sl, cudaStream_t s) { + int dev = -1; + cudaGetDevice(&dev); + if (sl.ev != nullptr && sl.ev_dev != dev) { cudaEventDestroy(sl.ev); sl.ev = nullptr; sl.ev_dev = -1; } // idle + if (sl.ev == nullptr) { + if (cudaEventCreateWithFlags(&sl.ev, cudaEventDisableTiming) == cudaSuccess) sl.ev_dev = dev; + else sl.ev = nullptr; + } + if (sl.ev != nullptr && cudaEventRecord(sl.ev, s) == cudaSuccess) { sl.pending = true; return; } + cudaGetLastError(); // no event: the copy is waited for here instead + cudaStreamSynchronize(s); +} + +cudaError_t floria_h2d(void* dst, const void* src, size_t bytes, cudaStream_t s) { + if (bytes == 0) return cudaSuccess; + FloriaRing::Slot* sl = nullptr; + cudaError_t e = floria_slot(bytes, sl); + if (e != cudaSuccess) { std::fprintf(stderr, "strata prefill: [floria patch C] h2d bounce: %s\n", cudaGetErrorString(e)); return e; } + std::memcpy(sl->p, src, bytes); + e = cudaMemcpyAsync(dst, sl->p, bytes, cudaMemcpyHostToDevice, s); + if (e == cudaSuccess) floria_busy(*sl, s); + else std::fprintf(stderr, "strata prefill: [floria patch C] h2d: %s\n", cudaGetErrorString(e)); + return e; +} + +// D2H into pageable memory: into the bounce slot, the stream drained, then copied out (synchronous: the bytes are there on return) +cudaError_t floria_d2h_sync(void* dst, const void* src, size_t bytes, cudaStream_t s) { + if (bytes == 0) return cudaSuccess; + FloriaRing::Slot* sl = nullptr; + cudaError_t e = floria_slot(bytes, sl); + if (e == cudaSuccess) e = cudaMemcpyAsync(sl->p, src, bytes, cudaMemcpyDeviceToHost, s); + if (e == cudaSuccess) e = cudaStreamSynchronize(s); + if (e == cudaSuccess) std::memcpy(dst, sl->p, bytes); + else std::fprintf(stderr, "strata prefill: [floria patch C] d2h: %s\n", cudaGetErrorString(e)); + return e; +} +} // namespace + #ifndef STRATA_PREFILL_MMQ // A build without the llama.cpp sources (no STRATA_NATIVE_EXPERTS): no MMQ, the FP16 expert path everywhere. namespace strata::prefill::mmq { @@ -1371,11 +1463,11 @@ const int64_t nb = std::min(B, n - b0), c0 = cell0 + b0; for (int64_t i = 0; i < nb; ++i) tk[(size_t) i] = next_tokens[b0 + i]; const int32_t bh[4] = {0, (int32_t) nb, 0, (int32_t) (nb * g.hc)}; - if (q8 && cudaMemcpyAsync(bnd, bh, sizeof bh, cudaMemcpyHostToDevice, m.cs) != cudaSuccess) { + if (q8 && floria_h2d(bnd, bh, sizeof bh, m.cs) != cudaSuccess) { // floria patch C err = "prefill: the draft bounds' upload failed"; return false; } - if (cudaMemcpyAsync(tok, tk.data(), (size_t) nb * 4, cudaMemcpyHostToDevice, m.cs) != cudaSuccess) { + if (floria_h2d(tok, tk.data(), (size_t) nb * 4, m.cs) != cudaSuccess) { // floria patch C err = "prefill: the draft tokens' upload failed"; return false; } @@ -2087,8 +2179,7 @@ else m.tok_host[(size_t) t] = (int32_t) tok; } if (batched) { - if (cudaMemcpyAsync(m.tok_dev, m.tok_host.data(), (size_t) T * sizeof(int32_t), cudaMemcpyHostToDevice, - m.cs) != cudaSuccess) { + if (floria_h2d(m.tok_dev, m.tok_host.data(), (size_t) T * sizeof(int32_t), m.cs) != cudaSuccess) { // floria patch C err = "prefill: the token id upload failed"; return false; } @@ -2108,7 +2199,7 @@ for (int64_t t = 0; hand_in_ == nullptr && !batched && t < T; ++t) { const float* row = embd_rows ? embd_rows[p0 + t] : nullptr; if (row) { - if (cudaMemcpyAsync(m.emb + t * N, row, (size_t) N * 4, cudaMemcpyHostToDevice, m.cs) != cudaSuccess) { + if (floria_h2d(m.emb + t * N, row, (size_t) N * 4, m.cs) != cudaSuccess) { // floria patch C err = "prefill: the image embedding upload failed"; return false; } @@ -2134,7 +2225,10 @@ err = ple_next_err; return false; } - if (cudaMemcpyAsync(m.ple_emb, m.ple_emb_host[ple_buf], (size_t) T * N * 4, cudaMemcpyHostToDevice, m.cs) != + // floria patch C2: the pageable fallback (no RAM left to pin, or STRATA_TEST_PAGEABLE=1) through a pinned slot + if ((m.ple_pageable[ple_buf].empty() + ? cudaMemcpyAsync(m.ple_emb, m.ple_emb_host[ple_buf], (size_t) T * N * 4, cudaMemcpyHostToDevice, m.cs) + : floria_h2d(m.ple_emb, m.ple_emb_host[ple_buf], (size_t) T * N * 4, m.cs)) != cudaSuccess || cudaEventRecord(m.ple_copied[ple_buf], m.cs) != cudaSuccess) { err = std::string("prefill: the PLE rows' upload failed: ") + cudaGetErrorString(cudaGetLastError()); @@ -2157,8 +2251,13 @@ for (int64_t t = 0; t < T; ++t) { prev[0] = prev[1]; prev[1] = (int32_t) tokens[c0 + t]; } // ---- the QSA step records of every position in the chunk for (int64_t t = 0; t < T; ++t) strata::kernels::qsa_step_fill(m.steps_host.data() + t * strata::kernels::kStepCount, p0 + t, s); - cudaMemcpyAsync(m.steps_dev, m.steps_host.data(), (size_t) T * strata::kernels::kStepCount * 4, - cudaMemcpyHostToDevice, m.cs); + // floria 10/10/2026 (#1712, patch B): i passi li scrive un kernel sul dispositivo, non una copia dall'host + strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs); + { + static bool detto = false; + if (!detto) { detto = true; std::fprintf(stderr, "strata prefill: [floria patch C] step records written on the device, " + "pageable prompt-path copies through pinned bounce slots\n"); } + } int64_t qsa_index = 0, gdn_index = 0; for (int64_t l = 0; l < LB; ++l) (core::is_qsa_layer(g, l) ? qsa_index : gdn_index) += 1; @@ -2634,6 +2733,7 @@ // the indexer appends, token by token; then scores + selection for many queries at once: // a query reads completed blocks (final once completed) and `dead` for its own tail block const strata::kernels::QsaIndexerBuffers ib{st.idx_tail, st.idx_dead, st.idx_pooled, st.idx_block_pos}; + strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs); // floria patch B: di nuovo, prima dell'indicizzatore pt.mark(kPfQsaIdx, cs); // C-2: the chunk's appends in three launches instead of one per token (the same end state: // the queries below read it only after the whole chunk is appended). STRATA_INDEXER_PER_TOKEN=1: the old @@ -2651,6 +2751,7 @@ strata::kernels::rope_scaling(), m.cs); } } catch (const std::exception& e) { err = std::string("prefill indexer: ") + e.what(); return false; } + strata::kernels::qsa_steps_fill_dev(m.steps_dev, p0, T, s, m.cs); // floria patch B: e prima della selezione pt.mark(kPfQsaSel, cs); for (int64_t t0 = 0; t0 < T; t0 += m.sel_batch) { const int64_t nb = std::min(m.sel_batch, T - t0); @@ -2973,7 +3074,7 @@ int32_t* slot_h = grp_mapped ? m.grp_host + m.grp_tk : m.slot_host.data(); int32_t* src_h = grp_mapped ? m.grp_host + 2 * m.grp_tk : m.src_host.data(); if (grp_mapped) copy_i32(m.grp_dev, m.ids, T * K, m.cs); - else cudaMemcpyAsync(m.ids_host.data(), m.ids, (size_t) T * K * 4, cudaMemcpyDeviceToHost, m.cs); + else floria_d2h_sync(m.ids_host.data(), m.ids, (size_t) T * K * 4, m.cs); // floria patch C const bool cpu_maybe = pool_hold.held && !stream_all && m.src != nullptr && lay.native && !m.pp && !lay.fmt.empty(); // auto shares only while the layers that share cost less per non-resident expert than their @@ -3165,8 +3266,8 @@ copy_i32(m.slot_dev, m.grp_dev + m.grp_tk, T * K, m.cs); copy_i32(m.src_dev, m.grp_dev + 2 * m.grp_tk, T * K, m.cs); } else { - cudaMemcpyAsync(m.slot_dev, m.slot_host.data(), (size_t) T * K * 4, cudaMemcpyHostToDevice, m.cs); - cudaMemcpyAsync(m.src_dev, m.src_host.data(), (size_t) T * K * 4, cudaMemcpyHostToDevice, m.cs); + floria_h2d(m.slot_dev, m.slot_host.data(), (size_t) T * K * 4, m.cs); // floria patch C + floria_h2d(m.src_dev, m.src_host.data(), (size_t) T * K * 4, m.cs); } n_order = order.size(); // set_cpu_pool: the CPU's experts on a thread while this one streams and runs the GPU's; their @@ -3249,8 +3350,7 @@ std::memcpy(bh, m.bounds_host.data(), m.bounds_host.size() * 4); copy_i32(m.bounds_dev, m.grp_dev + 3 * m.grp_tk, (int64_t) m.bounds_host.size(), m.cs); } else { - cudaMemcpyAsync(m.bounds_dev, m.bounds_host.data(), m.bounds_host.size() * 4, - cudaMemcpyHostToDevice, m.cs); + floria_h2d(m.bounds_dev, m.bounds_host.data(), m.bounds_host.size() * 4, m.cs); // floria patch C } } else { gather_rows16(m.mixed_h, m.src_dev, m.Xs, T * K, N, m.cs); @@ -3288,8 +3388,11 @@ P.back_at = rows_local; P.back_rows = rows_peer; if (P.p2p) { - cudaMemcpyAsync(P.src, src_h + rows_local, // multi-GPU: the mapped table when on - (size_t) rows_peer * 4, cudaMemcpyHostToDevice, ps); + if (grp_mapped) + cudaMemcpyAsync(P.src, src_h + rows_local, // multi-GPU: the mapped table when on + (size_t) rows_peer * 4, cudaMemcpyHostToDevice, ps); + else // floria patch C2: src_host is a pageable vector + floria_h2d(P.src, src_h + rows_local, (size_t) rows_peer * 4, ps); } else { std::memcpy(P.host_src, src_h + rows_local, (size_t) rows_peer * 4); copy_i32(P.src, P.host_src, rows_peer, ps); @@ -3323,7 +3426,7 @@ P.bounds_host[std::min(P.groups[g2].second, P.groups[g2].first + i)] - P.bounds_host[P.groups[g2].first]; if (P.p2p || P.bounds_host.size() > PeerPrefill::kHostBounds) { - cudaMemcpyAsync(P.bounds, P.bounds_host.data(), P.bounds_host.size() * 4, cudaMemcpyHostToDevice, ps); + floria_h2d(P.bounds, P.bounds_host.data(), P.bounds_host.size() * 4, ps); // floria patch C } else { std::memcpy(P.host_bounds, P.bounds_host.data(), P.bounds_host.size() * 4); copy_i32(P.bounds, P.host_bounds, (int64_t) P.bounds_host.size(), ps); @@ -3454,7 +3557,7 @@ P.bounds_host[n + 1 + g2 * (MMQ_GROUP + 1) + i] = P.bounds_host[std::min(n, g2 * MMQ_GROUP + i)] - P.bounds_host[g2 * MMQ_GROUP]; if (P.p2p || P.bounds_host.size() > PeerPrefill::kHostBounds) { - cudaMemcpyAsync(P.bounds, P.bounds_host.data(), P.bounds_host.size() * 4, cudaMemcpyHostToDevice, ps); + floria_h2d(P.bounds, P.bounds_host.data(), P.bounds_host.size() * 4, ps); // floria patch C } else { std::memcpy(P.host_bounds, P.bounds_host.data(), P.bounds_host.size() * 4); copy_i32(P.bounds, P.host_bounds, (int64_t) P.bounds_host.size(), ps); --- a/include/strata/kernels/qsa.hpp +++ b/include/strata/kernels/qsa.hpp @@ -172,6 +172,11 @@ /// and a caller computing them by hand is a caller who can compute them differently. void qsa_step_fill(int32_t* host_step, int64_t pos, const QsaShapes& s); +/// floria 10/10/2026 (#1712, patch B): the records qsa_step_fill writes for positions p0 .. p0+n-1, written ON THE +/// DEVICE by one kernel on `stream` into `steps` (n * kStepCount int32): no host copy can deliver stale bytes, and +/// the prompt path rewrites them right before every reader. +void qsa_steps_fill_dev(int32_t* steps, int64_t p0, int64_t n, const QsaShapes& s, void* stream); + /// One token's K and V into the paged FP16 cache, at logical cell `pos`. /// --- a/src/kernels/cuda/qsa.cu +++ b/src/kernels/cuda/qsa.cu @@ -696,6 +696,26 @@ // ================= host entry points ================= +static __global__ void floria_steps_fill_kernel(int32_t* st, int64_t p0, int64_t n, int64_t idx_block, int64_t wcap) { + const int64_t t = (int64_t) blockIdx.x * blockDim.x + threadIdx.x; + if (t >= n) return; + const int64_t pos = p0 + t, n_kv = pos + 1; + int32_t* r = st + t * kStepCount; + r[kStepPos] = (int32_t) pos; + r[kStepNKv] = (int32_t) n_kv; + r[kStepNBid] = (int32_t) (n_kv / idx_block); + r[kStepWidth] = (int32_t) (n_kv < wcap ? n_kv : wcap); // = qsa_selection_width(n_kv, s) +} + +void qsa_steps_fill_dev(int32_t* steps, int64_t p0, int64_t n, const QsaShapes& s, void* stream) { + if (steps == nullptr || n <= 0) return; + if (p0 < 0) fail("qsa_steps_fill_dev: p0 < 0"); + const int64_t wcap = s.idx_top_k + s.idx_block - 1; // qsa_selection_width's bound + floria_steps_fill_kernel<<<(unsigned) ((n + 255) / 256), 256, 0, (cudaStream_t) stream>>>(steps, p0, n, + (int64_t) s.idx_block, wcap); + check_launch("qsa_steps_fill_dev"); +} + void qsa_step_fill(int32_t* host_step, int64_t pos, const QsaShapes& s) { if (host_step == nullptr) return; if (pos < 0) fail("qsa_step_fill: pos < 0"); ``` </details>
Author
Owner

@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.

<!-- gh-comment-id:6110173504 --> @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.
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#683
No description provided.