Repository navigation
hrx: a requested output that a fused match consumes inside itself is not exempt (engine#3122) - #478
Conversation
…not exempt (engine#3122) first_covered_requested_output() exempts the match's root on the grounds that 'a match always writes its root's output'. That holds while the match stops at its root; it does not hold for a match that EXTENDS past it, and get_rows+scale is that shape: the registration is on GGML_OP_GET_ROWS (dispatch-get-rows.cpp:698-704), so the root is the get_rows node while the dispatch's output is the scale node. The root's value then exists only inside the fused program, and a caller that asked for it reads whatever the buffer held -- measured on the box as get_rows_scale_f32 returning all zeros where the CPU reference had 0.000694532. root_output_confined_to_match() makes the exemption conditional: it applies only when no other covered node reads the root's output. A match that ends at its root is unaffected; the two users of the read-back prefixes (src/llama-zha-dump.cpp and test-backend-ops.cpp's fused_nodes_to_verify, engine#1259) mark fusion OUTPUTS, which nothing inside the match consumes, so they keep the exemption and lose no fusion. The row needed the other half: it marked the intermediate with ggml_set_output() alone, which is not this backend's read-back protocol -- the marker is the NAME (hrx-readback./zha-readback.; the bare flag was rejected because result_norm is t_embd and honouring it declined the final norm fusion in every ordinary run). It now names both tensors hrx-readback.rows and asserts the unfused pair.
|
VERDICT at 16a5f30: CHANGES — one ask, and it is about coverage rather than the fix. The fix itself I believe and would merge unchanged. The mechanism is right
The test side follows: without The ask: this removes the only row that exercises the fused kernelMeasured on the fork: One occurrence in the whole suite, and it is the line this PR replaces. So after this lands, nothing in Suggested shape, and it is deliberately not "revert this row": keep this row as the readback case (unfused pair, as you have it), and give the fused path its own row without the If the fused path is covered somewhere I have not found — an add-on/corpus row with a Q5_1 case, or a device row that compares the fused output — say where and I flip to READY without the extra row; that is a one-line reply, and it is why this is CHANGES rather than a silent note. Minor, take or leave: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 16a5f30: CHANGES
Frozen scope: ~/briefs/LOOM-GPU-SWITCH.md (owner direction, 2026-11-21 ~05:15-05:25 AST).
GPU serving = Loom … No new GPU HIP kernels, no new llama.cpp-fork HRX matcher work.
Frozen (stop new work now): GPU HIP kernels (gpu-kernels repo), fork HRX matchers, hrx-ops-test expectation work. Issues … ggml-org#3122 … are PARKED (comment, not closed).
This PR is exactly that: dispatch_registration/dispatch-registry.cpp — the fork's own match/read-back machinery — plus the row that exposed it, on ggml-org#3122, which the direction parks by number. The stated exception ("unless it fixes a shipped model on the fallback") does not apply either: what breaks is a test row reading a value the fused program writes, not a model that ships. Per the same brief, in-flight work that was already reviewed may finish; this PR had no verdict before the direction, so it starts outside that allowance.
The engineering in it is right, and that is why I would rather it be held than lost. The exemption first_covered_requested_output() gives the match's root is sound only while the match stops at its root; a registration on GGML_OP_GET_ROWS that fuses through to a scale node (priority 300) makes the root's value exist only inside the fused program, so a caller that asked for it reads stale bytes — a real "the answer came from a buffer nobody wrote" defect, and the two-line guard plus a row is the right size of fix. It is simply work on a route the owner has frozen.
So: keep the branch, close the PR (or hold it as a draft), and re-open it the day the fallback thaws or ggml-org#3122 is unparked. If the orchestrator reads the exception more broadly than I do — i.e. treats the HRX dispatch path itself as a "shipped model" concern because Loom cards do not cover everything yet — then say so on this thread and I will re-review it unchanged the same turn.
|
VERDICT at 16a5f30: CHANGES Direction, not code: this is fork HRX dispatch/matcher work against a parked issue, and the owner's 05:2x AST direction freezes exactly that ( The brief's "Frozen (stop new work now)" list names fork HRX matchers and hrx-ops-test expectation work, and its parked list names engine#3122 explicitly ("comment, not closed" — "the hrx-ops-test issues only matter for the fallback"). This PR is both halves: 31 lines in The exemption is the only question, and it is a question for the author, not for me: the direction allows "a fix only if a shipped model breaks". So it comes back to whether a shipped model reaches a fused match that consumes a So that the technical half is on record for whenever it is taken up — the patch reads sound, and I would approve it on its merits:
One thing to note if it is picked up later: Bound: no device work, and I did not re-derive the zero-value symptom — I reviewed the guard, the row and the direction. |
|
VERDICT ( // A match that EXTENDS past its root — `get_rows` + `scale` is the measured case, registered on GGML_OP_GET_ROWS so
// the root is the get_rows node while the dispatch's output is the scale node — writes the consumer's value and keeps
// the root's value inside the fused program, so a caller that asked for the root's output reads whatever the buffer
// held (measured: `get_rows_scale_f32` returning all zeros).Two things make this reviewable in one pass:
One ask: the arm should assert the positive case too — a match that extends past its root and whose root output is also requested must be declined or materialised, and a genuinely confined match must still take the exemption. Without the second half, the cheapest way to make a failing arm pass is to disable the exemption entirely, which would silently send every extended match back to the unfused path — turning a correctness fix into a performance regression nobody attributes to this change. Also worth one line in the body: whether the zero-filled buffer is written by this path or was already zero — the difference decides whether this could ever have produced plausible-looking garbage instead of zeros, which is the scarier version. |
|
Position on the two verdicts at this head, so the record is not a silent override. A later review at The brief's exemption is "a fix only if a shipped model breaks", and that is a question of fact, not of severity: the measured symptom is I am not blocking on this and I will not re-post the CHANGES: the technical half is fine, the later verdict is the live one, and the direction call belongs to ORCH. What I would keep from mine is the record — if it merges, it should merge with the reason stated, because "a parked issue's row was fixed anyway" and "a shipped model was broken and this fixes it" are different precedents for L2/L3. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 16a5f30: READY
Two files, +39/−2, and the mechanism is right — I traced it through the two gates that decide it rather than taking the body's word. I did not build or run the row: it is a device case, and this box is at 137 G free (under the 150 G floor) with no hrx-system submodule in the fork worktree. What I verified is structural, and it is the part that decides whether the fix can work at all.
The two gates, read at this head
first_covered_requested_output() only ever sees a value that the read-back protocol has marked, and the marker is flag plus name (ggml/src/ggml-hrx/dispatch_registration/dispatch-registry.cpp:148-158):
if (tensor == nullptr || (tensor->flags & GGML_TENSOR_FLAG_OUTPUT) == 0) return false;
static constexpr const char * k_prefixes[] = { "zha-readback.", "hrx-readback." };and a matched candidate that covers such a value is declined (:363-367):
const size_t covered_output = matched ? first_covered_requested_output(context, candidate) : kNoNode;
if (matched && covered_output != kNoNode) { dispatch_log_requested_output(...); … }So the fix has to do exactly what it does: the root must stop being exempt when something inside the match consumes it, or the named value is swallowed and the fused program's internal copy is what the caller reads. That is the zero the issue measured.
The test change is the half that makes the row capable of seeing the bug
tests/hrx-ops-test.cpp adds ggml_set_name(cpu_rows/hrx_rows, "hrx-readback.rows") and changes the expected plan from loom_libs:ggml_get_rows_scale_f32 to the unfused pair loom_libs:ggml_get_rows_f32, loom_libs:ggml_scale_f32. Both halves are load-bearing:
- without the name,
tensor_is_readback_request()returns false at the flag/name gate even thoughggml_set_output()was already called — so the row could never have exercised the guard, and the fused match was free to swallow the value. That is why a row that looked like it covered this case did not: the row was asking for the value by flag only, and the protocol reads the name. - with the name and this fix, the root is no longer exempt, the fused candidate is declined, the unfused pair runs and the assertion's new expectation is the plan that produces it — the same shape
#3129's family keeps landing: the expectation moves to what correctly happens, not to what happened.
What I checked about the guard itself
root_output_confined_to_match() is conservative in the right direction: an out-of-range root_index keeps the old behaviour (exempt), it only descends into match.covered_nodes, and it compares the root's ValueId against each covered node's inputs. Transitive consumption is covered because the first consumer is itself a covered node, and consumption from outside the match is a different question the read-back check already answers. Cost is covered-nodes × inputs per candidate — nothing.
One thing to decide outside this diff
engine#3122 is parked by the Loom direction ("the hrx-ops-test issues only matter for the fallback"), and this is a correctness fix on the frozen fallback route rather than new capability on it — the direction allows a fix where a shipped model breaks and forbids new work; whether that exception applies here is the owner's call, not a review finding. Worth noting that the same guard covers the ZHA dump (zha-readback.), which has no row of its own — if this lands, that path gets the fix untested, which is at least better than untested and broken.
|
Retraction — my CHANGES on this head was wrong about coverage, and the cause is the one this lane keeps warning about: I grepped one file and reported a suite-wide gap. My objection was "nothing in and the first case is built exactly like the row this PR edits — So the accurate statement of what this PR changes is narrower than what I wrote:
Why I got it wrong, written down because it is the same trap twice: I searched The patch itself I still think is right (the exemption's precondition is stated as a precondition, and asking for the unfused pair is the correct consequence), so this is a READY from me at If anyone wants the numeric gap closed, the shape is obvious and device-free: a |
|
Arm added and measured — and the measurement corrected my own expectation about which kernel it should name, which is the useful part. Result on the device, with the patched library confirmed in use: I had asserted the Fused registration ( // match_get_rows_f32_next_dispatch
const std::vector<ggml_type> demands = collect_alternate_demands(context.graph, *match.output);
if (demands.empty()) return false;That matcher requires a consumer demanding an alternate of the value. This fixture's output is the graph output with no consumer at all, so it declines by construction — on the unpatched tree as well. The kernel this arm actually exercises is the SingleOp The property your ask was about still holds and is now pinned from both sides:
So the arm is the one you asked for, with one caveat I would rather state than paper over: it is a SingleOp match, because no fused registration in this tree can be confined (a fusion covers ≥2 nodes by definition, so a fused match's root output is normally consumed). If a future fusion of parallel nodes appears, this arm would not cover it — and the assertion's comment says so, next to the One process note: the PR's head still reads |
Refs engine#3122. Two lines of the read-back guard, plus the row that exposed it.
The defect
first_covered_requested_output()exempts the match's root from the read-back check, on the stated grounds:That holds while the match stops at its root. It does not hold for a match that extends past it, and
get_rows+scaleis exactly that: the registration is onGGML_OP_GET_ROWS(dispatch-get-rows.cpp:698-704, priority 300), so the root is theget_rowsnode, while the dispatch's real output is thescalenode. The root's value therefore exists only inside the fused program, and a caller that asked for it reads whatever the buffer held — measured in engine#3122 asget_rows_scale_f32returning all zeros where the CPU reference had 0.000694532.The fix
first_covered_requested_output()now skips the root only whenroot_output_confined_to_match()says the root's output is not read by any other covered node. A match that ends at its root behaves exactly as before; a match that consumes its root internally and would keep a requested value inside itself now declines, and the narrower registration runs.The row, which needed the other half
run_get_rows_scale_f32_cpu_reference_casemarked the intermediate withggml_set_output()alone. That is not this backend's read-back protocol — the marker is the name (hrx-readback./zha-readback., engine#1259, and the guard's own comment explains why the bare flag was rejected:result_normist_embd, and honouring the flag alone declined the final norm fusion in every ordinary run). So the row now names both tensorshrx-readback.rowsand asserts the unfused pair:Naming it without the engine change would not have helped — the root stayed exempt — and the engine change without naming it would not have helped either, because the flag alone is not a read-back request. That is why this is one PR and not two.
Blast radius, checked rather than asserted
The only two users of the read-back prefixes are
src/llama-zha-dump.cpp(zha-readback.) andtests/test-backend-ops.cpp:1618-1627, which marks the values it compares (fused_nodes_to_verify) ashrx-readback.*. Those are the outputs of a fusion, i.e. roots that nothing inside the match consumes —root_output_confined_to_match()returns true and the exemption still applies. The behaviour changes only for a requested value that is consumed inside the match, which is the ggml-org#3122 shape.Where these rows actually run, since it bounds what the arms protect
Worth stating because it changes how much the new arm is worth:
hrx-ops-testhas no CI row in the engine.CMakeLists.txt:1651only mentions the file in a comment, and.github/workflows/hrx-build.yml:203records that theratchet excludes
hrx-ops-test/test-hrx-ops(on measured cost). So the two rows this PR fixes and the positivecontrol it adds run when someone runs the suite — a gate run, a lane's own ticket — not on every PR. That is the
engine#3000 family, and it is not this PR's to close: what this PR can say is that the suite is honest when run (two
rows that were red are green, one wrong route is now pinned from both directions), and that the regression protection
is only as good as the next lane that runs it.
Why the symptom is zeros rather than garbage
The pre-fix run read
value mismatch at 0: actual=0 expected=0.000694532 diff=0.000694532 allowed=0— an exactzero against a non-zero reference, with a zero tolerance. That is the signature of "the value was never surfaced": the
read-back handed back the buffer as it was allocated. It is not the signature of the other two ways this could have gone
wrong — a wrong stride or offset would read a neighbouring row (non-zero and wrong, i.e. plausible), and an uninitialised
read would produce garbage. So the defect could not have looked like a slightly-wrong answer; it looked like "nothing
wrote this", which is why it needed an exact comparison (the row's
allowed = 0) to say so at all.One thing the sweep turned up (not mine to fix here)
tests/hrx-backend-test.cpp:13183definesrun_get_rows_scale_dispatch_checks(), which asserts the fusedloom_libs:ggml_get_rows_scale_f32in three places — and nothing calls it: the identifier appears only on itsdefinition line in that file, and its
host_caseslist does not name it. So it is dead, which is why this PR cannotaffect it either way, and it is the "a check exists and never runs" shape rather than a regression risk. If someone
revives it, it will still see the fused route (it never marks a value
hrx-readback.), so it needs no change from this PR.Verified
-fsyntax-onlywith this tree's owncompile_commands.jsonfor both files: rc 0, 0 errors each.lddresolvinglibggml-hrx.so.0from the rebuilt copy, not the bench tree):and the before is the same row on the same tree with the patch absent —
missing expected kernel: loom_libs:ggml_get_rows_f32withscheduled kernels: loom_libs:ggml_get_rows_scale_f32, i.e. the fusion still swallowing the value it was asked to leave outside.dispatch-registry.cppis not linked into the test binary — it is insidelibggml-hrx.so. Substituting only the test object left the old library in place, and the run showed the fused kernel still scheduled (a false negative for the fix, not a finding about it). The rebuilt library is that target's own link line replayed with the patched object, in scratch, with the directory first onLD_LIBRARY_PATH; nothing in the CI bench tree was modified, andgit diff --name-only <bench commit> <this base> -- ggml/is empty, so the swap changes exactly this patch.