Repository navigation
Description
Summary
hrx_hal_queue_transfer_and_wait (libhrx/src/libhrx/transfer.c) submits the upload/download on
device->transfer_queue with iree_hal_semaphore_list_empty() as its wait list, then waits only for its own
signal. Command programs complete asynchronously on the backend's stream, so a host transfer issued between two
graph programs can execute before the dispatch that produces or consumes those bytes.
ggml/src/ggml-hrx/ggml-hrx.cpp reaches that path from buffer_set / buffer_get — i.e. every cross-backend
copy ggml_backend_sched inserts — and from the HRX host-buffer memcpy branch, which has no ordering at all.
This is a latent data race on every HRX load with more than one split. It is not the cause of #674 (a
compute-stream synchronize before every buffer-level copy changed that output not at all), but it is the hazard
#674's body flagged in passing and left for its own issue.
Measured cost of the blunt fix
A full hrx_stream_synchronize before every buffer-level copy cost 6× on a 4B -ngl 0 run (5 s → 32 s,
measured while chasing #674; the patch was reverted for that reason). So ordering has to be semaphore-based,
not a full sync.
What a fix looks like
A wait semaphore derived from the stream's last submitted timepoint, or an explicit device-level barrier before
the transfer, so that:
- a
h2dcopy issued after a dispatch is ordered behind it (writes land after the producer's write), - a
d2hcopy is ordered behind the dispatch that produces the data, - the HRX host-buffer
memcpybranch gets the same ordering as the BO path (today it has none).
Until then, correctness on multi-split loads rests on the per-graph synchronizes happening to be far enough apart
— which is true in the configurations we run today and is not a property the executor guarantees.
Why it is worth filing rather than appending to #674
#674 is about a specific wrong output (every weight op on the CPU), and the ordering hazard was exonerated
there: adding a compute-stream sync changed nothing, at 6× cost. That makes the hazard invisible to #674's
reproducer, which is exactly the kind of finding that gets lost inside another issue's negative-result section.
It has its own blast radius (any multi-split graph), its own test (a transfer issued between two dispatches), and
its own acceptance (byte-identical output with the sync removed from the fast path).
Reproduce / prove the fix without a wrong-output reproducer
- Log ordering:
HRX_PROFILE_MODE=dispatchbundle of a multi-split graph (-ngl 0on a small model), then check
whether anyfill_buffer/copy_bufferrecord's start time precedes the producing dispatch's end on the
compute timepoint. If a bundle shows ordering today it is because of an unrelated stall, not a wait. - Acceptance for a fix: the same bundle shows every transfer ordered behind its producer, and the 4B
-ngl 0end-to-end time is not the 6× of the blunt sync (i.e. the semaphore is not a barrier), and output
is byte-identical to-dev none.
Related
- HRX route pins ~107 GiB outside process RSS on a 217 GiB mmap (DeepSeek-V4.1 UD-IQ1_S), independent of -ngl/ubatch/prefetch #669 — the same executor's host-weight residency: both are "what the executor assumes about when bytes are
where"; HRX route pins ~107 GiB outside process RSS on a 217 GiB mmap (DeepSeek-V4.1 UD-IQ1_S), independent of -ngl/ubatch/prefetch #669's bounded-residency work touchesrebind_prepared_host_weightsand its staging siblings, which is
the same code region a transfer-ordering fix has to reason about. - hrx: any graph whose weight ops all run on the CPU computes garbage (1 s reproducer) #674 — where this hazard was found and exonerated for that bug, with the 6× measurement.
- hrx: gfxhub page fault + MODE2 GPU reset when GTT nears the 120 GiB ceiling (Flash-Next UD-IQ3_XXS, 18.8k ctx, 106.5 GiB GTT) #680 — page faults at GTT 106.5 of 120 GiB; a copy ordered before its producer is one way a device read can
hit a page that is not there yet, so the two are worth reading together.
Source
Drafted by the pi-i669 lane in ~/briefs/TISSUES-669-STATE.md ("ISSUE-DRAFT — transfer-queue ordering hazard"),
filed by the issue keeper unchanged; the lane's wording is its own analysis.
Activity
bong-water-water-bong commentedon Nov 1, 2026
Status after the 15:53Z fork merges — same bookkeeping as #674, so this does not close on the merge alone.
#167→f55e176b5(host copies ordered with the compute dispatches) on1bit/hrx-vulkan-patchedmainpinsthird_party/llama.cpp=4a58da9b0, 8 commits behind the fork tip199165047-dev none, and not the blunt full sync's 6× (5 s → 32 s) — needs an HRX run at a build that contains the fixCloses on the pin bump to
199165047plus that run. Frozen until the post-reboot all-clear.bong-water-water-bong commentedon Nov 2, 2026
EVIDENCE — #696 closeable: the host copies are ordered and cost ~2.5 s, not 32 s, and the output is byte-identical
f55e176b5f3, live at the pin1d32c22609d6Qwen3-4B -ngl 0at the pin is byte-identical to-dev noneand takes 2.45 s, i.e. it does not carry the ~6x cost of the blunt per-copyhrx_stream_synchronize(5 s → 32 s) that the issue measured as the reason a naive fix was unacceptableMeasured tonight, one
gpu-holdticket, #715 trio on,-fit off -c 256 --temp 0 -n 8, pin1d32c22609d6(
GGML_HRX_169_DECLINE=none, i.e. the pin's own placement):-dev HRX0 -ngl 0Okay, the user is asking-dev noneOkay, the user is asking7edd7f2d2c0651a1820a78a5ef61c4e6on both sidesThe 2.5 s against the CPU's 0.95 s is the normal cross-backend copy cost on this box; the number that matters for the
close is that it is not the 32 s of the blunt fix, and the text is identical, so the ordering did not have to be
traded against correctness.
The one caveat worth keeping in the close: #167 fixes
buffer_set/buffer_get(the ordered host copy), and adifferent unordered path remains -
buffer_get's host-mapped branch is a barememcpy, and a read there is notordered against an in-flight dispatch. I built that experiment (
1bit/i674-hostread-ordered,1513e4e8c74) and it isnot the cause of #674, so it is a latent hazard rather than an open defect; it is written into #674's thread, not
this one.
Lane pi-i669.
bong-water-water-bong commentedon Nov 2, 2026
Closed on the evidence comment above — it carries the two numbers this issue's acceptance names, and both hold.
Fix: fork #167 →
f55e176b5, live in the engine at the pin1d32c22609d6(bumped in#786→7ba14cde9).The acceptance was "transfers ordered, not 6× (5 s → 32 s), byte-identical to
-dev none":1d32c22609d6,Qwen3-4B -ngl 0, onegpu-holdticket, #715 trio,-fit off -c 256 --temp 0 -n 8)-dev HRX0 -ngl 0Okay, the user is asking-dev noneOkay, the user is asking7edd7f2d2c0651a1820a78a5ef61c4e6on both sidesSo the ordering did not have to be bought with the blunt per-copy
hrx_stream_synchronize, whose 6× cost (5 s → 32 s) is what made the naive fix unacceptable in the first place. The 2.45 s against the CPU's 0.95 s is ordinary cross-backend copy cost on this box, not a synchronisation tax.Caveat carried into the record, not dropped: #167 fixes
buffer_set/buffer_get's ordered host copy. A different path is still unordered —buffer_get's host-mapped branch is a barememcpywith no ordering against an in-flight dispatch. The lane built that experiment (1bit/i674-hostread-ordered,1513e4e8c74) and showed it is not the cause of #674, so it is a latent hazard rather than an open defect; it lives in #674's thread, which is the right place for it.