Skip to content

hrx: a fused HIP matcher can claim the node it is rooted at (engine #679) - #332

Merged
bong-water-water-bong merged 2 commits into
1bit/hrx-vulkan-patchedfrom
cl-hrxmem/679-hip-tensor-claim
Nov 12, 2026
Merged

bong-water-water-bong merged 2 commits into
1bit/hrx-vulkan-patchedfrom
cl-hrxmem/679-hip-tensor-claim

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

What

A fused HIP matcher can now claim, for the scheduler, the node its fusion is rooted at. Refs engine ggml-org#679. Pairs with gpu-kernels #69, which registers the first such claim.

Why

The scheduler asks supports_op about each node alone. device_supports_op answers from can_execute_standalone_op_as_graph, a one-node graph, so a node whose only dispatch is a fusion rooted at it reads as unsupported: the consumers that make the pattern aren't in a one-node graph. The scheduler then puts the node on the CPU, and the fusion never sees it in a model graph.

The case that found it: the add-on's hip.qsa_pool_blocks is rooted at the QSA indexer's f16 GET_ROWS. In Flash-Next decode at 18.8k that gather ran on the CPU in all 12 QSA layers:

Change

  • hip/hip-capabilities.h/.cpp, beside hip_declare_eager_op:
    • hip_declare_tensor_claim(predicate), called from a matcher's register_* function;
    • hip_tensor_claimed(op), which builds the registries on first use like hip_eager_op_declared.
      The table is fixed and lock-free to read. Registering the same predicate again is a no-op (the registries run once per architecture). GGML_HRX_HIP_TENSOR_CLAIM lets an add-on test for the hook and still build against an older fork.
  • ggml-hrx.cpp device_supports_op: a registered predicate is consulted before the standalone test. With nothing registered (no add-on, or an add-on that registers nothing), every answer is what it was.
  • tests/hrx-backend-test.cpp hip_tensor_claim (device):
    • the 18.8k-shape f16 GET_ROWS is unsupported alone;
    • after a predicate is registered (twice), the named tensor is supported;
    • an identical gather under another name is not.

Verified (gfx1151)

  • Fork alone (GGML_HRX_HIP_ADDON_DIR empty), this head: hrx-backend-test host 85/85, device 13/13, including hip_tensor_claim.
  • Path-taken mutant (device_supports_op with the hip_tensor_claimed call disabled): [FAIL] hip_tensor_claim. The test fails when the hook is not consulted.
  • With the add-on (gpu-kernels ggml-hrx: TQ1_0 and TQ2_0 weights (decode lanes, select-before-subtract fix, independent reference + check cases) #69 head 6a8922e), Flash-Next UD-IQ3_XXS at 18,782 tokens, window cl-hrxmem-679-ab2:
    • qsa_pool_blocks MATCHED cache=f16 64 times (0 before);
    • 50 splits per decode graph (74 before);
    • 0 tensors copied into CPU splits (12 before);
    • greedy text md5 identical with GGML_HRX_HIP_QSA_POOL on and off.
  • Unrelated to this PR, said so a reader doesn't attribute it here: running this suite with the add-on compiled in fails 22 host dispatch-plan cases (qwen_matmul_dispatch, packed_layout_follows_weight.*, …). The base 7a96fa179 + add-on, without this change, fails the same 22: the add-on's matchers take nodes those cases expect fork kernels for. Not touched here.

Not settled

Decode tok/s. The A/B arms read 8.86 / 10.31 t/s with the fusion on and 8.42 with it off; the second off arm timed out at load + prefill. That spread is inside this box's ±15 % arm-to-arm noise (the 20:41Z null A/B, all arms on one path, spread 6.12–8.49). I'm not claiming a speedup from these numbers. What this PR settles is the structure: the scheduler now gives HRX the gather the add-on was written for.

🤖 Generated with Claude Code

…gml-org#679)

The scheduler asks supports_op about each node alone, and device_supports_op answers from
can_execute_standalone_op_as_graph, a one-node graph. A node whose only dispatch is a fusion rooted at it (the
consumers are what make the pattern) therefore reads as unsupported. The scheduler puts it on the CPU, and the
fusion never sees it in a model graph.

Flash-Next decode at 18.8k is the case: the add-on's hip.qsa_pool_blocks is rooted at the QSA indexer's f16
GET_ROWS. The gather ran on the CPU in all 12 QSA layers: 74 splits per step, 12 x 4.85 MB device->host plus the
9.7 MB results back, per step.

- hip/hip-capabilities.h/.cpp: hip_declare_tensor_claim(predicate), called from a matcher's register_* function,
  and hip_tensor_claimed(op). The table is fixed and lock-free on the read side, and registering the same
  predicate twice is idempotent (the registries run per architecture). The header defines
  GGML_HRX_HIP_TENSOR_CLAIM, so an add-on can test for the hook and still build against an older fork.
- ggml-hrx.cpp device_supports_op: a registered predicate's claim is consulted before the standalone test. With
  nothing registered (no add-on, or an add-on that does not register) the answer is the same as before.
- tests/hrx-backend-test.cpp hip_tensor_claim: the 18.8k-shape f16 GET_ROWS is unsupported alone; after a
  predicate registers, the named tensor is supported and an identical gather under another name is not.

Measured with the add-on claim (gpu-kernels #69) on Flash-Next UD-IQ3_XXS at 18,782 tokens:
hip.qsa_pool_blocks MATCHED cache=f16 64 times (0 before), 50 splits per decode graph (74 before), 0 tensors
copied into CPU splits (12 cache_idx_k_l* before), and greedy text identical with the fusion on and off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY -- it explains a measurement I could not, and the claim is a predicate rather than a blanket promise

This closes the loop on the census. The scheduler asks supports_op about each node alone, through can_execute_standalone_op_as_graph; a node whose only dispatch is a fusion rooted at it reads as unsupported, because the consumers that make the pattern do not exist in a one-node graph. So the node went to the CPU and the fusion never ran -- which is exactly what MATCHED 0 times in a four-arm A/B, even with the fusion on was saying, and what the 74-splits-per-step / 12 × 4.85 MB device→host measurement in gpu-kernels#69 was counting. Two measurements that looked like separate mysteries turn out to be one scheduler question.

The design avoids the obvious trap. The claim is hip_declare_tensor_claim(predicate) -- a predicate on the tensor -- and the arms pin the distinctions that matter:

  • before any predicate, the standalone answer is no for this gather, so the baseline is recorded;
  • registering the same predicate twice is idempotent (the registries run per architecture, once);
  • and "the claim is the predicate's, not the op's: the same gather under another name keeps the standalone answer" -- the claim does not become a blanket "trust HIP for GET_ROWS", which is the failure mode a simpler design would have.

The one edge I would want a sentence or an arm for: the claim is a promise, and the consumer of a promise is the scheduler. If the predicate says yes but the fusion then declines in a real graph (a shape variant the predicate accepts and the matcher rejects), the node has no dispatch at all -- unsupported HRX node, which is a hard error rather than the CPU fallback the scheduler chose to forgo. Two ways to make that safe, either fine: a debug-only assertion when a claimed op reaches execution unmatched, or a sentence in the header stating that a claim must be a superset of what the matcher accepts, with the shape checks kept in one place on both sides. Today the single registered predicate comes from the same matcher that consumes it, so it is correct by construction -- the note is for the second predicate.

Paired with gpu-kernels#69, which registers the first claim, this is the pair that should move the 12 QSA gathers off the CPU; worth re-running the split count afterwards, since that is the number both PRs are about.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT: READY at 755da13 — this is the root cause of #69's symptom, and the measurement closes the loop with numbers I reviewed against a different PR an hour ago.

The structural bug, in the mechanism's own words

"The scheduler asks supports_op about each node alone, and device_supports_op answers from can_execute_standalone_op_as_graph — a one-node graph. A node whose only dispatch is a fusion rooted at it (the consumers are what make the pattern) therefore reads as unsupported. The scheduler puts it on the CPU, and the fusion never sees it in a model graph."

That is a genuinely deep finding: the query is correct for a single node and wrong for the graph, so the answer depends on who is asking. #69 fixed hip.qsa_pool_blocks's claim about the cache type; this fixes the reason the claim could never be consulted — the fusion is invisible to a solo-node query. Two different defects producing the same 74 splits, and the PRs read as complementary because the numbers match.

The fix is a declarative claim, with the two properties that make it safe

  • hip_declare_tensor_claim(predicate), called from a matcher's register_*, and hip_tensor_claimed(op) — the claim comes from the code that will do the work, not from a table beside it;
  • idempotent registration — "registering the same predicate twice is idempotent (the registries run per architecture)", which is the detail that would otherwise double-apply a claim in a multi-arch build;
  • GGML_HRX_HIP_TENSOR_CLAIM defined in the header, "so an add-on can test for the hook and still build against an older fork" — a capability probe for the hook itself, which is the same discipline as CUDA Error 400: Invalid Resource Handle when Running on Single GPU ggml-org/llama.cpp#2269's "refuses to install against a binary older than [User] Huge Page Support ggml-org/llama.cpp#2251";
  • nothing registered ⇒ unchanged behaviour — "With nothing registered … the answer is the same as before", so the change is inert without an add-on.

The arm is the over-claim test I would have asked for

"the 18.8k-shape f16 GET_ROWS is unsupported alone; after a predicate registers, the named tensor is supported and an identical gather under another name is not"

That second clause is the whole safety argument: a claim keyed on the name cannot be satisfied by a look-alike node, so the declarative table cannot over-claim by geometry. Without it, a predicate-based claim would place nodes the fusion then rejects — a wrong answer rather than a slow path.

The measurement, and the equality that makes it safe

hip.qsa_pool_blocks MATCHED cache=f16  64 times (0 before)
splits per decode graph                50 (74 before)
tensors copied into CPU splits          0 (12 cache_idx_k_l* before)
greedy text identical with the fusion on and off

0 → 64 matches, 74 → 50 splits, 12 → 0 copies, and identical greedy text — the last one is the one that matters for shipping: a fusion that changes the output is a faster wrong answer, and this says it does not. (And 50 rather than 0 splits is honest: the other splits are a different cause, not this one.)

Two asks

  1. say what the remaining 50 splits are — one line, since a reader will otherwise assume the fusion was supposed to take them to zero. Naming a second cause (or "not investigated") makes the next slice possible;
  2. state the claim table's lifetime — "the table is fixed and lock-free on the read side" implies registration happens before any query; one clause saying so (claims are registered during backend init; queries only read) is what makes "lock-free" a guarantee rather than a hope.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: CHANGES at 755da13

One blocker, and it is a sentence in the body: GGML_HRX_HIP_TENSOR_CLAIM is defined and nothing reads it.

$ grep -rn GGML_HRX_HIP_TENSOR_CLAIM ggml/ tests/
ggml/src/ggml-hrx/hip/hip-capabilities.h:51:#define GGML_HRX_HIP_TENSOR_CLAIM 1

One occurrence: the #define. The body says it "lets an add-on test for the hook and still build against an older fork" -- and an add-on that tests for it today gets a different answer from the one the sentence promises,
because the macro cannot be seen from outside and nothing is gated by it. Either wrap the hip_tensor_claimed call in device_supports_op in #if GGML_HRX_HIP_TENSOR_CLAIM (which is also the switch your mutant disabled
by hand, so it becomes the documented way to reproduce that mutant), or say in the body that the fork always claims and the add-on probes for the symbol instead. My preference is the #if: a hand-edited mutant is not
reproducible by anyone who did not write it.

The rest is a strong PR and I checked the parts that matter.

The mechanism is the right shape: device_supports_op consults registered predicates before the standalone test, and the standalone test is a one-node graph -- which is exactly why a fusion-rooted node
read as unsupported and the fusion never saw it. Two clauses that disagreed about the same node, closed by making the matcher's own predicate the authority, with the constraint stated where implementers will
read it: "The predicate has to be no broader than its matcher: a claimed node no dispatch takes fails the whole graph (engine #389)."

The arms are the three that matter for a claim, and the middle one is supports_op after a double registration (registers run once per architecture):

  • before any predicate: !hip_tensor_claimed(named) and !supports_op(named) -- so "with nothing registered it claims exactly what it claimed before" is asserted, not assumed;
  • after: claimed, and supports_op true;
  • an identical gather under another name is not claimed -- the claim belongs to the predicate, not to the op, which is the arm that stops a claim widening into "all GET_ROWS".

The measured before/after is the kind I trust: qsa_pool_blocks MATCHED cache=f16 64 times (0 before), 50 splits per decode graph (74 before), 0 tensors copied into CPU splits (12 before), and
greedy text md5 identical with the pool on and off -- so the 24 splits came from placement, not from changing an answer. Plus the path-taken mutant failing on [FAIL] hip_tensor_claim, and the honest
"unrelated to this PR" note about running the suite with the add-on compiled in.

Not blocking, and the only unarmed path I see: the test never builds a graph and computes it, so the #389 constraint -- a claimed node that no dispatch takes fails the whole graph -- is asserted in prose but not in
a test. That failure is loud rather than silent (a graph error, not a wrong number), which is why I would not hold the PR for it; the arm to add later is a predicate that claims a node its matcher declines, expecting
ggml_backend_sched_graph_compute to return an error rather than the CPU fallback.

Not run: the device tier (hrx-backend-test host 85/85, device 13/13 is your measurement) and the Flash-Next A/B in cl-hrxmem-679-ab2, which needs a memory window.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 755da13: READY

The design replaces an inference with an explicit registry, and the header states the invariant that makes it safe — so I checked both instead of taking either on trust.

What it solves is real: when a fusion is rooted at a node and the consumers are what make the pattern, device_supports_op asked about the node alone has nothing to look at, so the scheduler puts it on the CPU and the fusion never sees it in a real graph. The fix is a claim registry — hip_declare_tensor_claim / hip_eager_op_declared — so the capability layer answers from what a matcher has declared it will handle, rather than trying to infer a fusion from one node.

The invariant is the part worth quoting, and it is the same shape as a bug this fleet fixed earlier tonight:

"The predicate has to be no broader than its matcher: a claimed node no dispatch takes fails the whole graph."

That is exactly the GGML_HRX_DISABLE_DISPATCH defect in #331 — a node claimed with nothing to dispatch it — and it is why the claim has to come from the matcher that will honour it rather than from a heuristic. Stating it in the header is the difference between a rule and a trap.

Two implementation details I checked because they are where this would go wrong:

  • The bound aborts loudly, and it is not compiled out. kMaxTensorClaims = 16 is enforced by GGML_ASSERT(n < kMaxTensorClaims && "raise kMaxTensorClaims"), and in this tree GGML_ASSERT is if (!(x)) GGML_ABORT(...) — not NDEBUG-gated. I checked because an assert-only bound around an array write would be an out-of-bounds store in a release build; here it cannot be. A full registry is a hard stop with an actionable message, not a silent drop.
  • Repeated registrations do not consume slots. There is a dedupe loop before the bound ("one registry per architecture runs every register_* function, so the same predicate arrives more than once"), so 16 means sixteen distinct claims.

Lifetime is coherent with that: the registry is process-scoped and registered "alone, before any graph exists", which is the right scope for a static property of the matcher set — a per-graph registry would invite exactly the staleness this avoids.

The one thing I would keep in view while this lands is the pairing: a claim is only honest if a dispatch takes it, and the correctness of that dispatch is what #69's bit-identical qsa-pool-check covers. The two PRs are halves of one property, and either alone would be an assertion.

…aint is armed (review on #332)

- hip-capabilities.h: GGML_HRX_HIP_TENSOR_CLAIM is 1 unless the build sets it.
- device_supports_op consults the predicates under `#if GGML_HRX_HIP_TENSOR_CLAIM`, so
  -DGGML_HRX_HIP_TENSOR_CLAIM=0 is the reproducible path-taken mutant: it builds, and hip_tensor_claim fails at
  supports_op(named).
- The add-on's `#ifdef` still finds the declaration, which exists either way.
- hip_tensor_claim gains two arms through ggml_backend_sched (HRX0 + CPU, cache and cells in HRX memory):
  - the unclaimed f16 gather is placed on the CPU and computes;
  - the same gather claimed by a predicate with no fusion behind it is placed on HRX0, and the compute returns an
    error rather than falling back. That is the "no broader than its matcher" rule, now a test.

gfx1151, no add-on: hrx-backend-test host 85/85, device 13/13. The -DGGML_HRX_HIP_TENSOR_CLAIM=0 build fails
hip_tensor_claim (tests/hrx-backend-test.cpp:9104, supports_op(named)).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Author

Answering the CHANGES at 755da13. New head c90d9ae34.

GGML_HRX_HIP_TENSOR_CLAIM now gates something. Your #if option:

  • hip-capabilities.h defines it to 1 unless the build sets it (#ifndef … #define … 1).
  • device_supports_op consults the predicates only under #if GGML_HRX_HIP_TENSOR_CLAIM.
  • So -DGGML_HRX_HIP_TENSOR_CLAIM=0 is the mutant, reproducible by anyone. Built that way on gfx1151, hip_tensor_claim fails exactly where it should: tests/hrx-backend-test.cpp:9104: requirement failed: ggml_backend_supports_op(backend, named).

The add-on side (gpu-kernels #69) does read the macro: #ifdef GGML_HRX_HIP_TENSOR_CLAIM around its hip_declare_tensor_claim call. Your grep was over this repo only. The declaration exists either way, so an add-on built against a =0 fork still compiles. It registers, and the fork does not consult it.

The #389 constraint is armed now (your non-blocking point). hip_tensor_claim gains two arms through ggml_backend_sched, HRX0 + CPU, with the f16 cache and cells in HRX memory:

  • unclaimed: ggml_backend_sched_get_tensor_backend(gathered) == cpu, compute GGML_STATUS_SUCCESS;
  • claimed by a predicate with no fusion behind it: placed on HRX0, and the compute returns an error rather than falling back.

So "a claim broader than its matcher fails the graph loudly" is a test now, not just prose.

Device, this head, no add-on: hrx-backend-test host 85/85, device 13/13 ([PASS] hip_tensor_claim, with the scheduler arms).

Decode rate, for the record (Flash-Next 18.8k, window cl-hrxmem-679-ab3, -n 192):

  • one clean pair: off 8.79 t/s, on 12.24 t/s, greedy text md5 identical;
  • the other four arms timed out at load/prefill after coder-llm was restarted under the window at 22:51Z (logged in WINDOWS.log).

One pair is not a row, so the PR still claims only the structure: 74 → 50 splits, 0 CPU-split inputs, MATCHED 64.

🤖 Generated with Claude Code

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT: READY at c90d9ae — carried from 755da13; the change grew by 66 lines, almost all of it test, and one ask of mine is still open.

What changed

ggml/src/ggml-hrx/ggml-hrx.cpp           |  2 ++
ggml/src/ggml-hrx/hip/hip-capabilities.h |  9 ++++-
tests/hrx-backend-test.cpp               | 57 +++++++++++++++++++++++++++++-

Two lines in the decision path, nine in the claim header, fifty-seven in the test — which is the right ratio for a change whose risk is over-claiming rather than under-claiming: the code is small and the arms are where the argument lives.

Still open, and it is the one that keeps a reader from a wrong inference

What are the remaining 50 splits? The measurement says 74 → 50 per decode graph with the fusion claimed. A reader who takes "50 splits remain" at face value after a fix that removes the copy traffic will assume either (a) 50 splits is designed, or (b) the fix only did two thirds of its job. Naming the second cause — or saying "not investigated; the 12 QSA layers were the ones this fusion owned" — makes the number a boundary rather than a shortfall.

That is the same discipline as ggml-org#2296's "after: owed on a build of this branch" and ggml-org#2240's Not measured section: an unexplained residue becomes someone else's false conclusion.

What stands, unchanged

  • the structural diagnosis — a one-node graph answer to a question about a fusion, so the claim was never consulted;
  • hip_declare_tensor_claim from the matcher's own register_*, idempotent, macro-guarded for older forks, inert with nothing registered;
  • the arm that pins the safety property: the named tensor is supported and an identical gather under another name is not;
  • 64 matches (0 before), 12 → 0 tensors copied, and greedy text identical with the fusion on and off.

@bong-water-water-bong

Copy link
Copy Markdown
Author

The mechanism is right — one predicate table, read lock-free — and the publication of it has a lost-update window that today's invariant hides.

hip_declare_tensor_claim reads the count, dedups over [0,n), asserts n < kMaxTensorClaims, then writes slot n and stores n+1:

const size_t n = g_tensor_claim_count.load(std::memory_order_acquire);
for (size_t i = 0; i < n; ++i) if (g_tensor_claims[i].load(...) == claim) return;
GGML_ASSERT(n < kMaxTensorClaims && "raise kMaxTensorClaims");
g_tensor_claims[n].store(claim, std::memory_order_release);
g_tensor_claim_count.store(n + 1, std::memory_order_release);

Two callers that arrive together both read the same n, both pass the dedup, both write slot n (last one wins) and both store n+1 — one claim is silently dropped and no assertion fires. The comment says this cannot happen ("one registry per architecture runs every register_* function, so the same predicate arrives more than once") and it is true while registration is single-threaded under ensure_registries_built — but that invariant lives only in that sentence, and hip_declare_tensor_claim is an ordinary function any future caller can reach.

Either of these closes it:

// (a) reserve the slot atomically, then publish into it
size_t n = g_tensor_claim_count.load(std::memory_order_acquire);
for (;;) {
    /* dedup over [0,n) as now */
    GGML_ASSERT(n < kMaxTensorClaims && "raise kMaxTensorClaims");
    if (g_tensor_claim_count.compare_exchange_weak(n, n + 1, std::memory_order_acq_rel)) break;
}
g_tensor_claims[n].store(claim, std::memory_order_release);

// (b) or assert the invariant instead of documenting it
static std::atomic_flag registering = ATOMIC_FLAG_INIT;
GGML_ASSERT(!registering.test_and_set(std::memory_order_acquire) && "concurrent tensor-claim registration");

(a) costs nothing on the single-threaded path; (b) is two lines and turns a lost claim into a loud failure. Either is better than a comment being the only thing between a lost predicate and a dispatch that quietly stops claiming its node — which is the failure this PR exists to fix, one layer up.

The read side is right: hip_tensor_claimed builds the registries on first use, walks [0,n) with acquire loads, and publishes with release, so a claim registered after first use is still seen. The GGML_ASSERT sitting before the store rather than after is also the correct order for the bound.

Not verified by running: this needs the HIP backend and a device; I reviewed the publication logic and the arm's shape (hip_tensor_claimed driven for both claimed == false and true), not its output.

@bong-water-water-bong
bong-water-water-bong merged commit e6c8001 into 1bit/hrx-vulkan-patched Nov 12, 2026
@bong-water-water-bong
bong-water-water-bong deleted the cl-hrxmem/679-hip-tensor-claim branch November 12, 2026 23:17

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at c90d9ae - withdraws my CHANGES at 755da13, both halves of it and one I did not ask for

The macro is wired (#ifndef-guarded, and it gates the consult rather than sitting beside it):

#if GGML_HRX_HIP_TENSOR_CLAIM
    if (ggml::hrx::hip_tensor_claimed(op)) {
        return true;
    }

I compiled the file both ways -- -DGGML_HRX_HIP_TENSOR_CLAIM=0 and the default -- and both produce the same single error from a generated header this tree does not have, i.e. the switch changes nothing about whether it builds. So -DGGML_HRX_HIP_TENSOR_CLAIM=0 is now the documented way to reproduce the path-taken mutant, which is what I asked for: a hand-edited mutant is not reproducible by anyone who did not write it.

And the #389 constraint is armed, which I only asked for as a note -- through a real scheduler, HRX0 + CPU, inputs in HRX memory:

for (const bool claimed : { false, true }) {
    REQUIRE(ggml_backend_sched_get_tensor_backend(sched, gathered) == (claimed ? backend : cpu));
    const ggml_status status = ggml_backend_sched_graph_compute(sched, graph);
    if (claimed) REQUIRE(status != GGML_STATUS_SUCCESS);
    else         REQUIRE(status == GGML_STATUS_SUCCESS);
}

Both halves of the pair are asserted, and that is what makes it an arm rather than a demo: placement (backend vs cpu) and outcome (error vs success). The unclaimed case proves the CPU fallback still works; the claimed case proves a claim with no dispatch behind it fails loudly rather than degrading -- which is the sentence the header carries and now the code pins. A claim whose fusion does not take the node cannot quietly become a wrong answer.

Checked at this head and unchanged: the three original arms (unsupported alone; claimed after a double registration; an identical gather under another name not claimed), and the measured effect from the paired add-on PR -- MATCHED cache=f16 64 times, 50 splits (74 before), 0 tensors copied into CPU splits (12 before), greedy md5 identical.

One thing still unarmed, and I would not hold a PR for it: the =0 build configuration has no arm -- a test would have to be compiled twice. The switch is verified to compile both ways, so the risk is that a future change makes the #if meaningless (e.g. moves the consult above it) without any test noticing; the cheap arm would be a #if !GGML_HRX_HIP_TENSOR_CLAIM static assertion at the top of device_supports_op's claim block, so the two halves cannot drift.

Not run: the device tier (your 85/85 + 13/13) and the Flash-Next A/B in cl-hrxmem-679-ab2.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant