You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HRX Loom decode-split FA fails to compile for D=256, 24 q heads / 4 kv heads after fork #72 (hrx-system 51b1739) #314
Found 2026-10-05 by the masked-KV determinism audit. With fork #72 (masked-V fix) applied on hrx-system 51b1739 (the pin on main), the decode-split flash-attention kernel fails to compile for head size 256 with 24 query heads and 4 KV heads: BACKEND/044 scheduler cycle, low.cond_br <-> amdgpu.s_cmp_lg_u64. It fails at every n_kv from 256 to 8192 and compiles with #72 reverted.
Qwen3.8-27B is not affected: it takes the gated kernel (priority 100).
A non-gated model with that head layout would fail at decode.
Repro: the add-on's ggml-hrx-attn-masked-kv-check 256 256 24 4 1 1024 1000 (private tool; the shape is all that matters).
To check against the next hrx-system pin; if it persists, the fix is on our side of the .loom (no AMD Loom file was edited).
Re-tested against the next pin: it still reproduces
The issue asked to "check against the next hrx-system pin; if it persists, the fix is on our side of the .loom." Checked. It persists.
Under test:hrx-system 98d05d94 (our fork 1bit/main, the pin on main now — the issue was filed against 51b1739) with llama.cpp 522dab4, private add-on loom-cxx26-gk, gfx1151, via the issue's own repro on the built tool:
HRX Loom JIT AMDGPU HSACO emission failed
diagnostic[0] BACKEND/044: target 'gfx1151' export
'ggml_flash_attention_decode_split_f32_f16_wmma_next_q8' config 'amdgpu.rdna3_5.core'
scheduler stopped in block '<anonymous>' index 162 after scheduling 39/41 node(s)
with 2 unscheduled node(s); unresolved state dependency from node 2355 'low.cond_br'
to node 2354 'amdgpu.s_cmp_lg_u64.src1_inline' operand '0';
cycle path [low.cond_br, amdgpu.s_cmp_lg_u64.src1_inline]; witness edge only true
diagnostic[1] EMIT/TARGET: AMDGPU HSACO emission produced no executable bytes
Shape as the issue states: key_value_token_count=1024, qk_head_size=256, value_head_size=256, query_head_count=24, key_value_head_count=4.
The pin move did not fix it. That was worth testing because the new pin's entire delta over 51b1739 is Loom wait planning — loom/src/loom/target/arch/amdgpu/planning/wait_plan.c+227, plus target_info.py and target_info_defs.h — i.e. the component that reports the cycle. It was suggestive, and it is not the fix.
Where the kernel comes from (this narrows the work): it is not in hrx-system, and not in the add-on. It is tracked at the pinned llama.cpp commit — so it is shipped code, not a local experiment:
ggml/src/ggml-hrx/kernel-corpus/kernels/qwen_moe/qwen3_moe/flash_attention_decode_split_next_q8_test.loom
last commit touching it: 522dab4 "Merge pull request #90 from 1bit-MONSTER/1bit/kv-nan-rootcause"
So the fix belongs in the llama.cpp fork, on our side of the .loom, as the issue predicted. The next step is to read that .loom for the construct that leaves low.cond_br's flag (amdgpu.s_cmp_lg_u64) unresolved — a branch on a comparison whose source is defined in a way the scheduler cannot order.
Reproduce with the tool as above; no AMD Loom file has been edited.
Same index.assume chain, same arithmetic, same two template.apply calls; only the last reduce_fused argument differs (%partial_output vs %next_q8_output). With false the Q8 branch is dead and folds away; with true it goes live and the scheduler stops at 39/41 nodes.
Which specialization is live
reduce_fused dispatches on %key_value_token_capacity:
variant
capacity range
scf.if %publish_q8
reduce_fused_direct_f32 (prio 20)
[64, 256)
:1072
reduce_fused_cooperative_f32 (prio 10)
[257, 2048)
:1121
reduce_fused_multipass_f32 (prio 5)
[2049, 262144)
:1170
The repro's capacity is 1024, so it takes the cooperative variant. The live path is therefore:
around it: seven index.assume …[range(…)] hints, two scf.for … unroll with dynamic bounds (%phase_count, %head_tile_count), and a scf.select that clamps %query_head0 into %safe_query_head.
What I have not established
The cycle's operand is amdgpu.s_cmp_lg_u64.src1_inline — an unsigned != against an inline constant. That comparison does not appear literally in the source (index.cmp ult is s_cmp_lt), so lowering introduces it, most plausibly around the dynamic-bound loop termination, the scf.if %publish_word region, or the completion-counter protocol — all of which only reach that block once pack_completed_q8 is live.
Next step: dump the Loom MLIR and read block index 162's unscheduled nodes 2354/2355, instead of guessing from the .loom. Then the fix is a small source change on our side of the .loom, as the issue predicted.
I have not touched any AMD Loom file, and have not opened a PR for this — it needs the IR dump first.
— but extracts them only on success. On failure it returns early and discards them. I patched that locally (env-gated dump, failure path only), rebuilt, and re-ran the repro. The report does dump, and it is not sufficient:
LOOMC_COMPILE_REPORT_MODE_DETAILS is the highest mode available (only NONE/SUMMARY/DETAILS exist), and it emits planning/memory facts, but every schedule counter is 0 — schedule_node_count, scheduled_node_count, schedule_dependency_count, schedule_band_row_count, schedule_hazard_gap_count — because the compile fails before scheduling completes.
LOOMC_COMPILE_ARTIFACT_FLAG_MODULE_TEXT is documented as "after successful compilation", so a failed compile returns no textual module IR.
So the failing kernel's IR cannot be obtained from loomc's public artifact API at any report mode. Getting it means instrumenting loomc itself (the Loom compiler in hrx-system) to dump the module before the pass that fails — a compiler change, not a .loom change.
That reframes the issue's closing line slightly: the fix is still likely on our side of the .loom, but the diagnosis needs the compiler instrumented first.
If that is too deep a route, the alternative is to reason from the construct already identified: the cycle is low.cond_br feeding on amdgpu.s_cmp_lg_u64.src1_inline (an unsigned != against an inline constant) inside the pack_completed_q8 path that only goes live when publish_q8 is true — i.e. look for the !=-terminated construct the lowering introduces there.
A validated way to test a .loom fix — and one candidate ruled out
Two of my attempts at this produced no-op "results" that looked like findings. Writing down the trap, because it is invisible and it cost me two cycles:
kernel-corpus.cpp includes generated.inc files (kernel-corpus-sources.inc, -qwen.inc, -catalog.inc), built from the .loom sources at build time.
So editing a .loom and re-running the tool changes nothing at all. That is what my first two runs did — they returned byte-identical diagnostics, including after I injected a deliberate syntax error, which is what eventually exposed it.
The corpus build does validate: a bad .loom fails it (FAILED: [code=1] …kernel-corpus-sources.inc).
The procedure whose results mean anything:
edit the .loom;
rebuild and require rc=0 and zero hard errors — a failed build leaves the previous .so and the old embedded corpus, producing an unchanged diagnostic that reads exactly like "the fix didn't work";
establish a baseline first (clean tree must still fail), then re-run.
Ruled out: the two dynamic-bound unroll loops in pack_completed_q8
Baseline clean (build rc=0, 0 hard errors, repro still hits the cycle). Then unroll was removed from both scf.for loops in pack_completed_q8; build rc=0, 0 hard errors, so the change was genuinely compiled in. The repro returned an identical diagnostic:
scheduler stopped in block '<anonymous>' index 162 after scheduling 39/41 node(s) with 2 unscheduled node(s)
Not the cause. Tree restored with git checkout (diff 0).
Where that leaves it
The cycle's operand, amdgpu.s_cmp_lg_u64.src1_inline, is an unsigned != against an inline constant that does not appear in the .loom — lowering introduces it, and it is not the unroll loops. The IR is not obtainable through loomc's artifact API at any mode (see above), so the next candidate has to come from reading pack_completed_q8 for that !=-shaped construct, or from instrumenting loomc itself.
Everything above is on the pinned tree (llama.cpp 522dab4, hrx-system 98d05d94), repro 256 256 24 4 1 1024 1000.
Second candidate ruled out — with all preconditions asserted this time
Two candidates are now eliminated by valid tests. The second one, and the method that makes it trustworthy:
Hypothesis. The cycle operand is amdgpu.s_cmp_lg_u64.src1_inline — an unsigned != against an inline constant. The one construct in pack_completed_q8 that lowers that way is a divisibility assume:
baseline: build rc=0 hard-errors=0 ; reproduces
intervention: replaced all 7 occurrences of the mul constraint
tree changed: yes
build rc=0 hard-errors=0
after: identical diagnostic (block 162, 39/41)
VERDICT: NOT the cause
The constraint appears in 7 places, not one, so any fix there would have to cover all seven.
On method, because it is the actual lesson here. Four earlier attempts produced "results" that were no-ops:
attempt
what invalidated it
1–2
edited the .loom without rebuilding — the corpus .inc is generated at build time
3
build gate, but a bad restore left my own syntax-error token in the file
4
build gate, but the patch legitimately matched 7 sites, so it never applied — it printed "change compiled in" while diff=0
Every one looked like "hypothesis falsified". The defect was identical each time: a gate that checked build health but never checked that the intervention happened. The test now asserts five preconditions and aborts loudly on any: tree clean · baseline build clean · baseline reproduces · intervention changed the tree · post-intervention build clean.
So this issue currently stands at: two candidates eliminated with evidence, the live path pinned to pack_completed_q8's publish_q8 branch, and the IR unreachable through loomc's artifact API at any report mode.
Third candidate ruled out — the extra publish_q8 barriers
Three candidates are now eliminated, each by a test whose preconditions were asserted. Summary, and the one that matters most for method:
#
candidate
verdict
1
the two dynamic-bound unroll loops in pack_completed_q8
not the cause
2
the mul(...) divisibility assume on value_head_size (all 7 sites)
not the cause
3
the two extra barriers in the publish_q8 branch (cooperative_f32)
not the trigger
Candidate 3 was the strongest hypothesis so far — amdgpu.s_cmp_lg_u64 is an unsigned 64-bit !=, the natural shape of a barrier's "wait until the count reaches N" test, and publish_q8 = true emits exactly two barriers the false path never does, which would explain the gating without special pleading. It is wrong:
baseline: build rc=0 hard-errors=0 ; reproduces
intervention: cooperative_f32's publish_q8 barriers removed (scoped to 1 of 3 occurrences)
tree changed: yes
build rc=0 hard-errors=0
after: identical diagnostic (block 162, 39/41)
VERDICT: NOT the trigger
On method, because it is now the load-bearing part. The first attempt at candidate 3 aborted — the barrier block is identical in all three reduce_fused specializations, so an unanchored replace matched 3 and the precondition refused to emit a verdict. Compare that with attempt 4, which hit the same class of problem and printed "BUILD OK → change compiled in" while diff=0. Two of the five attempts would have been reported as findings under the old harness.
So: the failure stands at block 162 with 39/41 nodes scheduled and the low.cond_br ↔ amdgpu.s_cmp_lg_u64.src1_inline cycle, gated on publish_q8 = true. The IR is unreachable through loomc's artifact API at any report mode, so the next step is either a fourth hypothesis or instrumenting loomc itself — not another .loom poke.
The IR is obtainable — loom-compile has --dump-ir-* flags
This issue's blocker is recorded as:
"the failing kernel's IR is NOT reachable through loomc's artifact API at any report mode (only NONE/SUMMARY/DETAILS
exist; MODULE_TEXT is success-only), so the next step is a fourth hypothesis or instrumenting loomc."
The first half is true; the conclusion does not follow. That was established against loomc's artifact/report API, but
the tool has a separate pass-pipeline IR tracer. From loom/src/loom/tooling/pass/trace_cli.h:
#define LOOM_TOOLING_PASS_TRACE_USAGE \
"Use --dump-ir-before/--dump-ir-after=<pass-or-stage> or " \
"--dump-ir-before-all/--dump-ir-after-all to capture pass-boundary IR. " \
"Trace events snapshot the whole module, even for function passes. Use " \
"--dump-ir-format=jsonl for one event per line; " \
"--dump-ir-output=dir/ writes trace.jsonl plus ir/*.loom.\n"
loom-compile.c links loom::tooling::pass::trace_cli and calls loom_tooling_pass_trace_open_from_flags(...), and loom/src/loom/pass/trace.h documents the mechanism:
"The pass interpreter calls this cold diagnostic boundary immediately before and after selected pass invocations…
the trace layer owns stable event formatting, pass/stage matching, and IR snapshot printing."
with LOOM_PASS_TRACE_FORMAT_TEXT and LOOM_PASS_TRACE_FORMAT_JSONL, and a configurable point of BEFORE/AFTER per invocation.
which per the usage line writes trace.jsonl plus ir/*.loom — the whole module at each pass boundary, including
whatever stage the scheduler's dependency analysis runs in. That is precisely the artifact whose absence was blocking
this issue, and it means the likely route is a flag, not instrumentation.
I have not run it yet, and I want to be explicit about that rather than present a flag list as a result: the box is
executing a long GPU evaluation, and this repro needs the failing kernel compiled. So treat the above as a corrected
statement of what is possible, not as a capture. What I have verified is the flag surface in the source: the usage
string, loom-compile.c's call into open_from_flags, and the trace header's before/after boundary semantics.
What this changes for the issue:
"Instrument loomc" is probably unnecessary, and was the expensive next step.
The four hypotheses already spent do not need redoing; they were sound, they just could not see the IR.
The remaining job is to capture the trace at the failing pass boundary and read the cycle where it is introduced —
which is a debugging task with the evidence in hand, not a compiler-instrumentation project.
Worth correcting in the issue body so the next person does not burn time on instrumentation that already exists in
tool form.
The IR dump works — but this repro needs the runtime's compilation unit, not a standalone compile
Following my previous comment, I ran it rather than stopping at the flag list. Both halves are worth recording.
The dump mechanism works. Compiling this kernel with --dump-ir-after-all --dump-ir-format=text produced a 3.4 MB
artifact containing 27 pass-boundary IR snapshots:
//===----------------------------------------------------------------------===//
// Loom IR dump after pass normalize-kernel-resources
// tool: loom-compile
// input: …/flash_attention_decode_split_f32_f16_wmma.loom
…
after pass cse
after pass select-templates
after pass inline-callables
after pass canonicalize (x4)
after pass select-templates
after pass inline-callables
after pass select-templates ← last one before the failure
So the IR is obtainable, and my previous comment stands on that point.
But a standalone compile does not reproduce this issue. It fails earlier, with a different error:
…/flash_attention_decode_split_f32_f16_wmma.loom:893:7: error [LOWERING/045]:
select-templates cannot resolve template.apply against …
893 | template.apply<@ggml.quantize_q8_1_x4.publish_vector4>(%publish_word, …)
= help: Add a matching template.def provider, make target, caller context, and value
predicates resolvable before final selection, or correct the construct.
That is a missing provider, not a scheduler cycle. The kernel calls into @ggml.quantize_q8_1_x4.publish_vector4,
whose template.def lives outside this file, so compiling the .loom on its own never reaches the pass where the low.cond_br ↔ amdgpu.s_cmp_lg_u64 cycle appears. The compile ran with the repro's parameters
(key_value_token_capacity=1024, which does select cooperative_f32).
So the correct correction to my previous comment is narrower than I implied. The pass-trace exists and works, but it
is reached through loom-compile, and the failing compile in this issue happens inside the runtime's in-process
compile — the JIT path that has the private add-on's providers in scope. Two consequences:
To capture this cycle, the compile must carry the same providers the runtime links: the same bundle/catalog, not the
single .loom. I have not established what that bundle is; the add-on's kernel sources would be the place to look.
It is worth checking whether the runtime's compile path can be given the same trace options. loom-compile gets them
through loom_tooling_pass_trace_open_from_flags, but the loomc compile API used in-process does not obviously expose
a trace field — which is the one place the earlier "instrumentation may be needed" instinct could still be right, now
for a much narrower reason than before.
Net effect on the issue: the blocker is still false — the IR is obtainable — and the expensive guesswork is still
avoidable. But the input to the dump must be the runtime's compilation unit, and reproducing the cycle with loom-compile kernel.loom alone will not work. That is a much smaller unknown than "the IR is unreachable".
Artifacts preserved at ~/lb/ir314/per-pass-dump.txt (3.4 MB), bare.log, dump.log on strixhalo.
Five capture attempts mapped the toolchain — here is the input problem, precisely
Following my earlier correction (the IR is obtainable), I tried to actually capture it. Five attempts, each costing a
compile cycle and revealing one more requirement. None reached the IR, but the map is worth having.
#
input
result
1
the lone .loom
LOWERING/045: template.apply @ggml.quantize_q8_1_x4.publish_vector4 unresolvable — a bare file carries no template implementations
2
+ loom-libs/** as --library
link OK (64 KB) but compile still no_provider; my root grep had matched a _body_ symbol
3
the correct kernel, qwen_moe/qwen3_moe/flash_attention_decode_split_f32_f16_wmma.loom
link OK, then HAL backend 'amdgpu-hal' requires at least one kernel entry — a _body_ root materialises no entry
4
+ the real entry @qwen3_moe_flash_attention_decode_split_f32_f16_wmma_next_q8
link fails: template_selection.c:1546 FAILED_PRECONDITION; 1 reachable template applications remain unresolved
5
+ every.loom in the corpus (122) as providers
link fails earlier: planner.c:496 NOT_FOUND; unresolved exact declaration '@qwen3_moe_flash_attention_decode_split_f32_f16_wmma_next_q8'
What is now established — this is the useful part:
The corpus layout is kernel-corpus/kernels/{qwen,qwen_moe,hrx,loom-libs}.loom-libs holds the shared templates
(the providers); the concrete kernels live under qwen_moe. Attempts 1-2 were compiling a template as if it were the
kernel, which is why the provider would not resolve.
The kernel's real entry is @qwen3_moe_flash_attention_decode_split_f32_f16_wmma_next_q8, and the same directory
contains a separate flash_attention_decode_split_next_q8_test.loom — plausibly where that variant is defined
rather than referenced. That is the most likely next input, and the cheapest thing to try.
The runtime does not compile from text at all. The generated kernel-corpus-sources.inc is 17 MB of LOOM-magic bytecode (0x4c,0x4f,0x4f,0x4d), i.e. the engine's own compilation unit is a frozen bytecode corpus. Reproducing
that from .loom text may not be equivalent, which would explain why resolving providers by hand keeps failing.
Why I am stopping, and what stands. Each attempt reveals one more requirement with no bounded end in sight, so I would
rather leave an accurate map than another half-attempt. The earlier correction stands unchanged: the IR is not
unreachable — --dump-ir-after-all works and produced 27 pass-boundary snapshots. What is missing is the right input,
and the likeliest candidate is now named. Whoever picks this up should start with flash_attention_decode_split_next_q8_test.loom, and if that fails, treat the bytecode corpus as the real unit and
either extract it or add the trace to the runtime's in-process compile path instead.
Artifacts: /tmp/ir314{e,d,c}/ on strixhalo hold each attempt's link/compile logs.
The real blocker: I was driving a v34 toolchain against a v38 corpus
Six attempts in, the answer was in the very first error line and I misread it as another thing to work around:
error [BYTECODE/002]: unsupported format version 38, expected 34
and one line of source:
# /home/bcloud/wt/pin-fork-hrx/third_party/hrx-system <- the engine pin, 98d05d94
#define LOOM_BYTECODE_FORMAT_VERSION 38
~/hrx-sdk-pin/bin/loom-compile is built from an older hrx-system than the engine pins, so it cannot read the
engine's frozen bytecode corpus. The corpus is v38; that tool expects 34.
This retro-explains every earlier failure, which is the useful part:
The text .loom files linked to only 6 KB and resolved no template bodies — not because they are
"planning-grade" (my hypothesis) but because that text and that tool are from different revisions.
no_provider kept appearing for families the manifest names explicitly — version skew, not a missing input.
The engine's own build tree contains a v38 loom-link but no loom-compile — which is exactly why nothing
local could compile the corpus.
So the fix is a matching toolchain, not more input archaeology. Build loom-compile from the engine-pinned
hrx-system 98d05d94 (the tree that defines version 38) — I have that build running incrementally in the engine's own
loom build directory, since the v38 loom-link is already there — then compile the frozen corpus with --dump-ir-after-all. Pairing a corpus with tools of a different revision, as I did, measures only the mismatch.
What stands from all of this, and it is worth keeping:
The IR is reachable: --dump-ir-after-all is real, documented in the tool's own help, and was demonstrated
producing pass-boundary snapshots.
The corpus's manifest.json is the specification — link_modules gives each module's exact srcs + libraries
(which is how I learned the provider is ggml/quantize_q8_1_x4.loom in ggml/, not in loom-libs/), and plan_cases
gives the exact config namespace (qwen3_moe.attention.*, not ggml.flash_attention.*).
The engine compiles frozen bytecode, not text — kernel-corpus-sources.inc is 17 MB of LOOM-magic arrays; I
extracted the three flash-attention ones (kernel_source_{42,107,108}_*) as a first step before hitting the version
error, so that path is prepared.
Lesson I'd rather state plainly than bury: the first BYTECODE/002 was already the answer. I treated a version
error as an input error, and six compile cycles followed from that. Reading the error literally would have cost one.
Addendum: don't try to reconfigure the engine's loom build — it will not relink
Following the version-skew finding, I tried the obvious fix on the engine's own loom build:
cmake -DLOOM_EMIT_AMDGPU=ON -DLOOM_TARGET_ARCH_AMDGPU=ON .
-- Configuring done / Generating done
now: LOOM_EMIT_AMDGPU:BOOL=ON
ninja loom-compile
ninja: no work to do.
no work to do is the point. Turning the option on adds no dependency to the loom-compile target in that
configuration, so the tool is never relinked and still rejects --backend. That build exists to embed loom as a library (for ggml-hrx); its command-line tool is incidental and does not carry the emit backends, flag or no flag.
So no single loom build on this box satisfies both requirements, and none of them is broken:
build
bytecode version
backends
why it fails here
~/hrx-sdk-pin/bin/loom-compile
v34
yes
cannot read the engine's v38 corpus
engine deps build (ggml-hrx-deps-build/loom/…)
v38
no, and unconfigurable as above
cannot emit HSACO
What is actually needed is a third thing that does not exist here: loom's own tool build from the pinned hrx-system 98d05d94 — the project's full tools configuration (bazel, or loom's top-level cmake with tools enabled), not the
engine's dependency subset. That is a known-tree build, not research.
The capture recipe is complete and recorded, so whoever builds that one tool can run it immediately:
configs: plan_cases — namespace is qwen3_moe.attention.*, not ggml.flash_attention.*
IR: --dump-ir-after-all --dump-ir-format=text
input format: the frozen bytecode corpus; the three flash-attention arrays are already extracted at /tmp/ir314i/kernel_source_{42,107,108}_*.loomc on strixhalo
The kernel compiles — the "fails to compile" framing looks like a runtime-config problem
Worked on this today. The headline: this kernel compiles cleanly, standalone, on a CPU-only box, to a real AMD code object. So the failure is not "loomc cannot compile this kernel".
Recipe. The compilation unit is not the kernel file — it is declared per kernel in the corpus manifest:
kernels/loom-libs/manifest.json -> exports[] -> symbol ggml_flash_attention_decode_split_f32_f16_wmma_next_q8
compile_recipe.primary_sources : ops/flash_attention_decode_split_f32_f16_wmma.loom
compile_recipe.library_sources : motifs/quantize_q8_1_x4.loom <-- supplies the missing provider
LOWERING/045: no_provider for @ggml.quantize_q8_1_x4.publish_vector4; no artifact
kernel + library_sources, no config
LOWERING/045: missing_facts at template.apply<@ggml.flash_attention.decode_split.reduce_fused> — its provider requires where [range(%key_value_token_capacity, 64, 256)] and the launch shape is unknown
kernel + library_sources + launch-shape config
rc=0, real 120,320-byte code object
The template.apply argument comes from an index.assume, so selection cannot resolve unless the launch shape is compile-time. Hypothesis: the runtime's in-process compile does not pass the launch shape as compile-time config, so reduce_fused selection degrades to missing_facts/no_provider and the backend emits no bytes — which matches "HSACO emits no bytes" far better than a scheduler cycle.
Two corrections to the issue text:
The reported cycle names s_cmp_lg_u64. This build produces s_cmp_lg_i32.src1_inline (108 hits), not u64. It is not reachable from capacity 256 or 1024. low.cond_br (25,929) and *.src1_inline (5,677) are both present in the IR — and the kernel still compiles — so those two tokens being adjacent is not sufficient to cause the failure.
Per-pass IR is now obtainable (--dump-ir-after-all, 148 snapshots), which the previous attempt could not reach.
Not yet established: nothing has run on a GPU here, and the end-to-end symptom (scheduler stopped in block 162, 39/41 nodes, no bytes) is still unreproduced. Suggested next step is to instrument the runtime's compile call to record which config it passes, before chasing the scheduler cycle. Full write-up: STANDALONE-REPRO.md in the working notes.
Root cause: amdgpu.scc register exhaustion from two subgroup.vote ops — reproduced locally, no GPU
Correcting my earlier comment on this issue: I hypothesised the launch-shape config was missing. That was wrong. The runtime does supply it (dispatch-flash-attention.cpp:632 for the capacity, :397 for qk_head_size/attention_scale). The config is necessary — without it the unit dies earlier at LOWERING/045 — but it is not the cause.
The real failure, at the release pin 522dab4, compiling the manifest-declared unit:
BACKEND/005: target 'gfx11-generic' export 'ggml_flash_attention_decode_split_f32_f16_wmma'
failed to allocate amdgpu.scc registers for '@ggml_flash_attention_decode_split_f32_f16_wmma'
with budget 1, peak 2, and failure code 'unspillable-register-exhausted'
at pin-unit.loom:348: %key_tile_all_visible = kernel.subgroup.vote.all %lane_tile_visible : i1
help: Lower pressure before allocation or allow spill codegen for amdgpu.scc values
…repeated for …_next_q8 and …_produce_partials_f32_f16_wmma. So this is register allocation on the SCC register failing, not a scheduler cycle. It also reads the reported symptom correctly: amdgpu.s_cmp_lg_u64.src1_inline is how a vote comparison lowers and low.cond_br is the branch consuming its s_cc — "cycle: low.cond_br ↔ s_cmp" is the allocator unable to satisfy two live SCC values against a budget of 1.
Controlled A/B (the proof). The pin's kernel has exactly two votes:
(The aliasing is a diagnostic, not a fix — it changes any into all. A real fix must preserve the visibility logic.)
Revision dependence.c7aedf319 (2026-09-30) has 0subgroup.vote ops in this kernel and compiles cleanly to a 120,320-byte code object; the pin has 2 and fails. The votes were added between those revisions — that is the regression window, and git log -p over that range on ops/flash_attention_decode_split_f32_f16_wmma.loom will name the commit.
Repro (CPU-only, no GPU, deterministic):
cd<engine checkout>
F=ggml/src/ggml-hrx/kernel-corpus/kernels/loom-libs/ops/flash_attention_decode_split_f32_f16_wmma.loom
M=ggml/src/ggml-hrx/kernel-corpus/kernels/loom-libs/motifs/quantize_q8_1_x4.loom
gh api "repos/1bit-MONSTER/llama.cpp/contents/$F?ref=522dab4" --jq .content | base64 -d > /tmp/pin-fa.loom
gh api "repos/1bit-MONSTER/llama.cpp/contents/$M?ref=522dab4" --jq .content | base64 -d > /tmp/pin-motif.loom
cat /tmp/pin-fa.loom /tmp/pin-motif.loom > /tmp/pin-unit.loom
loom-compile /tmp/pin-unit.loom --backend=amdgpu-hal --target=gfx11-generic \
--config=ggml.flash_attention.query_head_count=24 --config=ggml.flash_attention.key_value_head_count=4 \
--config=ggml.flash_attention.qk_head_size=256 --config=ggml.flash_attention.value_head_size=256 \
--config=ggml.flash_attention.decode.key_value_token_capacity=1024 \
--config=ggml.flash_attention.attention_scale=0.0625 --output=/tmp/pin.hsaco
# rc=1, no bytes. Compile the same unit with one vote -> rc=0, real code object.
Note the compilation unit is declared in the corpus manifest (exports[] → compile_recipe: primary_sources + library_sources). Compiling the kernel file alone fails with no_provider for @ggml.quantize_q8_1_x4.publish_vector4 — which is what earlier attempts did, and why they concluded this needed a build it did not need. loom-compile already exists.
Fix options
Compiler side (cleanest, fixes the class): make amdgpu.scc values spillable, or materialise the vote result into a VGPR rather than holding it in SCC across the branch. Lives in hrx-system/loom (our fork).
Kernel side: restructure so only one vote result is live at a time, or derive any without a second vote. Must preserve slot-visibility semantics.
Revert to the c7aedf319 kernel shape (no votes), which compiles.
Separate, smaller finding: at the pin, dispatch-flash-attention.cpp:46 claims the reduce kernel has "exactly two template.def implementations … Nothing covers above 2048". The corpus actually has three (multipass_f32 covers 2049–262144), so the constant kDecodeSplitMaxKeyValueTokenCapacity = 32768 is correct and the comment is stale. Acting on that comment (lowering it to 2048) would silently disable the split path for 2049–32768. Not this bug, but worth fixing so it does not mislead the next person.
Introducer named — and it is a correctness fix, so reverting is not free
Commit e6187096 (2026-10-02) — "ggml-hrx: masked KV rows reach flash-attention P*V as V = +0 (identical requests gave different logits)", +80/-5 — adds exactly the two lines:
e6187096...522dab4 = ahead=54, behind=0, so it is an ancestor of the release pin, and it is the only commit touching that file between c7aedf319 (0 votes → compiles to a 120,320-byte code object) and the pin (2 votes → BACKEND/005, 0 bytes).
The important consequence: this commit fixed a nondeterminism bug — identical greedy requests in one llama-server process produced different logits because masked KV rows reached P*V as V = +0. So reverting the votes would reintroduce that determinism defect.
This is the same item tracked separately as "the separate masked-V determinism item (masked keys changed output by ~1e-6, so identical requests diverged)". #314 and the masked-V determinism item are two faces of one commit — the fix for the determinism bug is what breaks the compile.
That makes the compiler-side fix the preferred one (make amdgpu.scc spillable, or materialise the vote result into a VGPR rather than holding it live in SCC across the branch). It fixes the class and keeps the determinism fix. In hrx-system/loom, our fork.
Blast radius: exactly one kernel. Scanned the pin's own tree (git grep at 522dab4; note a raw-SHA fetch is refused by GitHub, so I fetched 1bit/hrx-vulkan-patched to bring the object in). Of 123.loom files under kernel-corpus/kernels, only two contain any vote at all:
So no other kernel can hit this. The exposure is one kernel family.
(The same commit e6187096 also touched ops/flash_attention_f32_f16_wmma.loom, but that file has 0 votes at the pin, so its change is unrelated to this failure.)
Ops a kernel-side fix needs — both confirmed present (in hrx-system/loom/src/loom/ops/kernel/ops.h):
so vote.all(p) ≡ cmpi eq, ballot(p), active.mask and vote.any(p) ≡ cmpi ne, ballot(p), 0. Ballot results live in a general register (VCC/SGPR), not SCC, leaving the single SCC for the final branch.
Caveat: the two votes use two different predicates (%lane_tile_visible uses scalar.ori of the outside/in-tile and key-visible terms; %lane_tile_has_visible uses scalar.andi), so this needs two ballots, not one, and the active-lane semantics must be confirmed before landing. I deliberately did not land a rewrite — this kernel is correctness-critical and needs GPU validation, so I am leaving it as a precisely-scoped handoff rather than an unverified edit.
Compiler-side alternative (fixes the class):codegen/low/rematerialization.c already has a path keyed exactly on unspillable-register-exhausted (loom_low_allocation_failure_is_rematerializable_pressure), but it only accepts LOOM_LOW_DESCRIPTOR_PACKET_OP/_CONST packets, so a vote feeding cond_br is out of scope. Widening that, or materialising the SCC into an SGPR, would fix any kernel that hits this. Note "make SCC spillable" is not literally possible: the class is count=1, allocatable=1, PHYSICAL|UNSPILLABLE (registers_test.cc:218), which is physically right — AMDGCN has one SCC.
The candidate fix is validated numerically — identical on the masked-KV check
I built the numerical gate the repro was missing (an equivalent of your ggml-hrx-attn-masked-kv-check): two runs of the same decode-shaped graph that differ only in the V values of the masked rows. If the fix works, both outputs must be identical.
kv=1024, first half visible, second half masked with F16 -inf:
kernel
vsign +0.5
vsign -0.5
current
out0=0.0100021362 sum=61.453125
out0=0.0100021362 sum=61.453125
candidate (shared-memory tile visibility)
out0=0.0100021362 sum=61.453125
out0=0.0100021362 sum=61.453125
Both are bit-identical across the two runs, and the candidate reproduces the current kernel's values exactly. So the shared-memory derivation is numerically equivalent on this check rather than merely compiling — which I could not claim before.
Two caveats, stated rather than buried:
The emission failure is intermittent. The unfixed kernel failed to compile on some runs and compiled on others with an identical graph, so the scheduler's mis-ordering has a nondeterministic element. That is a finding in itself, and it means "it compiles now" is weaker evidence than "it compiles every time" — the candidate needs repeat runs to establish that, which I have not done at volume.
My first version of this check was wrong twice — -65504 for masked keys when the threshold is < -1e30 (F16 -inf), and a V fill indexed [hsv][kv][nkv] instead of [hsv][nkv][kv] which scattered the masked values. Both produced a large spurious "leak" that I nearly reported as the bug. The numbers above are from the corrected program.
Program and patch script are in the working notes (fa314-candidate-fix.sh, fa314-masked-kv-check.cpp). Running your ggml-hrx-attn-masked-kv-check 256 256 24 4 1 1024 1000 against it is still the authoritative gate — mine is an equivalent I wrote, not the same instrument.
Correction: the failure does not reproduce on demand — and it failed on the same digest
I have to correct something I posted, and the correction is more interesting than the claim.
What I claimed: that the emission failure was "intermittent", because the unfixed kernel failed on some runs and compiled on others. I measured it properly instead — 10 runs each, JIT cache cleared between every run:
and again in a freshly configured tree (-B, so nothing carried over from this session's experiments), 5 more runs, cache cleared each time:
run 1..5: OK compile gfx1151|f2541593794f05ea (identical digest every run)
So "intermittent" is not supported by the data. I withdraw it.
What is still true, and is the more useful fact: the failures I saw repeatedly in earlier rounds carried the same digestf2541593794f05ea as the runs that succeed now. Same source, same digest, sometimes a scheduler failure and sometimes not — so whatever trips it is outside the kernel source: host-side compiler state, thread or hash ordering, something environmental. That is worth a report to the Loom side on its own, because a scheduler that non-deterministically fails to order the same input is a bug regardless of which kernel provokes it.
What this means for the candidate fix. The shared-memory derivation:
compiles, and is numerically identical to the pristine kernel on the masked-KV check (out0=0.0100021362, sum=61.453125, both V signs, both kernels);
removes exactly the construct the diagnostic named (low.cond_br fed by a subgroup collective).
But I cannot demonstrate that it fixes the emission failure, because I can no longer make that failure happen on demand — not even in a fresh tree. So it is a plausible, numerically equivalent change, not a demonstrated fix. Anyone who can reproduce the failure — with a machine or a build where it triggers — can settle it in one run. I would not merge it on my evidence alone, and I would rather say that than leave a "validated" claim standing that the rate test does not support.
Pushed as 1bit/fa-shared-visibility on 1bit-MONSTER/llama.cpp (f9ff06675af6) — one file, +102/-2 against the pin: ggml/src/ggml-hrx/kernel-corpus/kernels/loom-libs/ops/flash_attention_decode_split_f32_f16_wmma.loom.
The commit message carries the evidence and the limits: it compiles and runs at the failing configuration; it is bit-identical to the voting kernel on an equivalent masked-KV check; and it is not verified against your authoritative tool — nor can I demonstrate that it fixes the emission failure, because that failure no longer reproduces for me even in a freshly configured tree.
Treat it as a candidate to test, not a fix to merge. If ggml-hrx-attn-masked-kv-check 256 256 24 4 1 1024 1000 behaves identically with and without it, the shared-memory read is the right equivalent; if not, the per-lane derivation is wrong and the .loom needs restructuring instead (candidate 2 from my earlier comment).
One file, +102/-2 against the pin, with the verification and its limits in both the commit message and the PR body.
One CI note worth knowing before reading the red X: build-cann.yml fails on this branch — and on every other recent branch in the fork (1bit/amd-core-our-hrx, 1bit/amd-sync-corpus-repair). It is pre-existing, not something this change introduced.
Second candidate pushed: always-stage, +6/-2, also bit-identical
Candidate 2 is implementable without restructuring the scf.if — replace the two votes with constant predicates (all_visible = false, any_visible = true), so the kernel always takes the existing staging path and never issues a collective. Pushed as 1bit/fa-always-stage on 1bit-MONSTER/llama.cpp.
(My first attempt inlined the staged branch by hand and loom rejected it: the staged scf.yield belongs to an innerscf.if, so inlining turned it into a loop yield and the parser reported undefined SSA value '%next_product_accumulator0' at line 377. The constant-predicate form sidesteps that entirely.)
Same check for all three — kv=1024, half the keys masked with F16 -inf, two runs differing only in the masked rows' V:
variant
collectives
diff
build
out0
sum
pristine
2 votes
—
emission failure (not currently reproducible)
0.0100021362
61.453125
candidate 1fa-shared-visibility
none
+102/-2
ok
0.0100021362
61.453125
candidate 2fa-always-stage
none
+6/-2
ok
0.0100021362
61.453125
The trade-off, which I am not going to pick for you. Candidate 1 keeps the direct V path for tiles that need no masking and stages only where it must; candidate 2 is a quarter of the diff but pays the staging loop and two subgroup barriers on every key tile. So 1 is the fix if the direct path matters for decode throughput; 2 is the fallback if the priority is a small, obviously-correct change.
Neither is benchmarked: this box has no headroom for a throughput comparison (0 GB available), so any performance claim for either is reasoning, not measurement.
Census 2026-09-25 #961bit/fa-always-stage (+6/-2) — always stages; the smallest correct change
Each body now points at the other, with the trade-off stated. Both: no collectives, compile at the failing configuration, and give bit-identical output on the masked-KV check (out0=0.0100021362, sum=61.453125).
Pick one, not both — they are alternatives, not a stack. Neither is benchmarked (no machine headroom here) and neither is verified against ggml-hrx-attn-masked-kv-check, which is the gate I cannot run.
Activity
bong-water-water-bong commentedon Oct 5, 2026
Re-tested against the next pin: it still reproduces
The issue asked to "check against the next hrx-system pin; if it persists, the fix is on our side of the .loom." Checked. It persists.
Under test:
hrx-system 98d05d94(our fork1bit/main, the pin onmainnow — the issue was filed against51b1739) withllama.cpp 522dab4, private add-onloom-cxx26-gk,gfx1151, via the issue's own repro on the built tool:Result — the same scheduler cycle, to the node:
Shape as the issue states:
key_value_token_count=1024,qk_head_size=256,value_head_size=256,query_head_count=24,key_value_head_count=4.The pin move did not fix it. That was worth testing because the new pin's entire delta over
51b1739is Loom wait planning —loom/src/loom/target/arch/amdgpu/planning/wait_plan.c+227, plustarget_info.pyandtarget_info_defs.h— i.e. the component that reports the cycle. It was suggestive, and it is not the fix.Where the kernel comes from (this narrows the work): it is not in
hrx-system, and not in the add-on. It is tracked at the pinned llama.cpp commit — so it is shipped code, not a local experiment:So the fix belongs in the llama.cpp fork, on our side of the
.loom, as the issue predicted. The next step is to read that.loomfor the construct that leaveslow.cond_br's flag (amdgpu.s_cmp_lg_u64) unresolved — a branch on a comparison whose source is defined in a way the scheduler cannot order.Reproduce with the tool as above; no AMD Loom file has been edited.
bong-water-water-bong commentedon Oct 5, 2026
Localization: the failure is one boolean, and it is in
publish_q8Follow-up to the re-test above — I traced which code the cycle is in, because the answer is unusually clean.
The switch is a single constant
In
kernel-corpus/kernels/loom-libs/ops/flash_attention_decode_split_f32_f16_wmma.loom, two exports are identical apart from one line:Same
index.assumechain, same arithmetic, same twotemplate.applycalls; only the lastreduce_fusedargument differs (%partial_outputvs%next_q8_output). Withfalsethe Q8 branch is dead and folds away; withtrueit goes live and the scheduler stops at 39/41 nodes.Which specialization is live
reduce_fuseddispatches on%key_value_token_capacity:scf.if %publish_q8reduce_fused_direct_f32(prio 20)[64, 256)reduce_fused_cooperative_f32(prio 10)[257, 2048)reduce_fused_multipass_f32(prio 5)[2049, 262144)The repro's capacity is 1024, so it takes the cooperative variant. The live path is therefore:
The suspect construct
pack_completed_q8(:830), inner body:around it: seven
index.assume …[range(…)]hints, twoscf.for … unrollwith dynamic bounds (%phase_count,%head_tile_count), and ascf.selectthat clamps%query_head0into%safe_query_head.What I have not established
The cycle's operand is
amdgpu.s_cmp_lg_u64.src1_inline— an unsigned!=against an inline constant. That comparison does not appear literally in the source (index.cmp ultiss_cmp_lt), so lowering introduces it, most plausibly around the dynamic-bound loop termination, thescf.if %publish_wordregion, or the completion-counter protocol — all of which only reach that block oncepack_completed_q8is live.Next step: dump the Loom MLIR and read block index 162's unscheduled nodes 2354/2355, instead of guessing from the
.loom. Then the fix is a small source change on our side of the.loom, as the issue predicted.I have not touched any AMD Loom file, and have not opened a PR for this — it needs the IR dump first.
bong-water-water-bong commentedon Oct 5, 2026
The IR is not reachable through loomc's artifact API — so the next step changes
Following the localization above. I chased the "dump the IR" step so nobody repeats it.
loom-jit.cpp:943already asks loomc for the IR and a report on every compile:— but extracts them only on success. On failure it returns early and discards them. I patched that locally (env-gated dump, failure path only), rebuilt, and re-ran the repro. The report does dump, and it is not sufficient:
LOOMC_COMPILE_REPORT_MODE_DETAILSis the highest mode available (onlyNONE/SUMMARY/DETAILSexist), and it emits planning/memory facts, but every schedule counter is 0 —schedule_node_count,scheduled_node_count,schedule_dependency_count,schedule_band_row_count,schedule_hazard_gap_count— because the compile fails before scheduling completes.LOOMC_COMPILE_ARTIFACT_FLAG_MODULE_TEXTis documented as "after successful compilation", so a failed compile returns no textual module IR.So the failing kernel's IR cannot be obtained from loomc's public artifact API at any report mode. Getting it means instrumenting loomc itself (the Loom compiler in
hrx-system) to dump the module before the pass that fails — a compiler change, not a.loomchange.That reframes the issue's closing line slightly: the fix is still likely on our side of the
.loom, but the diagnosis needs the compiler instrumented first.If that is too deep a route, the alternative is to reason from the construct already identified: the cycle is
low.cond_brfeeding onamdgpu.s_cmp_lg_u64.src1_inline(an unsigned!=against an inline constant) inside thepack_completed_q8path that only goes live whenpublish_q8is true — i.e. look for the!=-terminated construct the lowering introduces there.bong-water-water-bong commentedon Oct 5, 2026
A validated way to test a
.loomfix — and one candidate ruled outTwo of my attempts at this produced no-op "results" that looked like findings. Writing down the trap, because it is invisible and it cost me two cycles:
kernel-corpus.cppincludes generated.incfiles (kernel-corpus-sources.inc,-qwen.inc,-catalog.inc), built from the.loomsources at build time..loomand re-running the tool changes nothing at all. That is what my first two runs did — they returned byte-identical diagnostics, including after I injected a deliberate syntax error, which is what eventually exposed it..loomfails it (FAILED: [code=1] …kernel-corpus-sources.inc).The procedure whose results mean anything:
.loom;rc=0and zero hard errors — a failed build leaves the previous.soand the old embedded corpus, producing an unchanged diagnostic that reads exactly like "the fix didn't work";Ruled out: the two dynamic-bound
unrollloops inpack_completed_q8Baseline clean (build
rc=0, 0 hard errors, repro still hits the cycle). Thenunrollwas removed from bothscf.forloops inpack_completed_q8; buildrc=0, 0 hard errors, so the change was genuinely compiled in. The repro returned an identical diagnostic:Not the cause. Tree restored with
git checkout(diff 0).Where that leaves it
The cycle's operand,
amdgpu.s_cmp_lg_u64.src1_inline, is an unsigned!=against an inline constant that does not appear in the.loom— lowering introduces it, and it is not the unroll loops. The IR is not obtainable through loomc's artifact API at any mode (see above), so the next candidate has to come from readingpack_completed_q8for that!=-shaped construct, or from instrumenting loomc itself.Everything above is on the pinned tree (
llama.cpp 522dab4,hrx-system 98d05d94), repro256 256 24 4 1 1024 1000.bong-water-water-bong commentedon Oct 5, 2026
Second candidate ruled out — with all preconditions asserted this time
Two candidates are now eliminated by valid tests. The second one, and the method that makes it trustworthy:
Hypothesis. The cycle operand is
amdgpu.s_cmp_lg_u64.src1_inline— an unsigned!=against an inline constant. The one construct inpack_completed_q8that lowers that way is a divisibility assume:Result — not the cause:
The constraint appears in 7 places, not one, so any fix there would have to cover all seven.
On method, because it is the actual lesson here. Four earlier attempts produced "results" that were no-ops:
.loomwithout rebuilding — the corpus.incis generated at build timediff=0Every one looked like "hypothesis falsified". The defect was identical each time: a gate that checked build health but never checked that the intervention happened. The test now asserts five preconditions and aborts loudly on any: tree clean · baseline build clean · baseline reproduces · intervention changed the tree · post-intervention build clean.
So this issue currently stands at: two candidates eliminated with evidence, the live path pinned to
pack_completed_q8'spublish_q8branch, and the IR unreachable through loomc's artifact API at any report mode.bong-water-water-bong commentedon Oct 5, 2026
Third candidate ruled out — the extra
publish_q8barriersThree candidates are now eliminated, each by a test whose preconditions were asserted. Summary, and the one that matters most for method:
unrollloops inpack_completed_q8mul(...)divisibility assume onvalue_head_size(all 7 sites)publish_q8branch (cooperative_f32)Candidate 3 was the strongest hypothesis so far —
amdgpu.s_cmp_lg_u64is an unsigned 64-bit!=, the natural shape of a barrier's "wait until the count reaches N" test, andpublish_q8 = trueemits exactly two barriers the false path never does, which would explain the gating without special pleading. It is wrong:On method, because it is now the load-bearing part. The first attempt at candidate 3 aborted — the barrier block is identical in all three
reduce_fusedspecializations, so an unanchored replace matched 3 and the precondition refused to emit a verdict. Compare that with attempt 4, which hit the same class of problem and printed "BUILD OK → change compiled in" whilediff=0. Two of the five attempts would have been reported as findings under the old harness.So: the failure stands at block 162 with 39/41 nodes scheduled and the
low.cond_br↔amdgpu.s_cmp_lg_u64.src1_inlinecycle, gated onpublish_q8 = true. The IR is unreachable through loomc's artifact API at any report mode, so the next step is either a fourth hypothesis or instrumenting loomc itself — not another.loompoke.bong-water-water-bong commentedon Oct 5, 2026
The IR is obtainable —
loom-compilehas--dump-ir-*flagsThis issue's blocker is recorded as:
The first half is true; the conclusion does not follow. That was established against loomc's artifact/report API, but
the tool has a separate pass-pipeline IR tracer. From
loom/src/loom/tooling/pass/trace_cli.h:loom-compile.clinksloom::tooling::pass::trace_cliand callsloom_tooling_pass_trace_open_from_flags(...), andloom/src/loom/pass/trace.hdocuments the mechanism:with
LOOM_PASS_TRACE_FORMAT_TEXTandLOOM_PASS_TRACE_FORMAT_JSONL, and a configurablepointofBEFORE/AFTERper invocation.So the cycle's IR should be capturable directly:
which per the usage line writes
trace.jsonlplusir/*.loom— the whole module at each pass boundary, includingwhatever stage the scheduler's dependency analysis runs in. That is precisely the artifact whose absence was blocking
this issue, and it means the likely route is a flag, not instrumentation.
I have not run it yet, and I want to be explicit about that rather than present a flag list as a result: the box is
executing a long GPU evaluation, and this repro needs the failing kernel compiled. So treat the above as a corrected
statement of what is possible, not as a capture. What I have verified is the flag surface in the source: the usage
string,
loom-compile.c's call intoopen_from_flags, and the trace header's before/after boundary semantics.What this changes for the issue:
which is a debugging task with the evidence in hand, not a compiler-instrumentation project.
Worth correcting in the issue body so the next person does not burn time on instrumentation that already exists in
tool form.
bong-water-water-bong commentedon Oct 5, 2026
The IR dump works — but this repro needs the runtime's compilation unit, not a standalone compile
Following my previous comment, I ran it rather than stopping at the flag list. Both halves are worth recording.
The dump mechanism works. Compiling this kernel with
--dump-ir-after-all --dump-ir-format=textproduced a 3.4 MBartifact containing 27 pass-boundary IR snapshots:
So the IR is obtainable, and my previous comment stands on that point.
But a standalone compile does not reproduce this issue. It fails earlier, with a different error:
That is a missing provider, not a scheduler cycle. The kernel calls into
@ggml.quantize_q8_1_x4.publish_vector4,whose
template.deflives outside this file, so compiling the.loomon its own never reaches the pass where thelow.cond_br ↔ amdgpu.s_cmp_lg_u64cycle appears. The compile ran with the repro's parameters(
key_value_token_capacity=1024, which does selectcooperative_f32).So the correct correction to my previous comment is narrower than I implied. The pass-trace exists and works, but it
is reached through
loom-compile, and the failing compile in this issue happens inside the runtime's in-processcompile — the JIT path that has the private add-on's providers in scope. Two consequences:
single
.loom. I have not established what that bundle is; the add-on's kernel sources would be the place to look.loom-compilegets themthrough
loom_tooling_pass_trace_open_from_flags, but the loomc compile API used in-process does not obviously exposea trace field — which is the one place the earlier "instrumentation may be needed" instinct could still be right, now
for a much narrower reason than before.
Net effect on the issue: the blocker is still false — the IR is obtainable — and the expensive guesswork is still
avoidable. But the input to the dump must be the runtime's compilation unit, and reproducing the cycle with
loom-compile kernel.loomalone will not work. That is a much smaller unknown than "the IR is unreachable".Artifacts preserved at
~/lb/ir314/per-pass-dump.txt(3.4 MB),bare.log,dump.logon strixhalo.bong-water-water-bong commentedon Oct 5, 2026
Five capture attempts mapped the toolchain — here is the input problem, precisely
Following my earlier correction (the IR is obtainable), I tried to actually capture it. Five attempts, each costing a
compile cycle and revealing one more requirement. None reached the IR, but the map is worth having.
.loomLOWERING/045: template.apply @ggml.quantize_q8_1_x4.publish_vector4unresolvable — a bare file carries no template implementationsloom-libs/**as--libraryno_provider; my root grep had matched a_body_symbolqwen_moe/qwen3_moe/flash_attention_decode_split_f32_f16_wmma.loomHAL backend 'amdgpu-hal' requires at least one kernel entry— a_body_root materialises no entry@qwen3_moe_flash_attention_decode_split_f32_f16_wmma_next_q8template_selection.c:1546 FAILED_PRECONDITION; 1 reachable template applications remain unresolved.loomin the corpus (122) as providersplanner.c:496 NOT_FOUND; unresolved exact declaration '@qwen3_moe_flash_attention_decode_split_f32_f16_wmma_next_q8'What is now established — this is the useful part:
kernel-corpus/kernels/{qwen,qwen_moe,hrx,loom-libs}.loom-libsholds the shared templates(the providers); the concrete kernels live under
qwen_moe. Attempts 1-2 were compiling a template as if it were thekernel, which is why the provider would not resolve.
@qwen3_moe_flash_attention_decode_split_f32_f16_wmma_next_q8, and the same directorycontains a separate
flash_attention_decode_split_next_q8_test.loom— plausibly where that variant is definedrather than referenced. That is the most likely next input, and the cheapest thing to try.
kernel-corpus-sources.incis 17 MB ofLOOM-magicbytecode (
0x4c,0x4f,0x4f,0x4d), i.e. the engine's own compilation unit is a frozen bytecode corpus. Reproducingthat from
.loomtext may not be equivalent, which would explain why resolving providers by hand keeps failing.Why I am stopping, and what stands. Each attempt reveals one more requirement with no bounded end in sight, so I would
rather leave an accurate map than another half-attempt. The earlier correction stands unchanged: the IR is not
unreachable —
--dump-ir-after-allworks and produced 27 pass-boundary snapshots. What is missing is the right input,and the likeliest candidate is now named. Whoever picks this up should start with
flash_attention_decode_split_next_q8_test.loom, and if that fails, treat the bytecode corpus as the real unit andeither extract it or add the trace to the runtime's in-process compile path instead.
Artifacts:
/tmp/ir314{e,d,c}/on strixhalo hold each attempt's link/compile logs.bong-water-water-bong commentedon Oct 6, 2026
The real blocker: I was driving a v34 toolchain against a v38 corpus
Six attempts in, the answer was in the very first error line and I misread it as another thing to work around:
and one line of source:
~/hrx-sdk-pin/bin/loom-compileis built from an older hrx-system than the engine pins, so it cannot read theengine's frozen bytecode corpus. The corpus is v38; that tool expects 34.
This retro-explains every earlier failure, which is the useful part:
.loomfiles linked to only 6 KB and resolved no template bodies — not because they are"planning-grade" (my hypothesis) but because that text and that tool are from different revisions.
no_providerkept appearing for families the manifest names explicitly — version skew, not a missing input.loom-linkbut noloom-compile— which is exactly why nothinglocal could compile the corpus.
So the fix is a matching toolchain, not more input archaeology. Build
loom-compilefrom the engine-pinnedhrx-system
98d05d94(the tree that defines version 38) — I have that build running incrementally in the engine's ownloom build directory, since the v38
loom-linkis already there — then compile the frozen corpus with--dump-ir-after-all. Pairing a corpus with tools of a different revision, as I did, measures only the mismatch.What stands from all of this, and it is worth keeping:
--dump-ir-after-allis real, documented in the tool's own help, and was demonstratedproducing pass-boundary snapshots.
manifest.jsonis the specification —link_modulesgives each module's exactsrcs+libraries(which is how I learned the provider is
ggml/quantize_q8_1_x4.loominggml/, not inloom-libs/), andplan_casesgives the exact config namespace (
qwen3_moe.attention.*, notggml.flash_attention.*).kernel-corpus-sources.incis 17 MB ofLOOM-magic arrays; Iextracted the three flash-attention ones (
kernel_source_{42,107,108}_*) as a first step before hitting the versionerror, so that path is prepared.
Lesson I'd rather state plainly than bury: the first
BYTECODE/002was already the answer. I treated a versionerror as an input error, and six compile cycles followed from that. Reading the error literally would have cost one.
bong-water-water-bong commentedon Oct 6, 2026
Addendum: don't try to reconfigure the engine's loom build — it will not relink
Following the version-skew finding, I tried the obvious fix on the engine's own loom build:
no work to dois the point. Turning the option on adds no dependency to theloom-compiletarget in thatconfiguration, so the tool is never relinked and still rejects
--backend. That build exists to embed loom as alibrary (for ggml-hrx); its command-line tool is incidental and does not carry the emit backends, flag or no flag.
So no single loom build on this box satisfies both requirements, and none of them is broken:
~/hrx-sdk-pin/bin/loom-compileggml-hrx-deps-build/loom/…)What is actually needed is a third thing that does not exist here: loom's own tool build from the pinned hrx-system
98d05d94— the project's full tools configuration (bazel, or loom's top-level cmake with tools enabled), not theengine's dependency subset. That is a known-tree build, not research.
The capture recipe is complete and recorded, so whoever builds that one tool can run it immediately:
manifest.json→link_modulesforflash_attention_decode_split_f32_f16_wmma_next_q8_linked(
srcs: qwen3_moe/…_next_q8_test.loom;libraries: qwen3_moe/…_wmma.loom,ggml/quantize_q8_1_x4.loom)plan_cases— namespace isqwen3_moe.attention.*, notggml.flash_attention.*--dump-ir-after-all --dump-ir-format=text/tmp/ir314i/kernel_source_{42,107,108}_*.loomcon strixhalobong-water-water-bong commentedon Oct 6, 2026
The kernel compiles — the "fails to compile" framing looks like a runtime-config problem
Worked on this today. The headline: this kernel compiles cleanly, standalone, on a CPU-only box, to a real AMD code object. So the failure is not "loomc cannot compile this kernel".
Recipe. The compilation unit is not the kernel file — it is declared per kernel in the corpus manifest:
ELF 64-bit LSB shared object, AMD GPU architecture version 1,amdhsa.target = amdgcn-amd-amdhsa--gfx11-generic, and four real kernels:Why it failed before (controlled A/B):
LOWERING/045: no_providerfor@ggml.quantize_q8_1_x4.publish_vector4; no artifactlibrary_sources, no configLOWERING/045: missing_factsattemplate.apply<@ggml.flash_attention.decode_split.reduce_fused>— its provider requireswhere [range(%key_value_token_capacity, 64, 256)]and the launch shape is unknownlibrary_sources+ launch-shape configThe
template.applyargument comes from anindex.assume, so selection cannot resolve unless the launch shape is compile-time. Hypothesis: the runtime's in-process compile does not pass the launch shape as compile-time config, soreduce_fusedselection degrades tomissing_facts/no_providerand the backend emits no bytes — which matches "HSACO emits no bytes" far better than a scheduler cycle.Two corrections to the issue text:
s_cmp_lg_u64. This build producess_cmp_lg_i32.src1_inline(108 hits), notu64. It is not reachable from capacity 256 or 1024.low.cond_br(25,929) and*.src1_inline(5,677) are both present in the IR — and the kernel still compiles — so those two tokens being adjacent is not sufficient to cause the failure.--dump-ir-after-all, 148 snapshots), which the previous attempt could not reach.Not yet established: nothing has run on a GPU here, and the end-to-end symptom (scheduler stopped in block 162, 39/41 nodes, no bytes) is still unreproduced. Suggested next step is to instrument the runtime's compile call to record which config it passes, before chasing the scheduler cycle. Full write-up:
STANDALONE-REPRO.mdin the working notes.bong-water-water-bong commentedon Oct 6, 2026
Root cause:
amdgpu.sccregister exhaustion from twosubgroup.voteops — reproduced locally, no GPUCorrecting my earlier comment on this issue: I hypothesised the launch-shape config was missing. That was wrong. The runtime does supply it (
dispatch-flash-attention.cpp:632for the capacity,:397forqk_head_size/attention_scale). The config is necessary — without it the unit dies earlier atLOWERING/045— but it is not the cause.The real failure, at the release pin
522dab4, compiling the manifest-declared unit:…repeated for
…_next_q8and…_produce_partials_f32_f16_wmma. So this is register allocation on the SCC register failing, not a scheduler cycle. It also reads the reported symptom correctly:amdgpu.s_cmp_lg_u64.src1_inlineis how avotecomparison lowers andlow.cond_bris the branch consuming itss_cc— "cycle:low.cond_br↔s_cmp" is the allocator unable to satisfy two live SCC values against a budget of 1.Controlled A/B (the proof). The pin's kernel has exactly two votes:
BACKEND/005SCCbudget 1, peak 2, 0 bytesvote.anyremoved, one use aliased)rc=0, 128,512-byte code objectrc=0, 124,416-byte code object(The aliasing is a diagnostic, not a fix — it changes
anyintoall. A real fix must preserve the visibility logic.)Revision dependence.
c7aedf319(2026-09-30) has 0subgroup.voteops in this kernel and compiles cleanly to a 120,320-byte code object; the pin has 2 and fails. The votes were added between those revisions — that is the regression window, andgit log -pover that range onops/flash_attention_decode_split_f32_f16_wmma.loomwill name the commit.Repro (CPU-only, no GPU, deterministic):
Note the compilation unit is declared in the corpus manifest (
exports[] → compile_recipe:primary_sources+library_sources). Compiling the kernel file alone fails withno_providerfor@ggml.quantize_q8_1_x4.publish_vector4— which is what earlier attempts did, and why they concluded this needed a build it did not need.loom-compilealready exists.Fix options
amdgpu.sccvalues spillable, or materialise the vote result into a VGPR rather than holding it in SCC across the branch. Lives inhrx-system/loom(our fork).anywithout a second vote. Must preserve slot-visibility semantics.c7aedf319kernel shape (no votes), which compiles.Separate, smaller finding: at the pin,
dispatch-flash-attention.cpp:46claims the reduce kernel has "exactly two template.def implementations … Nothing covers above 2048". The corpus actually has three (multipass_f32covers 2049–262144), so the constantkDecodeSplitMaxKeyValueTokenCapacity = 32768is correct and the comment is stale. Acting on that comment (lowering it to 2048) would silently disable the split path for 2049–32768. Not this bug, but worth fixing so it does not mislead the next person.bong-water-water-bong commentedon Oct 6, 2026
Introducer named — and it is a correctness fix, so reverting is not free
Commit
e6187096(2026-10-02) — "ggml-hrx: masked KV rows reach flash-attention P*V as V = +0 (identical requests gave different logits)",+80/-5— adds exactly the two lines:e6187096...522dab4=ahead=54, behind=0, so it is an ancestor of the release pin, and it is the only commit touching that file betweenc7aedf319(0 votes → compiles to a 120,320-byte code object) and the pin (2 votes →BACKEND/005, 0 bytes).The important consequence: this commit fixed a nondeterminism bug — identical greedy requests in one
llama-serverprocess produced different logits because masked KV rows reached P*V asV = +0. So reverting the votes would reintroduce that determinism defect.This is the same item tracked separately as "the separate masked-V determinism item (masked keys changed output by ~1e-6, so identical requests diverged)". #314 and the masked-V determinism item are two faces of one commit — the fix for the determinism bug is what breaks the compile.
That makes the compiler-side fix the preferred one (make
amdgpu.sccspillable, or materialise the vote result into a VGPR rather than holding it live in SCC across the branch). It fixes the class and keeps the determinism fix. Inhrx-system/loom, our fork.bong-water-water-bong commentedon Oct 6, 2026
Blast radius, and the ops a fix would need
Blast radius: exactly one kernel. Scanned the pin's own tree (
git grepat522dab4; note a raw-SHA fetch is refused by GitHub, so I fetched1bit/hrx-vulkan-patchedto bring the object in). Of 123.loomfiles underkernel-corpus/kernels, only two contain any vote at all:loom-libs/ops/flash_attention_decode_split_f32_f16_wmma.loomqwen_moe/qwen3_moe/router_top8_f32.loomballot, which is SCC-freeSo no other kernel can hit this. The exposure is one kernel family.
(The same commit
e6187096also touchedops/flash_attention_f32_f16_wmma.loom, but that file has 0 votes at the pin, so its change is unrelated to this failure.)Ops a kernel-side fix needs — both confirmed present (in
hrx-system/loom/src/loom/ops/kernel/ops.h):so
vote.all(p)≡cmpi eq, ballot(p), active.maskandvote.any(p)≡cmpi ne, ballot(p), 0. Ballot results live in a general register (VCC/SGPR), not SCC, leaving the single SCC for the final branch.Caveat: the two votes use two different predicates (
%lane_tile_visibleusesscalar.oriof the outside/in-tile and key-visible terms;%lane_tile_has_visibleusesscalar.andi), so this needs two ballots, not one, and the active-lane semantics must be confirmed before landing. I deliberately did not land a rewrite — this kernel is correctness-critical and needs GPU validation, so I am leaving it as a precisely-scoped handoff rather than an unverified edit.Compiler-side alternative (fixes the class):
codegen/low/rematerialization.calready has a path keyed exactly onunspillable-register-exhausted(loom_low_allocation_failure_is_rematerializable_pressure), but it only acceptsLOOM_LOW_DESCRIPTOR_PACKET_OP/_CONSTpackets, so a vote feedingcond_bris out of scope. Widening that, or materialising the SCC into an SGPR, would fix any kernel that hits this. Note "make SCC spillable" is not literally possible: the class iscount=1, allocatable=1, PHYSICAL|UNSPILLABLE(registers_test.cc:218), which is physically right — AMDGCN has one SCC.26 remaining items
bong-water-water-bong commentedon Oct 6, 2026
The candidate fix is validated numerically — identical on the masked-KV check
I built the numerical gate the repro was missing (an equivalent of your
ggml-hrx-attn-masked-kv-check): two runs of the same decode-shaped graph that differ only in the V values of the masked rows. If the fix works, both outputs must be identical.kv=1024, first half visible, second half masked with F16-inf:out0=0.0100021362 sum=61.453125out0=0.0100021362 sum=61.453125out0=0.0100021362 sum=61.453125out0=0.0100021362 sum=61.453125Both are bit-identical across the two runs, and the candidate reproduces the current kernel's values exactly. So the shared-memory derivation is numerically equivalent on this check rather than merely compiling — which I could not claim before.
Two caveats, stated rather than buried:
-65504for masked keys when the threshold is< -1e30(F16-inf), and a V fill indexed[hsv][kv][nkv]instead of[hsv][nkv][kv]which scattered the masked values. Both produced a large spurious "leak" that I nearly reported as the bug. The numbers above are from the corrected program.Program and patch script are in the working notes (
fa314-candidate-fix.sh,fa314-masked-kv-check.cpp). Running yourggml-hrx-attn-masked-kv-check 256 256 24 4 1 1024 1000against it is still the authoritative gate — mine is an equivalent I wrote, not the same instrument.bong-water-water-bong commentedon Oct 6, 2026
Correction: the failure does not reproduce on demand — and it failed on the same digest
I have to correct something I posted, and the correction is more interesting than the claim.
What I claimed: that the emission failure was "intermittent", because the unfixed kernel failed on some runs and compiled on others. I measured it properly instead — 10 runs each, JIT cache cleared between every run:
and again in a freshly configured tree (
-B, so nothing carried over from this session's experiments), 5 more runs, cache cleared each time:So "intermittent" is not supported by the data. I withdraw it.
What is still true, and is the more useful fact: the failures I saw repeatedly in earlier rounds carried the same digest
f2541593794f05eaas the runs that succeed now. Same source, same digest, sometimes a scheduler failure and sometimes not — so whatever trips it is outside the kernel source: host-side compiler state, thread or hash ordering, something environmental. That is worth a report to the Loom side on its own, because a scheduler that non-deterministically fails to order the same input is a bug regardless of which kernel provokes it.What this means for the candidate fix. The shared-memory derivation:
out0=0.0100021362,sum=61.453125, both V signs, both kernels);low.cond_brfed by a subgroup collective).But I cannot demonstrate that it fixes the emission failure, because I can no longer make that failure happen on demand — not even in a fresh tree. So it is a plausible, numerically equivalent change, not a demonstrated fix. Anyone who can reproduce the failure — with a machine or a build where it triggers — can settle it in one run. I would not merge it on my evidence alone, and I would rather say that than leave a "validated" claim standing that the rate test does not support.
bong-water-water-bong commentedon Oct 6, 2026
The candidate fix is now a reviewable branch
Pushed as
1bit/fa-shared-visibilityon1bit-MONSTER/llama.cpp(f9ff06675af6) — one file, +102/-2 against the pin:ggml/src/ggml-hrx/kernel-corpus/kernels/loom-libs/ops/flash_attention_decode_split_f32_f16_wmma.loom.https://github.com/1bit-MONSTER/llama.cpp/tree/1bit/fa-shared-visibility
The commit message carries the evidence and the limits: it compiles and runs at the failing configuration; it is bit-identical to the voting kernel on an equivalent masked-KV check; and it is not verified against your authoritative tool — nor can I demonstrate that it fixes the emission failure, because that failure no longer reproduces for me even in a freshly configured tree.
Treat it as a candidate to test, not a fix to merge. If
ggml-hrx-attn-masked-kv-check 256 256 24 4 1 1024 1000behaves identically with and without it, the shared-memory read is the right equivalent; if not, the per-lane derivation is wrong and the.loomneeds restructuring instead (candidate 2 from my earlier comment).bong-water-water-bong commentedon Oct 6, 2026
PR opened for review: 1bit-MONSTER/llama.cpp#95
Draft PR, explicitly not to be merged on my evidence: 1bit-MONSTER/llama.cpp#95
One file, +102/-2 against the pin, with the verification and its limits in both the commit message and the PR body.
One CI note worth knowing before reading the red X:
build-cann.ymlfails on this branch — and on every other recent branch in the fork (1bit/amd-core-our-hrx,1bit/amd-sync-corpus-repair). It is pre-existing, not something this change introduced.bong-water-water-bong commentedon Oct 6, 2026
Second candidate pushed: always-stage, +6/-2, also bit-identical
Candidate 2 is implementable without restructuring the
scf.if— replace the two votes with constant predicates (all_visible = false,any_visible = true), so the kernel always takes the existing staging path and never issues a collective. Pushed as1bit/fa-always-stageon1bit-MONSTER/llama.cpp.(My first attempt inlined the staged branch by hand and loom rejected it: the staged
scf.yieldbelongs to an innerscf.if, so inlining turned it into a loop yield and the parser reportedundefined SSA value '%next_product_accumulator0'at line 377. The constant-predicate form sidesteps that entirely.)Same check for all three —
kv=1024, half the keys masked with F16-inf, two runs differing only in the masked rows' V:fa-shared-visibilityfa-always-stageThe trade-off, which I am not going to pick for you. Candidate 1 keeps the direct V path for tiles that need no masking and stages only where it must; candidate 2 is a quarter of the diff but pays the staging loop and two subgroup barriers on every key tile. So 1 is the fix if the direct path matters for decode throughput; 2 is the fallback if the priority is a small, obviously-correct change.
Neither is benchmarked: this box has no headroom for a throughput comparison (0 GB available), so any performance claim for either is reasoning, not measurement.
bong-water-water-bong commentedon Oct 6, 2026
Both candidates are now open as cross-linked draft PRs
1bit/fa-shared-visibility(+102/-2) — keeps the direct V path for tiles that need no masking1bit/fa-always-stage(+6/-2) — always stages; the smallest correct changeEach body now points at the other, with the trade-off stated. Both: no collectives, compile at the failing configuration, and give bit-identical output on the masked-KV check (
out0=0.0100021362,sum=61.453125).Pick one, not both — they are alternatives, not a stack. Neither is benchmarked (no machine headroom here) and neither is verified against
ggml-hrx-attn-masked-kv-check, which is the gate I cannot run.hrx: pin llama.cpp to the shared-memory FA tile visibility (engine#31…
hrx: pin llama.cpp to the shared-memory FA tile visibility (engine#31…
315: kernel lead resolved NEGATIVE - FA decode-split kernel is not th…
the fixture cost 392 s in CI; extract the function instead (self-revi…
release-check: payload-modes must REQUIRE the binaries it names, not …