Skip to content

hrx: a profiled session dies at 65 536 dispatch events, and the client is told only "Compute error" #895

Closed

Description

@bong-water-water-bong

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

  1. 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 returns RESOURCE_EXHAUSTED (:356-362).
  2. 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_position written :759-763) — whose only callers are profiling_end (logical_device.c:3361) and profiling_flush (:3412).
  3. libhrx calls profiling_begin once at init and profiling_end once at shutdown, and never calls profiling_flush — libhrx/src/libhrx/runtime.c:680,697, and grep -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_ms on IREE tools), which libhrx bypasses because it drives the HAL directly.
  4. So under HRX_PROFILE_MODE the 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)

  1. Call iree_hal_device_profiling_flush() periodically from libhrx while a session is active (e.g. every N completed submissions or every T ms), so read_position advances and the ring is a window rather than a lifetime. This is the fix this lane would write; it needs a libhrx change plus an hrx-system pin bump in the engine, which is why it is an issue and not a PR from here.
  2. 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.
  3. At minimum, surface the cause: log the RESOURCE_EXHAUSTED text at the slot error path, and/or document the ≤65 536-dispatches-per-process budget next to HRX_PROFILE_MODE in docs/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

  1. added
    hrx
    on Nov 3, 2026
  2. bong-water-water-bong commented on Nov 3, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Verified at the pin (third_party/hrx-system = 82804197bcbe, engine 65460184), and the arithmetic closes exactly as reported:

    • capacity: 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 constructs IREE_STATUS_RESOURCE_EXHAUSTED at :316 — 65 536 − 65 223 = 313 free slots against the 475 the next 4-slot step wants.
    • drainage: read_position is advanced only in iree_hal_amdgpu_host_queue_write_profile_events (:759 region), reached from profiling_end/profiling_flush; and git grep profiling_flush over libhrx/ at the pin returns nothing, while libhrx/src/libhrx/runtime.c calls iree_hal_device_profiling_begin at :680 and profiling_end at :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's src/llama-context.cpp:2498-2500 naming the ring) plus a pin bump, so this is an A row on the board, not C.

    One thing the report's third option does not need a device or a rebuild for: docs/hrx.md documents HRX_PROFILE_MODE at :252, :268, :409, :469 and 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.

  3. added
    bug
    on Nov 3, 2026
  4. bong-water-water-bong commented on Nov 4, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Fix written, built and measured: 1bit-MONSTER/hrx-system#10, branch 1bit/895-profile-ring-reclaim, commit
    2043763420, base 1bit/e3e6a976-pin-6 (the branch the engine pins at 82804197; the fork's main does not contain
    that pin, so a PR against main would 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 is
    consumed rather than in libhrx's five submission sites:

    1. On exhaustion, flush the device and retry. The queue already knows its logical device, so the reservation can
      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 lifetime
      budget — 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.
    2. If it still does not fit, drop that submission's events and keep the workload alive. More than capacity events
      genuinely 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), and cancel_profile_dispatch_events early-returns on it, so this
      path 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 configuration
    mismatch rather than this bug.

    Measured on this box (gfx1151, pin 82804197, no-SVM trio), one gpu-hold (34 s, die 61 → 51 °C), two arms
    differing only in libhrx.so.0.1.0 (e12d4cec stock vs b99203c2 fixed, both resolved from their own snapshot dirs and
    printed by ldd in 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):

    arm requests ring exhausted log lines RESOURCE_EXHAUSTED lines dispatch events the bundle recorded
    stock 3 × 200, then 8 × HTTP 500 (0.02-1.25 s each) 3 3 65 508
    fixed 12 × 200, every phase including both 4-slot passes 0 0 106 863

    So 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:

    • The drop branch is not exercised by this run (no "could not be reclaimed" line): it needs more than a ring's worth
      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.
    • Absolute tok/s between the two arms is not comparable (62.8 vs 24.9 solo): the first arm ran while other lanes were
      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 82804197 for this to reach trees — that pin bump is not mine to make.

  5. bong-water-water-bong commented on Nov 6, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    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-gate validated the new pin on strixhalo.

    iree_hal_amdgpu_host_queue_reserve_profile_dispatch_events now 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughrx

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions