Repository navigation
Description
Lane pi-hrx-sched. A measured hazard, filed because it turns measuring into a workload failure — and because the failure arrives at the client as a generic compute error.
Symptom
A long profiled session dies mid-workload with a per-request Compute error, and the workload is innocent. Measured on strixhalo (gfx1151), llama-server -np 4 -c 16384 on Qwen3-4B Q4_K_M with HRX_PROFILE_MODE=dispatch, two independent sessions:
E graph_compute: launch HRX graph replay: hrx-system/…/host_queue_profile_events.c:362: RESOURCE_EXHAUSTED;
dispatch profiling event ring exhausted: requested 475 events, available 313, ready 65223, capacity 65536
E srv send_error: task id = 133, error: Compute error. (all four slots, at n_tokens = 70)
Both sessions died at 65 223 dispatch events — the same count to the event — and the arithmetic closes: 65 536 − 65 223 = 313 free slots against the 475 events the next 4-slot decode step wants.
The controls that pin it to the instrument and not the serve (5 arms, no profiler where noted):
| config | n_predict | profiler | result |
|---|---|---|---|
-np 4 -c 16384, 4/1/4 concurrent |
64 | off | all HTTP 200, 64 tokens, twice, zero server errors |
| fresh server, one 4×64 phase | 64 | off | 4 × 200, 25.3-26.8 tok/s |
| fresh server, one 4×64 phase | 64 | on | 4 × 200 — 32 051 dispatches, passed |
| fresh server, 1→2→4 concurrent sequence | 64 | on | 4 × HTTP 500 Compute error — 65 223 dispatches |
So the shipped --parallel 4 serve is fine; what fails is a capture that outgrows its budget. Worth saying explicitly because I first reported it the other way (state entries 23/24) and retracted it in entry 26.
Mechanism
- The ring is a fixed 65 536 dispatch events per queue:
IREE_HAL_AMDGPU_HOST_QUEUE_PROFILE_DISPATCH_EVENT_CAPACITY = 64 * 1024(runtime/src/iree/hal/drivers/amdgpu/host_queue_profile_events.c:33), reserved per submission (:307-364), and a reservation that does not fit returnsRESOURCE_EXHAUSTED(:356-362). - Ring space is only reclaimed by advancing
read_position, which happens in exactly one place —iree_hal_amdgpu_host_queue_write_profile_events(host_queue_profile_events.c:655,read_positionwritten:759-763) — whose only callers areprofiling_end(logical_device.c:3361) andprofiling_flush(:3412). - libhrx calls
profiling_beginonce at init andprofiling_endonce at shutdown, and never callsprofiling_flush—libhrx/src/libhrx/runtime.c:680,697, andgrep -rn profiling_flush libhrx/is empty. The only periodic flusher in the tree is the IREE tooling layer (runtime/src/iree/tooling/device_profiling.c:341, reached by--device_profiling_flush_interval_mson IREE tools), which libhrx bypasses because it drives the HAL directly. - So under
HRX_PROFILE_MODEthe ring fills monotonically for the life of the process, and no knob inside HRX can raise it or drain it.
Diagnosability gap (the part that cost the most time)
The RESOURCE_EXHAUSTED text does reach the server log — verbatim, evidence/scheduler/exp11-raw/exp11-server.log:41 — I initially wrote that it did not and corrected that. What has no path to the text is the HTTP client: src/llama-context.cpp:2498-2500 logs the bare ggml_status (ggml_backend_sched_graph_compute_async failed with error %d), and the slot layer turns ret = -3 into error: Compute error.. A user sees a broken model, not a full ring.
Suggested fixes (any one is a fix; the first is the real one)
- Call
iree_hal_device_profiling_flush()periodically from libhrx while a session is active (e.g. every N completed submissions or every T ms), soread_positionadvances and the ring is a window rather than a lifetime. This is the fix this lane would write; it needs a libhrx change plus anhrx-systempin bump in the engine, which is why it is an issue and not a PR from here. - Make a failed reservation non-fatal: drop the dispatching events for that submission (and count them) instead of failing the submission. That is arguably right for an instrument in every case — a profiler should not be able to break the workload.
- At minimum, surface the cause: log the
RESOURCE_EXHAUSTEDtext at the slot error path, and/or document the ≤65 536-dispatches-per-process budget next toHRX_PROFILE_MODEindocs/hrx.md.
Acceptance
A profiled session can run past 65 536 dispatch events and keeps serving; or, if a budget is kept, the client-visible error names the ring and the numbers, and docs/hrx.md states the ceiling.
Note for other lanes, until this is fixed
Budget ≤65 536 dispatches per queue per profiled process on this stack. Data points from this lane: EXP-8 55 825 (within 9 700 of the ceiling — a slightly longer run would have produced a phantom engine bug report), EXP-10 39 099, EXP-11 65 223 (hit it), EXP-14 32 051. KNOBS.md carries the same budget in the HRX_PROFILE_MODE row.
Evidence: ~/amd-oss/hrx-study/evidence/scheduler/exp11-raw/, exp12-raw/, exp13-raw/, exp14-raw/; FACTS-scheduler.md §3 (signature row) and §5 EXP-11/12/13/14.
Activity
bong-water-water-bong commentedon Nov 3, 2026
Verified at the pin (
third_party/hrx-system=82804197bcbe, engine65460184), and the arithmetic closes exactly as reported:runtime/src/iree/hal/drivers/amdgpu/host_queue_profile_events.c:33→IREE_HAL_AMDGPU_HOST_QUEUE_PROFILE_DISPATCH_EVENT_CAPACITY (64 * 1024); the failed reservation constructsIREE_STATUS_RESOURCE_EXHAUSTEDat:316—65 536 − 65 223 = 313free slots against the 475 the next 4-slot step wants.read_positionis advanced only iniree_hal_amdgpu_host_queue_write_profile_events(:759region), reached fromprofiling_end/profiling_flush; andgit grep profiling_flushoverlibhrx/at the pin returns nothing, whilelibhrx/src/libhrx/runtime.ccallsiree_hal_device_profiling_beginat:680andprofiling_endat:697. So the ring is monotonic for the life of the process, exactly as the report says.Labels:
bug+hrx. Both halves of the acceptance cost a submodule change (libhrx flush, or the fork'ssrc/llama-context.cpp:2498-2500naming the ring) plus a pin bump, so this is an A row on the board, notC.One thing the report's third option does not need a device or a rebuild for:
docs/hrx.mddocumentsHRX_PROFILE_MODEat:252,:268,:409,:469and none of those lines states the ≤65 536-dispatch ceiling. If the ring is not going to be drained this week, that ceiling should be in the doc now, because the failure it produces reads as a model error. I have recorded the ceiling on the board row so no lane budgets a capture past it in the meantime.Owner: pi-hrx-sched. Next: whoever takes the flush also takes the doc line; I close this only on a merge whose evidence is either a capture past 65 536 events or a client-visible error that names the ring.
bong-water-water-bong commentedon Nov 4, 2026
Fix written, built and measured: 1bit-MONSTER/hrx-system#10, branch
1bit/895-profile-ring-reclaim, commit2043763420, base1bit/e3e6a976-pin-6(the branch the engine pins at82804197; the fork'smaindoes not containthat pin, so a PR against
mainwould not be the tree we run).Two changes in
iree_hal_amdgpu_host_queue_reserve_profile_dispatch_events, both at the one place where the ring isconsumed rather than in libhrx's five submission sites:
reclaim the events the GPU has completed. That is the same flush the IREE tooling performs on
--device_profiling_flush_interval_ms, and it turns the ring into a window over completed work instead of a lifetimebudget — which is what makes this cover the HIP binding path (hrx: HRX_PROFILE_MODE records nothing for HIP-binding launches, and says nothing about it #894's ring half) and any future submission path for
free, where a periodic libhrx flush would need one call per site and would miss new ones.
capacityeventsgenuinely in flight is a real condition; the right answer is a hole in the capture, not a dead session. Drops are
counted (
dropped_event_count) and the first one per queue prints the ring's numbers — requested, available, ready,capacity — so the hole is visible rather than silent. An empty reservation already means "nothing to profile" to the
caller (
host_queue_command_buffer_block.c:705), andcancel_profile_dispatch_eventsearly-returns on it, so thispath adds no new state to the submission machinery.
A single reservation larger than the ring stays
RESOURCE_EXHAUSTED: no flush can make it fit, so it is a configurationmismatch rather than this bug.
Measured on this box (gfx1151, pin
82804197, no-SVM trio), onegpu-hold(34 s, die 61 → 51 °C), two armsdiffering only in
libhrx.so.0.1.0(e12d4cecstock vsb99203c2fixed, both resolved from their own snapshot dirs andprinted by
lddin the run), same request shape as EXP-11 (1 → 2 → 4 → 4 concurrent, 64 tokens each,-np 4 -c 16384,Qwen3-4B-Q4_K_M,HRX_PROFILE_MODE=dispatch):ring exhaustedlog linesRESOURCE_EXHAUSTEDlinesSo the session runs past 65 536 dispatch events and keeps serving — the issue's first acceptance branch, with the
control faulting in the same hold so "it passed" is not a stale-library artefact.
Two limits, stated rather than implied:
of events genuinely in flight, i.e. a synthetic pressure test, not this workload. The flush-and-retry branch is what
the table above proves.
building on this shared die. The controlled signals are the HTTP statuses, the error lines and the recorded event
counts, all of which are arm-local.
The engine pin needs to move past
82804197for this to reach trees — that pin bump is not mine to make.Bump HRX: hrx-system 170d229a3 -- three libhrx/amdgpu profiling fixes…
Bump HRX: hrx-system 170d229a3 — three libhrx/amdgpu profiling fixes …
bong-water-water-bong commentedon Nov 6, 2026
Resolved. Fork PR 1bit-MONSTER/hrx-system#10 merged into the pin branch
1bit/e3e6a976-pin-6@170d229a3, and engine pin bump #1239 carries it;hw-gatevalidated the new pin on strixhalo.iree_hal_amdgpu_host_queue_reserve_profile_dispatch_eventsnow reclaims the ring on exhaustion (flush the device, retry) and drops only a submission that genuinely cannot fit, so the ring is a window over completed work instead of a lifetime budget. The issue's first acceptance branch is met with a control in the same hold: stock 3× HTTP 200 then 8× HTTP 500 at 65 508 recorded dispatch events; fixed 12× HTTP 200 and 106 863 events in one session, same workload, same device. The drop branch itself was not exercised (it needs more than a ring's worth of events genuinely in flight — a synthetic pressure test), which the issue records. Closing.docs: the post-fix in-engine capture the page owed — 3.5 % end to end…