Skip to content

hrx: ZAYA CCA convolution at decode in one dispatch (ZAYA1-8B decode 72 -> 81 tok/s) - #39

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/zaya-cca-conv-decode
Sep 29, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/zaya-cca-conv-decode

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Part of RFC 1bit-MONSTER/engine#213 gate 1 (HRX decode within 10% of Vulkan; ZAYA1-8B Vulkan is 93 tok/s).

Why. ZAYA's CCA convolution is ~35 graph nodes and 13 dispatches per layer at decode: 68 µs of a 328 µs ZAYA1-8B layer (21%). The steps:

  • concat Q and K;
  • append them to the two-step conv state, and write the state back;
  • a depthwise 2-tap conv plus bias;
  • per group of 128 channels, a 2-tap grouped conv (two F16 matmuls), their sum, and a bias.

ops/zaya_cca_conv_decode_f32.loom does all of it in one dispatch (6.9 µs), one wave64 per output channel reading contiguous F16 weights.

Matcher. dispatch-zaya-cca-conv.cpp matches the exact decode structure (one token, one sequence), rooted at the Q/K concat, and leaves prefill and multi-sequence batches to the generic path. The code is in our own files; hookups are the manifest, dispatch-common, and CMake.

Loom workflow (Ben Vanik's gist). The .loom file includes a plain reference kernel and two check.case differentials: an exact constant case, and a random-input comparison against the reference. Both pass under iree-test-loom --device=amdgpu --sanitizer=access with hrx-system 244cd38, whose stricter rules (constant divisors, proven bounds) the kernel already meets.

Checked on strixhalo (gfx1151), ZAYA1-8B Q4_K_M, HRX0, fused vs GGML_HRX_DISABLE_DISPATCH=zaya.cca_conv in the same binary:

plain fused
dispatches per token 3,045 2,565
token span (profile) 17.95 ms 15.90 ms
decode tg128, 3 interleaved rounds 72.1 / 72.2 / 71.7 81.2 / 81.0 / 80.8 tok/s
teacher-forced top-1 vs transformers FP32 69/96 69/96
batch-1 wikitext PPL, 4×512 (CPU: 34.30) 33.31 33.49

Not bitwise. The kernel accumulates in its own order, so greedy text diverges after 8-43 tokens on 4 of 6 test prompts. Accuracy against the FP32 reference is unchanged.

🤖 Generated with Claude Code

ZAYA's CCA convolution (concat Q and K, append them to the two-step conv state
and write the state back, a depthwise 2-tap conv plus bias, then per group of
128 channels a 2-tap grouped conv as two F16 matmuls, their sum and a bias) is
~35 graph nodes and 13 dispatches per layer at decode: 21% of a ZAYA1-8B layer
(68 us of 328 us). ops/zaya_cca_conv_decode_f32.loom does it in one dispatch,
one wave64 per output channel reading contiguous F16 weights;
dispatch-zaya-cca-conv.cpp matches the exact decode structure (one token, one
sequence) from the Q/K concat and leaves prefill and several sequences to the
generic path. Hookups: manifest, dispatch-common, CMake.

The .loom file carries a reference kernel and two check.case differentials
(an exact constant case and a random-input comparison with the reference);
both pass under iree-test-loom --device=amdgpu --sanitizer=access with
hrx-system 244cd38, which also enforces constant divisors and proven bounds.

ZAYA1-8B Q4_K_M, HRX0 (gfx1151), fused vs GGML_HRX_DISABLE_DISPATCH=zaya.cca_conv:
- dispatches per token 3,045 -> 2,565; token span 17.95 -> 15.90 ms;
- decode tg128, 3 interleaved rounds: 72.1 / 72.2 / 71.7 -> 81.2 / 81.0 / 80.8 tok/s;
- teacher-forced top-1 vs transformers FP32: 69/96 both;
- batch-1 wikitext perplexity (4 x 512, every token through the kernel):
  33.31 -> 33.49 (CPU backend 34.30). Not bitwise: the kernel accumulates in
  its own order, so greedy text diverges after 8-43 tokens on 4 of 6 prompts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant