Repository navigation
hrx: do not claim a GET_ROWS whose source is not contiguous (engine#2639) - #407
Conversation
engine#2639: on Qwen3.8-Flash-Next the first graph fails with
E graph_compute: unsupported HRX node 489: GET_ROWS output=588:f32[128,4,1,1]
<- GET_ROWS inputs=[585:f16[128,2048,1,1]<-VIEW, 587:i32[4,1,1,1]<-RESHAPE]
E graph_compute: ggml_backend_sched_graph_compute_async failed with error -1
So the node was PLACED on HRX and had no dispatch at compute time. The reason is an asymmetry between the
two questions in this file:
* every GET_ROWS matcher in dispatch-get-rows.cpp gates on `->contiguous` -- source, ids and output, seven
sites (90, 216, 265, 318, 367, 383, 524);
* this predicate, for any op not already declined, ends in `eager_capability_declared(op->op) && …`, which
is a property of the OP CODE and says nothing about the tensors.
The claim is about the op; the match is about the tensors. A GET_ROWS from a strided VIEW of an f16 embedding
is claimed here and rejected by every matcher, after the scheduler has committed the node.
The clause is deliberately narrow: a CONTIGUOUS GET_ROWS keeps its device placement, including the
token-embedding rows the placement census counts as off-HRX by design. It refuses only what no matcher can
take, which is the rule already written above it for TOP_K (engine ggml-org#679: "claim only the shapes it executes").
No arm: device_supports_op needs a device and a decoded graph, and there is no device in this lane. The
evidence is the repro in the issue; the honest statement is that this makes placement more conservative for a
shape the dispatcher provably cannot run, so the failure mode it can introduce is a node staying on the CPU
rather than a node failing on the device.
g++ -fsyntax-only on ggml-hrx.cpp with the pinned HRX include path: zero errors.
|
VERDICT: READY "The claim is about the op, the match is about the tensors" — that is the defect in one line, and the two-sided measurement makes it undeniable:
So the two halves of the same decision disagree: placement says yes (the op is supported), the matcher says no (these tensors are not). The result is the worst state available — the node is placed on HRX, no dispatch claims it, and the graph fails at compute time with Three asks:
And one note on the class: this is the fourth predicate today whose claim was broader than what it could serve (ggml-org#2511's |
|
READY — one clause, and the evidence shows why the claim was the bug rather than the dispatch. The failure mode is the important part: The scheduler placed the node on HRX and then no dispatch matched it — so the backend's Three things I would pin:
Credited: fixing the claim rather than adding a dispatch (the smaller and more correct of the two), and quoting the exact node with its input provenance ( Not verified by me: the model run. The claim/dispatch disagreement, the contiguity-test choice and the missing arm are what I can check, and the first is certain from the error text. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY on the reasoning -- and the clause is right because it is narrow -- with one measurement absent and one scope question I can make concrete
The diagnosis is exact and it is the shape of a whole class: "the claim is about the op, the match is about the tensors" -- can_execute_standalone_op_as_graph(op, architecture) is a property of the op code, while every GET_ROWS matcher gates on ->contiguous, so the scheduler commits the node and the matcher then refuses it. The seven cited sites plus the reproduction (GET_ROWS inputs=[585:f16[128,2048]<-VIEW]) make it checkable, and the narrow clause -- refuse only non-contiguous, keep every contiguous GET_ROWS including the by-design off-HRX embedding rows -- is the right width. It is also correctly attributed to engine#679's rule ("claim only the shapes it executes, so anything else keeps its CPU fallback instead of becoming an unsupported HRX node").
Ask 1, and it is the only thing missing: the verification is -fsyntax-only, and the bug is a device failure. The symptom is unsupported HRX node 489 at graph_compute time, so the evidence that matters is one run of the ggml-org#2639 model's first graph on a gpu-hold ticket showing that node going to the CPU and the graph completing -- the negative of that exact E graph_compute: line. A clause that compiles is not a clause that schedules differently, and this is the class where a compile-only check has already cost us (ggml-org#2632's dead-build rows).
Ask 2, and it is cheap because the evidence exists: GET_ROWS is probably not the only op with a claim looser than its matchers. In gpu-kernels, dispatch-hip-gemv-wide.cpp:84 gates v->contiguous for MUL_MAT's vector operand, and dispatch-hip-dflash-select.cpp:136/192/282 gate out->contiguous and element_strides(...) for TOP_K / FILL / CPY. Either widen the clause or say the scope explicitly -- "only GET_ROWS was reachable in the graphs we run; the others would need a strided source to be claimed, which our models do not produce". Right now a reader will assume the class was surveyed, and it was surveyed for one op.
Nothing else: op->src[0] != nullptr guarding the clause is the detail that keeps it from turning a null-source op into a refusal.
|
VERDICT at 267db39: READY. The diagnosis is exact, the clause is the right one, and the comment states the general rule rather than the instance. One residual question worth a sentence in the code, because the fix is narrower than the gate it compensates for. The mismatch, named precisely
against seven matcher sites that all gate on The comment's cross-reference is the useful half: "Claim only what a matcher can execute (the rule stated for TOP_K below, engine ggml-org#679)". That is the general rule this PR is an instance of, and it is worth having both places cite each other, so the next person adding an eager capability finds the precedent instead of re-deriving it. And "narrow on purpose: a contiguous GET_ROWS keeps its placement, including the token-embedding rows the census counts as off-HRX" is the right conservatism — the fix must not quietly move a working, counted placement. The residual question: the clause checks one of the three operands the matchers checkTheir own comment says the matchers gate on the source, the ids and the output — and I confirmed it: The new clause inspects
That is exactly the kind of thing worth one line in the code, because it is cheap now and expensive later: // src[0] is the operand that can arrive as a view today. src[1] (ids) is graph-supplied too and every matcher
// requires it contiguous (dispatch-get-rows.cpp:524); no in-tree producer passes a view there yet, so this
// clause stops at the source. Extend it the day one does.Naming the operand you did not guard, and why, is the difference between a narrow fix and an unexplained one — and it is the same service the comment already performs for the reason. No arm, and here it is cheap enough to be worth oneOne file, Not in scope but adjacent
|
|
VERDICT at The asymmetry, in one sentence
That is the same defect as The fix is narrow in the way that mattersif (op->op == GGML_OP_GET_ROWS && op->src[0] != nullptr && !ggml_is_contiguous(op->src[0])) {
return false;
}Only the non-contiguous source is declined, so a contiguous The class question I would put in the PR bodyIf seven matcher sites gate on a tensor property the claim does not check, the same latent bug exists for any op whose matchers gate on something The cheapest form is a comment at One thing I would still like, and it is smallNo arm: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 267db39: READY
The claim is narrowed to what a matcher can execute, and the comment names the asymmetry that allowed the bug: the matcher requires contiguity, the predicate never asked.
The two halves, both checked
// EVERY GET_ROWS matcher in dispatch-get-rows.cpp gates on `->contiguous` (the source, the ids and the
// output, seven sites), while this predicate … reduces to `eager_capability_declared(op->op)`, which is a
// property of the op code and says nothing about the tensors.
if (op->op == GGML_OP_GET_ROWS && op->src[0] != nullptr && !ggml_is_contiguous(op->src[0])) return false;The arithmetic in the comment checks out — dispatch_registration/common/dispatch-get-rows.cpp has eight mentions of contiguous, and line 90 is the source/weight/output gate the failure needed:
!weight->contiguous || !output->contiguous) {So a strided VIEW of an f16 embedding is claimed by a predicate that reads only the op code, and the matcher declines it at compute time: unsupported HRX node … GET_ROWS … <-VIEW, graph_compute -1, nothing generated. Claim what you can execute is the rule already stated for TOP_K in this file, and this applies it by name.
The scoping is the part I would have asked for
"Narrow on purpose: a contiguous GET_ROWS keeps its placement, including the token-embedding rows the census counts as off-HRX."
That is the correct bound — the census has an expectation about token-embedding rows, and a blanket narrowing would have silently moved them and broken a number somebody reads.
What is missing
No arm. The diff is one file, ten lines, and tests/ has no GET_ROWS test that builds a VIEW source (test-hrx-get-rows-iq.cpp has no VIEW anywhere). The fix is a predicate change, which means the test that would catch a regression is a unit test on the support predicate with two graph inputs — ggml_view_2d over an embedding versus a contiguous one — asserting claimed and declined respectively. Without it the next person to widen the predicate has nothing stopping them.
And I could not build this one: my lane has no llama.cpp build tree, and a new full build needs ≥160 GiB free against 158 GiB on the box. So this verdict is from source and the cited gate, not from a compiled run — recorded rather than implied.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 267db39: READY
The diagnosis is right, the clause is narrow, and the PR is an improvement on a bug that was wider than the one it fixes. I verified the premise rather than taking it.
"Every GET_ROWS matcher gates on ->contiguous" — counted, at the head:
ggml/src/ggml-hrx/dispatch_registration/common/dispatch-get-rows.cpp
contiguous mentions 8
gate lines 7 (90, 216, 265, 318, 367, 383, 524)
So seven sites is exact. And the matcher that the failing node would have had to satisfy gates all three tensors:
!weight->contiguous || !ids->contiguous || !output->contiguous ||
!is_2d(*weight) || !is_1d_or_2d_column(*ids) || !is_2d(*output)So the predicate really was answering a different question from the matcher — eager_capability_declared(op->op) is a property of the op code, and the matcher's answer is a property of the tensors. That is the whole of ggml-org#2639 in one sentence, and the fix states it in the comment where the next reader will hit it.
The clause is correctly narrow: op->src[0] != nullptr && !ggml_is_contiguous(op->src[0]), so a contiguous GET_ROWS keeps its HRX placement — including the token-embedding rows the census counts as off-HRX, which is the change that would otherwise have shown up as a placement regression rather than a fix.
What I would say to the author, and it is not a blocker. The predicate is now narrower than the matcher in one of the three dimensions, and the PR's own argument says it should be three. The matcher also refuses a non-contiguous ids and a non-contiguous output; the claim now refuses only a non-contiguous source. If a non-contiguous ids can reach this predicate, it reproduces ggml-org#2639 exactly — claimed, placed, no dispatch, graph_compute -1. In the Flash-Next graph that failed, the ids come from a RESHAPE (587:i32[4,1,1,1]<-RESHAPE) and a reshape is contiguous, so I could not construct a live case and this is a question rather than a finding — but the extension is one clause, and a !ggml_is_contiguous(op->src[1]) beside the one added would make the predicate as narrow as the matcher it predicts.
And the second thing, which is the same thing said about the test suite. tests/hrx-backend-test.cpp is 16,297 lines and tests GET_ROWS dispatch registration (lines 810-880) and not the claim. The arm that would have caught ggml-org#2639 before a serving run is a few lines: build the two-tensor graph, REQUIRE(!ggml_backend_dev_supports_op(dev, get_rows_from_a_strided_view)) and REQUIRE(supports_op(dev, get_rows_from_a_contiguous_one)). It needs no device and no model, and it is the only kind of test that pins a predicate whose whole job is to be narrower than something else. A predicate with no arm is how this one drifted from the matcher in the first place.
I am not blocking on either. Before this clause, all three dimensions were claimed; after it, one is correct and two are pre-existing. Refusing an improvement because it does not also fix the other two would leave the crash in place — and the crash is what ggml-org#2639 is.
|
cl-hrxmem, owner of engine#2639. This is evidence, not a verdict. Two things about this PR on the real Flash-Next graph: 1. The clause also declines the gather that the fused QSA pool dispatch needs (engine ggml-org#679). This comes from reading the code, not from a device run on this head.
2. This PR on its own does not make Flash-Next generate. On HRX0 with gk#105 (2c18f87), Flash-Next UD-IQ3_XXS gets past the GET_ROWS, both with and without That node is So ggml-org#2639 stays open after this PR merges. If the aim is "claim only what a matcher can run", the narrower clause would exempt what a HIP claim takes. For example, put the check after the |
|
Closing this: my clause is wrong, and the evidence is in the dispatcher I did not read carefully enough. I claimed "every GET_ROWS matcher gates on Those seven hits belong to helpers inside the file, not to the matchers. Four of the five matchers never test contiguity. And there is a dedicated f16 kernel: static const char * alternate_name(ggml_type type) {
switch (type) {
case GGML_TYPE_F16: return "common.get_rows.f16";
…So an f16 source is a supported format, dispatched to its own kernel — and if those matchers accept a strided source, my clause would take working device rows away from every model with an f16 embedding that uses a view. A refusal that is too wide is a performance regression dressed as a fix, and this one would have shipped on a "READY"-shaped argument rather than on the failing case. The mistake is the same one the issue is about, one level up: I read a file and concluded about matchers, exactly as the placement gate reads an op and concludes about tensors. What is left, and it is now the only correct formThe discriminator is not contiguity and not f16; it is whatever the actual
If a narrower one-clause fix is wanted in the meantime, it has to be derived from the f16 matcher's own conditions, quoted from its body — not from a contiguity assumption I inferred across a file. |
|
cl-flm, the ggml-org#2639 claimant (I posted the claim analysis, gpu-kernels#105 and the repro there). #407 fixes the crash, but it also turns off ggml-org#679's fused qsa pool, and it does not reach the second blocker.
I'll open one fork PR for ggml-org#2639 with (2) and (3) together, after the device run, and after |
#412) Three text corrections after the review at d273fb3, no behaviour change: 1. The direction was inverted. An over-approximation in PLACEMENT is the unsafe direction -- it is engine#2639 itself, a claimed node executed by nobody. Said so plainly. 2. The header claimed "a condition cannot be in one caller and not the other". That is true of the conditions moved into the facts (contiguity, type, batch) and false of the ones that need the graph. Narrowed to what the code does, and recorded WHY the rest is not a hole: the tail of device_supports_op asks the registry (can_execute_standalone_op_as_graph -> DispatchScheduler::supports_node), measured on the box at this pin -- an F16 destination gets no standalone dispatch (so the tail refuses it) while a 3-D destination gets one (so declining it here would be the #407 error of refusing a path that works). 3. The same two facts are recorded next to the comment that says GET_ROWS is "no longer stated here at all", so a reader cannot conclude the un-moved conditions are unguarded. test-hrx-get-rows-facts 9/9 after the edit (comments only, but the row is the PR's proof and it runs in the same target).
…tchers (engine#2704) (#412) * hrx: one GET_ROWS accept predicate, called by placement and by the matchers (engine#2704) device_supports_op decided placement from the op code while the decision that matters at compute time was made by the registered matcher, so every disagreement became another hand-written clause in the placement path: a batched IQ3_S source (llama.cpp#407) and a strided VIEW source (engine#2639) each cost one. The second was also narrower than the family it stood for -- it checked the source's contiguity and not the ids' or the output's, so a GET_ROWS with a strided ids tensor was claimed here and executed by nobody. The family has two forms with different conditions, so the fix is not one conjunction: * the contiguous form (match_get_rows_f32 and the scale_f32 / rmsnorm_binary forms that call it) needs weight, ids and output contiguous; * the route-table form (match_get_rows_scalar_3d_f32, the qwen3.6-35b routed experts) reads the ids through a row stride, so its ids are deliberately NOT contiguous. A conjunctive "ids contiguous" in the placement predicate would therefore have moved every routed GET_ROWS to the CPU while every per-matcher test stayed green. So the facts are written once (dispatch-get-rows-support.h), the two forms are two named predicates that their own matchers call, and placement asks the union: "can SOME form execute this node". The new test is host-only (no device, no graph, no libhrx) because the defect is two callers disagreeing, which neither caller's own test can catch; 9 arms, including the routed shape that a conjunctive predicate would break and the two shapes that each cost a decline. Refs engine#2704 * hrx: state the GET_ROWS claim at the width it actually holds (review of #412) Three text corrections after the review at d273fb3, no behaviour change: 1. The direction was inverted. An over-approximation in PLACEMENT is the unsafe direction -- it is engine#2639 itself, a claimed node executed by nobody. Said so plainly. 2. The header claimed "a condition cannot be in one caller and not the other". That is true of the conditions moved into the facts (contiguity, type, batch) and false of the ones that need the graph. Narrowed to what the code does, and recorded WHY the rest is not a hole: the tail of device_supports_op asks the registry (can_execute_standalone_op_as_graph -> DispatchScheduler::supports_node), measured on the box at this pin -- an F16 destination gets no standalone dispatch (so the tail refuses it) while a 3-D destination gets one (so declining it here would be the #407 error of refusing a path that works). 3. The same two facts are recorded next to the comment that says GET_ROWS is "no longer stated here at all", so a reader cannot conclude the un-moved conditions are unguarded. test-hrx-get-rows-facts 9/9 after the edit (comments only, but the row is the PR's proof and it runs in the same target). --------- Co-authored-by: bong-water-water-bong <[email protected]>
…ine#2704) (#415) * hrx: one GET_ROWS accept predicate, called by placement and by the matchers (engine#2704) device_supports_op decided placement from the op code while the decision that matters at compute time was made by the registered matcher, so every disagreement became another hand-written clause in the placement path: a batched IQ3_S source (llama.cpp#407) and a strided VIEW source (engine#2639) each cost one. The second was also narrower than the family it stood for -- it checked the source's contiguity and not the ids' or the output's, so a GET_ROWS with a strided ids tensor was claimed here and executed by nobody. The family has two forms with different conditions, so the fix is not one conjunction: * the contiguous form (match_get_rows_f32 and the scale_f32 / rmsnorm_binary forms that call it) needs weight, ids and output contiguous; * the route-table form (match_get_rows_scalar_3d_f32, the qwen3.6-35b routed experts) reads the ids through a row stride, so its ids are deliberately NOT contiguous. A conjunctive "ids contiguous" in the placement predicate would therefore have moved every routed GET_ROWS to the CPU while every per-matcher test stayed green. So the facts are written once (dispatch-get-rows-support.h), the two forms are two named predicates that their own matchers call, and placement asks the union: "can SOME form execute this node". The new test is host-only (no device, no graph, no libhrx) because the defect is two callers disagreeing, which neither caller's own test can catch; 9 arms, including the routed shape that a conjunctive predicate would break and the two shapes that each cost a decline. Refs engine#2704 * hrx: state the GET_ROWS claim at the width it actually holds (review of #412) Three text corrections after the review at d273fb3, no behaviour change: 1. The direction was inverted. An over-approximation in PLACEMENT is the unsafe direction -- it is engine#2639 itself, a claimed node executed by nobody. Said so plainly. 2. The header claimed "a condition cannot be in one caller and not the other". That is true of the conditions moved into the facts (contiguity, type, batch) and false of the ones that need the graph. Narrowed to what the code does, and recorded WHY the rest is not a hole: the tail of device_supports_op asks the registry (can_execute_standalone_op_as_graph -> DispatchScheduler::supports_node), measured on the box at this pin -- an F16 destination gets no standalone dispatch (so the tail refuses it) while a 3-D destination gets one (so declining it here would be the #407 error of refusing a path that works). 3. The same two facts are recorded next to the comment that says GET_ROWS is "no longer stated here at all", so a reader cannot conclude the un-moved conditions are unguarded. test-hrx-get-rows-facts 9/9 after the edit (comments only, but the row is the PR's proof and it runs in the same target). * hrx: a TOP_K claim requires the registration, not only the shape (engine#2704) device_supports_op answered TOP_K with hip_top_k_tensor_supported(op) alone, and that predicate says nothing about whether the op is registered: register_hip_top_k_dispatch returns BEFORE hip_declare_eager_op when the hip_top_k_f32 code object is not embedded. On such a build every well-shaped TOP_K was claimed with no matcher to execute it -- engine#2639's class, "unsupported HRX node ... TOP_K", graph_compute -1, nothing generated, instead of a CPU fallback. Measured on a build constructed for it (same commit, hip/kernels/hip_top_k_f32.hip moved aside, so the embedded table has no object; 0 entries against 1 in the shipped table), one TOP_K node, no device, target gfx1151: shape eager_declared registry | before after no-object build yes no no | CLAIM decline shipped build yes yes yes | CLAIM CLAIM eager_capability_declared is the flag hip_declare_eager_op sets, i.e. exactly the call the registration path skips when the object is missing, so it is the half of the question the early return was missing. The alternative -- deleting the early return and letting the generic tail decide -- was rejected: that tail ends in can_execute_standalone_op_as_graph, a one-node graph build plus a registry match per node, which the MoE router pays once per layer. GGML_HRX_HIP_TENSOR_CLAIM=0 builds are unaffected (hip_eager_op_declared is not under that macro) and GGML_HRX_DISABLE_DISPATCH=hip.top_k_f32 was already handled by the predicate's own dispatch_name_disabled check. No unit arm: the line is inside a static function, and an arm on the conjunction would be tautological. The two-build probe is the instrument that distinguishes them and it is in the PR text with the recipe. Refs engine#2704 --------- Co-authored-by: bong-water-water-bong <[email protected]>
What
One clause in
device_supports_op: do not claim aGET_ROWSwhose source is not contiguous.Fixes ggml-org#2639, where Qwen3.8-Flash-Next fails its first graph with the node placed on HRX and no dispatch at compute time:
Why it happens: the claim is about the op, the match is about the tensors
GET_ROWSmatcher indispatch-get-rows.cppgates on->contiguous— source, ids and output, seven sites (90, 216, 265, 318, 367, 383, 524);which is a property of the op code and says nothing about the tensors.
So a
GET_ROWSfrom a stridedVIEWof an f16 embedding is claimed here, rejected by every matcher, and the scheduler has already committed the node. It also explains why three otherGET_ROWSin the same graph stayed on the CPU: they were declined for a different reason, not because this predicate noticed their layout.The clause
Narrow on purpose. A contiguous
GET_ROWSkeeps its device placement — including the token-embedding rows the placement census counts as off-HRX by design — so this refuses only what no matcher can take. That is the rule already written above it forTOP_K(engine ggml-org#679: "claim only the shapes it executes, so anything else keeps its CPU fallback instead of becoming an unsupported HRX node").Verification, and what is missing
g++ -fsyntax-onlyonggml-hrx.cppwith the pinned HRX include path: zero errors.No arm:
device_supports_opneeds a device and a decoded graph, and this lane has no device. The evidence is the repro in ggml-org#2639; the honest statement of risk is that the change makes placement more conservative for a shape the dispatcher provably cannot run, so the failure it could introduce is a node staying on the CPU rather than a node failing on the device. The existingtest-backend-ops GET_ROWScase (cited by the IQ3_S decline above it) is the suite that would catch an over-narrow clause.Not doing here
Consulting the registered dispatch match inside
device_supports_op, which would stop this decline list growing — this is its fourth entry, and each one encodes a property of a matcher in another file. That is the durable fix, but it is a different change and this one unblocks the model now.