Skip to content

serve: Hadamard-rotated Q4_0 files run on --device hrx too - #277

Merged
bong-water-water-bong merged 3 commits into
mainfrom
h32-hrx-serve
Oct 2, 2026
Merged

bong-water-water-bong merged 3 commits into
mainfrom
h32-hrx-serve

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Hadamard-rotated Q4_0 files (tools/hadamard_q4_0.py, stamped onebit.hadamard_q4_0 = 32) now run on --device hrx. Until now they ran on the lean ROCm route only.

Merge after the third_party/llama.cpp pin that includes fork #58: the bump to bd5b297 (fork #58-#61). Without #58 the HRX build doesn't rotate the activations, and output is garbage (PPL 550,134).

Changes

  • serve: accepts --device hrx for a rotated file and runs it on HRX0, with neither GGML_W4A4_TENSORS nor a process-wide Hadamard variable. Our llama.cpp reads the stamp itself (llama-hadamard, fork Lean: ROCmI4 on Vulkan (our ROCmFPX fork); the bump rebases our commit #58).

  • --device auto still picks ROCm for these files. No fast HRX prompt kernel decodes Q4_0 yet: the q8_1 x4 template covers Q4_K, Q5_K and IQ4_XS only, so H32 prompts take HRX's generic path.

  • H32 vs the UD-Q4_K_XL file on HRX: H32 is both less accurate and slower.

    Qwen3.8-27B on HRX0 KLD vs BF16 pp512
    H32 0.029 63.5 tok/s
    UD-Q4_K_XL 0.007 335 tok/s

    This route keeps existing H32 files working on HRX; for new HRX use the UD file is the better choice. Making H32 fast would take a Q4_0 branch in the wmmai8 prompt template (exact in-kernel scale and min, same 144 bytes per 256 weights as Q4_K). Nobody is working on that now.

  • Docs: docs/hrx.md gets a section and docs/lean.md a pointer.

HRX numbers

Qwen3.8-27B-Q4_0-H32 on HRX0, measured on fork #58:

PPL (wikitext-2, 40 × 512) 6.021
KLD vs BF16 logits 0.0292
Same top token 92.5%
pp512 63.5 tok/s
pp2048 62.4 tok/s
tg64 11.65 tok/s

The speed figures are from a build before #55.

Tests

  • tests/hadamard_route.sh: --device hrx → HRX0, with neither variable.
  • ctest -LE gpu: 19/19 pass.

🤖 Generated with Claude Code

The engine's H32 files (tools/hadamard_q4_0.py, onebit.hadamard_q4_0 = 32)
ran on the lean ROCm route only. Our llama.cpp now reads the stamp
(llama-hadamard, fork #58) and rotates the activations as a matmul, so serve
accepts --device hrx for them: HRX0, no W4A4 or Hadamard variables.

--device auto keeps ROCm for these files until HRX routes Q4_0 prompt
matmuls to a fast kernel: Qwen3.8-27B-Q4_0-H32 on HRX0 runs pp512 at 63.5
tok/s today (PPL 6.021, KLD 0.0292, same top token 92.5% vs BF16).

tests/hadamard_route.sh: --device hrx -> HRX0 with neither variable.
ctest -LE gpu: 19/19. docs/hrx.md gets a section, docs/lean.md a pointer.

Needs the third_party/llama.cpp pin that includes fork #58.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@context7

context7 Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Docs7 for 1bit-monster/engine

Result Status Action
Deployment ➖ Not used —
Content review ➖ Did not run. This site has no agent runs available this month. Wait for the monthly reset or check your Docs7 plan. —

Commit 2eca400

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review (PR-Agent duty). Correct.

Merge order: after bcloud-ae's third_party/llama.cpp bump to 68805cc (the one with #58). Without it, HRX output is garbage.

Direction note (owner, 2026-10-01: zero ROCm): auto keeping ROCm for these files is a temporary exception. Please list it in docs/hrx.md as debt, and move auto to HRX in the PR that routes Q4_0 prompt matmuls to the fast kernel.

bong-water-water-bong added a commit that referenced this pull request Oct 2, 2026
…mat SwiGLU, Hadamard Q4_0 (#278)

* Pin llama.cpp bd5b297: HRX remainder prefill, 32K+ prompts, mixed-format SwiGLU, Hadamard Q4_0

llama.cpp fork commits since 6e42b51 (figures from each PR, Qwen3.8-27B on HRX0, balanced mode):
- #61: q8_1 x4 prefill takes the 256-aligned head of a Q5_K/IQ4_XS remainder chunk.
  UD-Q4_K_XL pp400 67.4 -> 103.4, pp1862 172.1 -> 234.6 tok/s; KLD vs 6e42b51 0.00215,
  same top token 97.19%; MUL_MAT HRX0 287/287.
- #59: V stays row-major past copy_transpose_f16's 32768-row range. pp512 @ d32768 failed
  before, 227.4 tok/s now; a 34,816-token wikitext chunk gives PPL 6.2150.
- #60: K-quant SwiGLU decode stages separate gate/up codebooks. UD-IQ2_S tg128 3.12 -> 8.32;
  UD-Q4_K_XL unchanged; KLD 0.00013; test-backend-ops HRX0 996/996.
- #58: llama loads onebit.hadamard_q4_0 files through llama-hadamard (needed by #277).
  Q4_0-H32 vs BF16: PPL 6.021, KLD 0.0292, same top token 92.5%.

Docs: docs/hrx.md #55 section (remainders now covered for Q5_K/IQ4_XS) and "Our patches".
Registry regenerated (tools/registry_build.py; no mapping changes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs/hrx.md: the #61 figures were measured on 6e42b51 + #61 (a36d547) (review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: bong-water-water-bong <bong-water-water-bong@1bit.gg>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) October 2, 2026 04:55
@bong-water-water-bong
bong-water-water-bong merged commit ca7ea81 into main Oct 2, 2026
10 of 11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the h32-hrx-serve branch October 2, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant