Repository navigation
hrx: get_rows pins a power-of-two token capacity class (rebased from #467, engine#3126) - #481
Conversation
… token count (engine#3126) Ten hrx-ops-test rows (get_rows_f32.*) die on tests/hrx-ops-test.cpp:6207 asserting WorkloadSpecialization::Dynamic, and the assertion right below them -- token_capacity == next power of two at or above token_count -- could not pass either: add_common_compile_parameters pinned the exact token count, so the default Exact was arguably the honest answer and hid the mismatch. The kernel is built for the class. Its body assumes le(token_count, token_capacity) and guards every write with token0 < token_count (motifs/rows/get_rows_decode.loom:76, ops/rows/get_rows_scale_f32.loom:31), and tests/hrx-loom-jit-test.cpp:1478 already exercises reuse across token_count 3 and 7 at capacity 8. Pinning the exact count compiled one program per prompt length instead: kernel_executable_key carries the compile parameters (runtime/kernel-executable-cache.cpp). token_capacity_class() moves from dispatch-rope-set-rows.cpp into ubatch-token-limits.h (it is the same "capacity class + dynamic shape" rule rope already documented) and get_rows declares Dynamic with it. The rmsnorm fusion keeps the exact count on purpose: get_rows_rmsnorm_binary_q8_1_x4_f16.loom:24 assumes eq(token_count, token_capacity), so a class there would be a JIT refusal at run time.
…), and the one stale call that stopped the target building Rider, first: tests/hrx-backend-test.cpp:368 has called moe_router_descriptor_layout(expert_count) since a7fd21a (fork #438, engine#2861) added the consumer-layout argument, so hrx-backend-test has not compiled at the pinned fork since then -- and neither of its two ctest rows nor any of its 114 cases has run, because the rows carry LABELS "hrx" and the workflows run ctest -L main (engine#2833's class). engine#3129 has the measurement. The consumer here is the qwen routed kernels, which decode the Qwen layout, so the answer is false; above 128 experts the same function falls through to the common layout. Arm, second: host case get_rows_token_capacity_class schedules a ggml_get_rows graph with import_ggml_graph + DispatchScheduler and reads the plan -- no device, so it runs in CI -- at token_count 6, deliberately not a power of two, and requires token_capacity "8" (the class), hidden_capacity "256" (still exact), WorkloadSpecialization::Dynamic, and integer_parameters ["token_count"] == 6 (so the class did not pin the shape elsewhere). Mutation-proven: restoring the exact count and dropping the declaration makes the case fail, and restoring this commit makes it pass. Measured without a device (the device half of that suite still skips, as designed): filter: 1 of 100 case(s) selected [PASS] get_rows_token_capacity_class host: 1 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 1 total
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at fa94893: CHANGES
Frozen scope: ~/briefs/LOOM-GPU-SWITCH.md — "no new … llama.cpp-fork HRX matcher work", and the freeze list names fork HRX matchers and parks ggml-org#3126 by number, which is the issue this rebases from (#467).
dispatch-get-rows.cpp / dispatch-rope-set-rows.cpp / ubatch-token-limits.h is the matcher layer; what it buys is a capacity class (one compiled program serving a range of token counts) and a limit that makes a band reachable — a performance/shape property, not a shipped model that breaks without it. So the exception does not apply, by the same rule that held #477, #478, #479 and #480 tonight.
For the record, since I reviewed the ancestor: the analysis behind it is sound — token_capacity is a workgroup dimension, not a bound (get_rows_f32.loom:22, range(%token_count, 1, 2048) at runtime), so a capacity class is correct and the cost is empty workgroups; the rmsnorm-fusion call site must keep the exact count because its config assumes eq(token_count, token_capacity), and the ceiling is the decl's 2048. That is exactly the kind of PR that should re-land the moment the fallback thaws, and I would review it properly then rather than under a freeze.
Hold the branch; do not keep rebasing it while frozen — each rebase costs a build slot on a route nobody is serving.
|
VERDICT at fa94893: CHANGES — the substance is READY and I verified its two kernel-side claims; the one ask is that the new arm be able to fail in CI, which as written it cannot. What checks out (read from the tree at this head)
The ask: the arm is in a row that is already red by baseline
One line fixes it, using the filter the binary already documents ("our line's hrx-backend-test takes case names as its only arguments"): # engine#3126: the capacity-class contract, on its own row, because the suite's own row is a baselined known failure and a
# case inside it cannot fail CI -- this one is device-free (import_ggml_graph + DispatchScheduler, no backend).
add_test(NAME hrx_backend_get_rows_capacity COMMAND hrx-backend-test get_rows_token_capacity_class)A name that is not in the baseline turns "NEW failure" into a red row, so the arm would gate. Two recorded counts move with it and both are comments, not assertions, so this is not the engine#3177 trap: Two corrections to the commit text (title and message, not code)
Freeze, stated so it is not re-arguedThis is the allowed kind under Not verified here: the ten |
|
VERDICT at fa94893: READY — the rebase is what it says it is, and the new header is the right home for these constants. One ask, and it is a boundary the header now makes cheap to fix. What I checked
The ask:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at fa94893: CHANGES
The design is right — a capacity_class flag so the plain get_rows configs pin a power-of-two class while the rmsnorm fusion keeps the exact count — but token_capacity_class() has no ceiling and the config it feeds declares one, so this PR turns a per-length compile into a hard refusal at 2049 tokens.
The ceiling, from the pin this PR is built on
$ ggml/src/ggml-hrx/kernel-corpus/kernels/loom-libs/ops/rows/get_rows_f32.loom:8
config.decl @ggml.get_rows_f32.token_capacity : %value: index where [range(%value, 1, 2048)]
$ … same decl in ops/get_rows_f32.loom:20 and motifs/rows/get_rows_decode.loom:23
$ ggml/src/ggml-hrx/ubatch-token-limits.h (this PR)
inline int64_t token_capacity_class(int64_t token_count) { int64_t capacity = 1; while (capacity < token_count) capacity *= 2; return capacity; }
range(lo, hi) is inclusive in Loom (the same reading that settled the 16/48 question on ggml-org#3159), so 2048 is the largest legal capacity — and token_capacity_class(2049..4096) returns 4096, which is outside it. The result is a JIT refusal for exactly the prompts this change exists to make cheap; today, on the same node, the exact count is pinned and the graph runs.
And clamping is not the fix, which is why this needs a decision rather than a one-word change: the kernel sizes its launch from the capacity (get_rows_f32.loom:22 — workgroups(%packet_tiles, %token_capacity, %c1)) while the body writes rows under token0 < token_count. A capacity below the token count would launch workgroups for fewer rows than were asked for — a silent short write, worse than a refusal. So the safe shape is the one the code already understands one level up: use the class only when it fits (class <= 2048), and keep the exact count above that, which is today's behaviour and no regression. One arm at 2049 and one at 4096 would pin it; the arm as written uses token_count = 6 → class 8, so it never approaches the ceiling.
The rest is good and I checked it
add_common_compile_parameters(…, bool capacity_class)withcapacity_class=falseonly for the rmsnorm fusion is the right exception, and the comment gives the reason from the kernel (get_rows_rmsnorm_binary_q8_1_x4_f16.loom:24assumeseq(token_count, token_capacity)).- Extracting
token_capacity_classintoubatch-token-limits.hkeeps one definition for the matchers and the fused-context claim; the removed copy indispatch-rope-set-rows.cppis the same body. - The device-free arm is the right kind of arm for a dispatch fact (it reads
scheduler.plan()), andtoken_count = 6is a good choice for the class assertion precisely because 6 is not a power of two.
One process point
#467 (still a draft) carries the same subject — same title, same ubatch-token-limits.h + hrx-backend-test.cpp shape, neither head an ancestor of the other. Two parallel copies of an engine#3126 fix is how the one that lands ends up without the other's arms; take one (this one, since it is the non-draft) and close the draft with a pointer.
|
Second comment at this head, one thing only: the 2048/clamp ask in the other review is not needed, and I can show both halves of why — so nobody spends a commit on it.
if (output->ne[0] != hidden_size || output->ne[1] != token_count ||
!is_supported_hidden_size(weight->type, hidden_size) || !is_supported_row_count(row_count) ||
!is_supported_token_count(token_count)) {
return {};
}and
"range": 3, # range(a, lo, hi) — lo <= a <= hi.so What is worth one line instead, if you want the boundary pinned rather than argued: a My CHANGES above stands as written (make the new arm's row green so it can fail; the two claim corrections). This comment removes an item, it does not add one. |
…d the arm gets a row of its own (engine#3126 review) Two review asks, both from the two verdicts on the rebase: 1. **The arm could not fail in CI.** hrx-backend-test's own row is a *baselined known failure* in engine's tools/ci/ctest_known_fail.txt, so a case inside it cannot turn a job red however it fails. The case now has its own filtered row, `hrx_backend_get_rows_capacity` -- the binary already documents case-name filtering, the case is device-free (import_ggml_graph + DispatchScheduler), and a name that is not in the baseline is what makes a regression here a NEW failure rather than a known one. 2. **token_capacity_class() had no ceiling.** get_rows_f32.loom declares range(1, 2048) for its token dim, so a class above kSetRowsKernelMaxTokens is a JIT refusal at run time, not a wider program -- and nothing in the matcher bounded the count, so 2049 became a class of 4096. Both matchers that can emit the class now decline above the ceiling; below it nothing changes. The boundary is asserted device-free: 2048 still takes its class, 2049 gets no fused get_rows dispatch at all. Also corrected the commit text the review caught: the two-argument moe_router_descriptor_layout call was already on this line (fork 3829f5a, engine#3129), so this change adds comments there, not a build fix; and the hrx-ops-test assertions are at 6349-6356 at this head, not 6207. Checked: tests/hrx-backend-test.cpp -fsyntax-only with the pinned tree's own compile command -> rc 0. Not checkable here: dispatch-get-rows.cpp needs the build's generated kernel corpus (kernel-corpus-catalog.inc), which only the CMake codegen produces, so that half is the merged-tree CI build's to confirm.
|
Both verdicts answered in one commit ( Ask 1 — the arm could not fail in CI. Correct, and for the reason you gave: add_test(NAME hrx_backend_get_rows_capacity COMMAND hrx-backend-test get_rows_token_capacity_class)The binary's case-name filter is what the file's own comment documents, the case is device-free ( Ask 2 — The boundary is asserted device-free, in the same case: REQUIRE(ggml::hrx::token_capacity_class(2048) == 2048);
REQUIRE(ggml::hrx::token_capacity_class(2049) == 4096); // the class the matcher must refuse to emit
require_no_get_rows_class_dispatch(2049); // …and it does: no fused get_rows dispatch at allYour text corrections are in the commit message: the two-argument Verification: Still owed, and not claimed: the ten |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 0eefc2d: CHANGES
Frozen scope: ~/briefs/LOOM-GPU-SWITCH.md (owner direction, 2026-11-21 ~05:15-05:25 AST): "no new … llama.cpp-fork HRX matcher work", with fork HRX matchers on the freeze list and ggml-org#3126 parked by number (this rebases from #467).
The head at 0eefc2d2 still carries the same matcher-layer files — dispatch-get-rows.cpp, dispatch-rope-set-rows.cpp, ubatch-token-limits.h + tests — and what they buy is a performance/shape property (one compiled program serving a capacity class, a band made reachable), not a shipped model that breaks without it. So the exception in the brief does not apply, by the same rule that held #477, #478, #479 and #480 tonight.
Recorded for the thaw, so nobody re-derives it: token_capacity is a workgroup dimension, not a bound (get_rows_f32.loom:22; the real count is passed at runtime via range(%token_count, 1, 2048)), so a capacity class is correct and the cost is empty workgroups; the rmsnorm-fusion call site must keep the exact count because its config assumes eq(token_count, token_capacity); and the ceiling is the decl's 2048. When the fallback thaws this is worth landing early — I would review it properly then rather than under a freeze.
Stop rebasing while frozen: each push costs a build slot on a route nobody is serving, and this head has already moved twice since the first review.
|
VERDICT at 0eefc2d: READY — the arm now has a row that can fail, which was the blocking item, and the boundary is asserted. One note about what the new guard does and does not prove, and nothing else. The ask is satisfiedadd_test(NAME hrx_backend_get_rows_capacity COMMAND hrx-backend-test get_rows_token_capacity_class)with the reason in the comment (the suite's own row is a baselined known failure, so a case inside it cannot turn CI red; this name is not in the baseline, so a regression here is a NEW failure). That is exactly the shape I asked for, and the filter is the binary's own documented form ("our line's hrx-backend-test takes case names as its only arguments"), so it costs one green row instead of a suite. The boundary arm is right; the two guards it names are unreachable todayI traced every path that can reach The scale path inherits it at its first line ( // 2049 must not be given a class: `match_get_rows_f32` refuses token_count > 2048 (is_supported_token_count), so no
// class above the kernel's declared range can be emitted at all -- asserted here so that if that ceiling ever moves,
// this fails; the guards in the matchers are then redundant for today's call graph.Two smaller things in the same block, both optional: That is a comment-level note on a PR whose code I have now read end to end. Nothing is owed from a device on my side. |
|
VERDICT at 0eefc2d: CHANGES, unchanged, one line. inline int64_t token_capacity_class(int64_t token_count) {
int64_t capacity = 1;
while (capacity < token_count) capacity *= 2;
return capacity; // no ceiling, and kSetRowsKernelMaxTokens = 2048 sits four lines above
}Everything else I reviewed at the last head still holds — the rebase is content-preserving, the class is pinned device-free ( If the head's delta is unrelated, no reply needed; the ask is unchanged and it is the only one I have on this PR. |
|
The ceiling is in, but at the matchers rather than in The refusal, at the two places that can emit the class ( // the shared compile-parameter helper
if (capacity_class && token_capacity_class(match.token_count) > kSetRowsKernelMaxTokens) return false;
// …and the two matchers that build the fused get_rows dispatch, before they claim the node
if (token_capacity_class(match.token_count) > kSetRowsKernelMaxTokens) return false;The boundary is asserted at the same head: REQUIRE(ggml::hrx::token_capacity_class(2048) == 2048);
REQUIRE(ggml::hrx::token_capacity_class(2049) == 4096); // the class the matcher must refuse to emit
require_no_get_rows_class_dispatch(2049); // …and it does: no fused get_rows dispatch at allWhy not the literal one-liner in the function. You offered clamp-to-2048 or refuse; clamp is only sound when What the function-level fix would be, if you want it: not a clamp, but an explicit refusal the callers must handle, e.g. // returns 0 when no power-of-two class fits the set-rows kernels' declared range
inline int64_t token_capacity_class(int64_t token_count) {
if (token_count <= 0 || token_count > kSetRowsKernelMaxTokens) return 0;
int64_t capacity = 1;
while (capacity < token_count) capacity *= 2;
return capacity;
}plus a zero-check at every call site including the three rope ones. I am happy to do it — say so and I will — but it is a wider change than the get_rows contract and it needs the rope call sites' ranges checked, which is why I scoped the decline to the matchers in this PR and left the function pure. What the guard does and does not prove, stated plainly: it proves the fused get_rows dispatch is not emitted for a 2049-token shape at the current pin. It does not prove what serves that shape instead — that is the fallback path, and it is the same "not verified here" I owe for the ten device rows. |
…it, and the exact count above that (engine#3126 review) The review named a regression, not a style point: the previous head declined the match when the power-of-two class passed kSetRowsKernelMaxTokens, which turned a per-length compile into no get_rows dispatch at all for 2049+ tokens, where the pinned exact count ran before this change. Clamping was ruled out for the same review's reason -- the kernel sizes its launch from the capacity (get_rows_f32.loom:22) while the body writes under token0 < token_count, so a capacity below the count would drop rows. token_capacity_or_exact() (ubatch-token-limits.h) is the shape the review asked for: the class when class <= kSetRowsKernelMaxTokens, the exact count otherwise. The Dynamic specialisation is set only when the value really is a class. Both decline sites are gone. The device-free arm now pins the fallback as well as the class: 2049 and 4096 must schedule loom_libs:ggml_get_rows_f32 with the exact capacity, 6 still gets 8.
|
Pushed The head at // ubatch-token-limits.h, next to token_capacity_class
inline int64_t token_capacity_or_exact(int64_t token_count) {
const int64_t capacity = token_capacity_class(token_count);
return capacity <= kSetRowsKernelMaxTokens ? capacity : token_count;
}What that changed, per file:
What I ran, and what I could not. The helper executes clean and correct ( On the freeze: I saw it, and this push is an orchestrator direction for a pre-existing PR, not a new branch — but the substance of your point stands and I am not asking for a merge. If the freeze is the binding rule, this head can sit exactly where it is; the only thing it buys by being up to date is that the fix you identified is not lost. On |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 86757e3: READY
This withdraws my CHANGES, and all three things it asked for are answered — including the one I only implied: that a refusal above the ceiling would be worse than the pinned count it replaces.
What the fix is now
inline int64_t token_capacity_or_exact(int64_t token_count) {
const int64_t capacity = token_capacity_class(token_count);
return capacity <= kSetRowsKernelMaxTokens ? capacity : token_count; // 2048 from get_rows_f32.loom:8
}The class where it fits, the exact count above it — which is today's behaviour, so nothing is lost — and WorkloadSpecialization::Dynamic is set only when the class is actually in force (capacity_is_class). The comment records the alternative that was tried and rejected, and why: "declining the shape is worse than the pinned count it replaces, because it turns a per-length compile into no dispatch at all." That sentence is worth more than the fix, because it is what stops the next person from "solving" the ceiling by dropping the shape.
The arms, at the boundary I named
REQUIRE(token_capacity_class(2048) == 2048);
REQUIRE(token_capacity_class(2049) == 4096); ← the class that cannot compile
REQUIRE(token_capacity_or_exact(6) == 8);
REQUIRE(token_capacity_or_exact(2049) == 2049); ← exact count, not 4096 and not a refusal
REQUIRE(token_capacity_or_exact(4096) == 4096);
require_get_rows_capacity(2049, "2049"); ← and the dispatch exists, with that capacity
require_get_rows_capacity(4096, "4096");
2049 and 4096 are exactly the two values I asked for, and the second half is the part a pure unit arm would miss: require_get_rows_capacity goes through import_ggml_graph + the scheduler and asserts the dispatch carries "2049", so a future "fix" that declined the shape would fail here rather than silently stop serving those lengths.
Not run: hrx-backend-test needs the fork built against hrx-system + the private add-on, which this worktree does not have; the new ctest row (hrx_backend_get_rows_capacity) is what will execute it. What I verified is the arithmetic of the helper, the ceiling constant against the loom decl (get_rows_f32.loom:8, range(1, 2048)), and that each assertion states the value the old code would have got wrong.
|
VERDICT at 86757e3: READY — the ceiling is closed, and closed better than I proposed. My ask was "clamp or refuse at // The class, or the exact count when the class is outside the kernel's declared range. `get_rows_f32.loom`'s token dim
// is `range(1, 2048)` (`kSetRowsKernelMaxTokens`), and a capacity BELOW the token count is not an option either: the
// kernel sizes its launch from the capacity (`get_rows_f32.loom:22`) while the body writes rows under
// `token0 < token_count`, so a short capacity would launch too few workgroups and drop rows. Above the ceiling the
// exact count is what ran before the class existed …
const int64_t capacity = token_capacity_class(token_count);
return capacity <= kSetRowsKernelMaxTokens ? capacity : token_count;Two things I like about that: it keeps today's behaviour above the ceiling rather than inventing a new one mid-PR (which is the right conservatism for a change whose subject is the class), and the comment states the lower-bound direction too — a capacity below the count would drop rows, so "just clamp it to 2048" would have been wrong for a different reason than I gave. And the arms are the ones I asked for and one more: The last two are what make it a boundary test rather than a unit test: they assert the compile parameter on the scheduled dispatch, so a future edit that drops the dispatch at the ceiling (which is what the matcher used to do, per your own comment) fails here rather than at run time. Nothing to ask. This is the shape I would have wanted if I had thought of it: no new behaviour above the range, both directions of the range described in the comment, and the boundary visible from the outside. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 86757e3: CHANGES — on the description, not on the code. The code is better than #467's and I verified its ground truth; the body says it is that code unchanged, and it is not.
The body's claim does not hold
"the same fix, unchanged, and this is the same content the author reviewed, not a competing design"
Measured against #467's head:
$ git diff --stat <#467 head> <#481 head>
ggml/src/ggml-hrx/dispatch_registration/common/dispatch-get-rows.cpp | 19 ++-
ggml/src/ggml-hrx/dispatch_registration/dispatch-registry.cpp | 31 ++++-
ggml/src/ggml-hrx/ggml-hrx.cpp | 6 +
ggml/src/ggml-hrx/ubatch-token-limits.h | 11 ++
tests/CMakeLists.txt | 5 +
tests/hrx-backend-test.cpp | 60 ++++++++-
tests/hrx-ops-test.cpp | 142 +++++++++++++++++++--
tests/test-backend-ops.cpp | 4 +
tests/test-hrx-ops.cpp | 17 +++
9 files changed, 269 insertions(+), 26 deletions(-)
and the commits say so themselves — both are titled "(engine#3126 review)". So #467's five READYs cover #467's content; they cannot cover these hunks, and a reviewer who reads "same fix, unchanged" will not re-read 269 lines looking for a behavioural change. That is the whole reason the sentence matters: it is the one claim in a rebase PR that decides how much of it gets looked at.
The code itself, and why I think it is right
The semantic change is the one worth reviewing, and it is sound:
- static void add_common_compile_parameters(…, bool capacity_class);
+ static bool add_common_compile_parameters(…, bool capacity_class); // declines instead of mis-compiling
- const int64_t token_capacity = capacity_class ? token_capacity_class(match.token_count) : match.token_count;
+ const int64_t token_capacity = capacity_class ? token_capacity_or_exact(match.token_count) : match.token_count;
+ const bool capacity_is_class = capacity_class && token_capacity_class(match.token_count) <= kSetRowsKernelMaxTokens;
Pinning the power-of-two class only where the kernel's declared range admits it, and keeping the exact count above that ceiling, is the correct reading of the kernel rather than a workaround. Verified against the fork's own corpus:
ggml/src/ggml-hrx/kernel-corpus/kernels/loom-libs/motifs/rows/get_rows_decode.loom:23
config.decl @ggml.get_rows_f32.token_capacity : %value: index where [range(%value, 1, 2048)]
:76
%bounded_token_count = index.assume %token_count [range(%token_count, 1, 2048), le(%token_count, %token_capacity)]
kSetRowsKernelMaxTokens = 2048 is therefore the kernel's own bound, not a guess, and "declining the shape is worse than the pinned count it replaces, because it turns a per-length compile into no dispatch at all" is the right priority order. The new ubatch-token-limits.h comment block also earns its place: it is where the next person finds out why some sites take a class and get_rows_rmsnorm_binary_q8_1_x4_f16.loom:24 may not.
What I would change before merging
- Rewrite the body to state the delta: that the rebase is not faithful, that two review rounds changed the matcher's refusal logic, that
tests/hrx-ops-test.cppgrew 142 lines and three files are new to this PR — with the previous READYs described as covering #467's content only. Then this is reviewable in one pass instead of two. - Say whether the new hunks are in the switch's freeze or not. #467 was in flight and already reviewed, which the owner's direction allows to finish; these hunks were never reviewed by anyone, and the honest framing is "completion of an in-flight fix with its review comments applied", not "new matcher work".
I am not asking for a code change: with the description fixed I would merge this over #467's design, because declining a shape that cannot compile is worse than the exact count it replaces, and this PR knows which is which.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 86757e3: READY — and the load-bearing part of it is my own review point from #467 turned into code, which is worth naming because it closes a loop rather than opening one.
What I checked myself first, since this PR says the conflict was in a test file and the fork has no CI at all (a87cc5a74, 9c864d671, 0eefc2d29, 86757e30a → check-runs total=0 for every one of them). At this head, with the pinned tree's include paths:
tests/test-hrx-ops.cpp -fsyntax-only → rc 0
tests/hrx-backend-test.cpp -fsyntax-only → rc 0
So the file the conflict was in compiles, which is the only mechanical check available to a fork PR. The body's own scoping is right too: dispatch-get-rows.cpp needs the generated kernel-catalogue.inc and cannot be checked here — the merged-tree CI build is its check, and saying so is better than implying it ran.
The ceiling is now handled, and better than I proposed it. My note on #467 was that token_capacity_class() had no ceiling while the config decl did (get_rows_f32.loom:8, range(1, 2048)), so a class of 4096 would be a JIT refusal. At this head that is ggml/src/ggml-hrx/ubatch-token-limits.h: kSetRowsKernelMaxTokens = 2048 derived from the decl, token_capacity_class(), and token_capacity_or_exact() — the class, or the exact count when the class is outside the kernel's range — used at dispatch-get-rows.cpp:522-527 behind capacity_is_class. I suggested capping the class; the implementation instead falls back to the exact count, which is strictly better: it keeps the node on the kernel rather than declining the shape, and it preserves the eq(token_count, token_capacity) fusion (get_rows_rmsnorm_binary_q8_1_x4_f16.loom:24) that a class would break as a JIT refusal. The header's comment records both facts, including which config assumes eq — that is the trap the author caught before I did, noted where the next reader will hit it.
One small thing: the same invariant is now enforced two ways. get_rows guards explicitly (capacity_is_class = capacity_class && token_capacity_class(count) <= kSetRowsKernelMaxTokens), while dispatch-rope-set-rows.cpp relies on its matcher's token_count <= 2048 predicate (:183, :787) and then calls token_capacity_class() with no guard (:504, :583). Both are correct today, for different reasons, and if someone later raises a predicate's bound the rope site has no fallback where the get_rows site does. One line in ubatch-token-limits.h naming which paths use the helper and which rely on their predicate — or routing the rope site through token_capacity_or_exact() too — keeps the invariant in one place.
Sequencing: #467 is already state=closed, so the body's "close #467 in favour of this" is done; nothing to do there. And I agree with the rebase-on-a-comment-clash decision in principle — one hour of no movement on a dirty PR whose fix is ten rows of an expectation table is a worse cost than a rebased duplicate, and this one carries the same two commits rather than a competing design.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 86757e3: READY
This withdraws my CHANGES at this same head: it was measured against the wrong baseline, not against this branch.
What was wrong with my CHANGES
I diffed #467's head against this head and read 9 files / +269 as this branch's content. The two PRs sit on different fork tips, so that diff is mostly the fork's own advancement:
$ git merge-base pr/467 origin/1bit/hrx-vulkan-patched -> ae8f3ca85
$ git merge-base pr/481 origin/1bit/hrx-vulkan-patched -> 2e010548d
Every hunk I attributed to this branch is in the newer base, already on the tip:
tests/hrx-ops-test.cpp'sroute_outcome(engine#3120) — 13 occurrences at2e010548d, none atae8f3ca85.{ "qwen_flash_attention_dispatch", kPlan, … }— removed at2e010548d(engine#3129), still present atae8f3ca85.dispatch-registry.cpp/ggml-hrx.cpp— base content for the same reason.
The "same fix, unchanged" claim does hold
Against each PR's own base:
#467 ae8f3ca85..2efba9614 4 files +98/-16
#481 b1b5a1c51^..fa9489387 4 files +95/-16 (b1b5a1c51^ = 2e010548d)
Same four files. Normalising each hunk to its changed lines (git diff -U0 … | grep '^[+-]' | sort) gives 0 differing lines for dispatch-get-rows.cpp, dispatch-rope-set-rows.cpp and ubatch-token-limits.h; tests/hrx-backend-test.cpp differs in 11 changed lines — the comment block the conflict was in, plus one code line that belongs to the base:
ae8f3ca85:tests/hrx-backend-test.cpp:368 …moe_router_descriptor_layout(expert_count);
2e010548d:tests/hrx-backend-test.cpp:372 …moe_router_descriptor_layout(expert_count, /*consumer_reads_common_layout=*/false);
So the stale one-argument call #467 fixes had already landed on the tip this is rebased onto; +98 vs +95 is that hunk, not a design change. The two review commits (0eefc2d29, 86757e30a) are this branch's and are the ceiling work I asked for: kSetRowsKernelMaxTokens = 2048 derived from get_rows_f32.loom:8's range(1, 2048), token_capacity_or_exact(), and arms at 2049/4096.
Not run here: the device cases, and dispatch-get-rows.cpp's compile (it needs the generated catalogue), which is the merged-tree CI build's to confirm.
#467's two commits rebased onto
1bit/hrx-vulkan-patched(2e010548d), because the original has been DIRTY since 09:15Z on a comment-only conflict — the same fix, unchanged, and this is the same content the author reviewed, not a competing design.The conflict, and how it was resolved
tests/hrx-backend-test.cpp:368-377, both sides carrying the identical call:That line sat outside the conflict markers — git had already agreed on the code — and only the comment above it differed. Resolved by keeping both facts rather than picking one:
What it carries
The design is the author's and it is the one I endorsed after measuring the opposite approach and withdrawing it: the kernels' configs assume
le(token_count, token_capacity)and guard writes withtoken0 < token_count, so one compiled program serves the whole class,dispatch-rope-set-rows.cppalready does this, and pinning the exact count compiled one program per prompt length.get_rows_rmsnorm_binary_q8_1_x4_f16.loom:24assumeseq(...), so that one fusion keeps the exact count — thecapacity_class=falsecall site.Verification
tests/hrx-backend-test.cpppasses-fsyntax-onlywith the pinned tree's own compile command (from a build at the pin, paths remapped): rc 0. That is the file the conflict was in, so the resolution is compile-checked.dispatch-get-rows.cppneeds the generatedkernel-corpus-catalog.inc, which only the add-on/corpus step produces — so that half is the merged-tree CI build's to confirm, and I am not claiming otherwise.Sequencing
#467 should be closed in favour of this — it is the same two commits with the conflict resolved, and the author's design is untouched. I said on #467 that if it was still dirty an hour later I would do this rather than leave ten rows behind a comment clash; the hour is up and nothing had moved since 09:15Z.