Skip to content

Pin llama.cpp 8de144e: HRX MoE decode as a GEMV (ZAYA1-8B 46 -> 62 tok/s) - #218

Merged
bong-water-water-bong merged 1 commit into
mainfrom
pin/hrx-moe-decode-gemv
Sep 29, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
pin/hrx-moe-decode-gemv

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Moves third_party/llama.cpp 22ceda3 -> 8de144e (fast-forward), bringing 1bit-MONSTER/llama.cpp#32. It's the first step on RFC #213 gate 1 (HRX decode speed).

What: a one-token MUL_MAT_ID kernel for HRX (ops/mul_mat_id_decode_f32.loom, ours). It reads only the routed expert's rows, one wave64 per (row pair, token×slot), and reuses the decode GEMV's dequant loop. It's registered ahead of the batched WMMA mul_mat_id kernel for ≤ 4 tokens, and below the fused SwiGLU/postops paths and Qwen's routed-FFN kernels, which are unchanged.

Why: a dispatch profile of ZAYA1-8B decode (HRX_PROFILE_MODE=dispatch, read with iree-profile) showed the WMMA expert matmul at 40% of a token's device time, reading one expert per token at ~45 GB/s.

Measured on Strix Halo, HRX0 decode:

model before after
ZAYA1-8B Q4_K_M 46.3 tok/s 62.0 (+34%)
GLM-4.7-Flash Q4_K_M 22.1 25.3 (+14%)

Accuracy:

  • ZAYA1-8B tf_cmp32 is 69/96 on both paths.
  • Batch-1 perplexity against the CPU backend: ZAYA 32.86 vs CPU 32.83 (the old path gave 32.51); GLM 15.748 vs CPU 15.693 (old 15.696).

Details are in llama.cpp#32. Only the pin and registry/architectures.json change.

🤖 Generated with Claude Code

…xperts (ZAYA1-8B +34%)

Brings 1bit-MONSTER/llama.cpp#32: a one-token MUL_MAT_ID kernel
(ops/mul_mat_id_decode_f32.loom) that reads only the routed expert's rows,
ahead of the WMMA mul_mat_id kernel at <= 4 tokens. HRX0 decode: ZAYA1-8B
46.3 -> 62.0 tok/s, GLM-4.7-Flash 22.1 -> 25.3; ZAYA tf_cmp32 69/96 on both
paths; batch-1 perplexity within 0.1% (ZAYA) / 0.35% (GLM) of the CPU backend.

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

context7 Bot commented Sep 29, 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 959e065

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Version Mismatch

The llama.cpp (hrx) version in registry/architectures.json is updated to 8de144ee8c36494088ef0621f15090ca9192f2ec, but the PR description claims this is a fast-forward from 22ceda3ad7c97f5358b99f4fe0db42f5cf9f3bae. This discrepancy should be verified to ensure the correct commit is being used and that the fast-forward is indeed accurate.

"llama.cpp (hrx)": "8de144ee8c36494088ef0621f15090ca9192f2ec",

@bong-water-water-bong
bong-water-water-bong merged commit effbdbe into main Sep 29, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the pin/hrx-moe-decode-gemv branch September 29, 2026 05:02
bong-water-water-bong pushed a commit that referenced this pull request Nov 8, 2026
A number audit of the page against the measured results files (47 KLD/same-top-1
pairs, tolerance = half the last printed digit) found 45 matching a measured row and
2 that only match the superseded merged-form rows: both were in *current prose* in
the family summary, still claiming Zamba2-7B-Instruct's Q5_K_M clears the top-1 bar
at 0.01936 / 95.03 %.

That is no longer true: under the adapter form (fork #218) the same arm measures
0.019383 / 94.792 % at 32 chunks, misses the bar, and the sweet spot moved up to
Q6_K (0.010430 / 96.593 %). The two bullets now say so, and the historical pick is
labelled as the merged-form record instead of being presented as the current answer.

No other number moved: the remaining 45 pairs and every MiB figure in the current
tables match their results rows.
bong-water-water-bong pushed a commit that referenced this pull request Nov 8, 2026
…ter as open

The #1036 paragraph still ended by calling the per-layer FFN adapter 'cause 2 of
#1036 and ... a graph change, not a converter fix', written before fork #218
(21c814079) landed. A reader would take that as open work.

It is merged, and the consequence is on this same page: the adapter form is a
different (smaller, not bit-identical) artifact, so the Zamba2 rows are re-measured
in it and Zamba2-7B-Instruct's Q5_K_M is retired because it misses the top-1 bar
there. The paragraph now says both halves of #1036 are resolved and points at those
sections.
bong-water-water-bong pushed a commit that referenced this pull request Nov 8, 2026
…link instead

Fourth pass on the same three sentences, and the reviewer's argument is right: any
literal pin sha on this page has a shelf life shorter than the review loop. So the
page no longer asserts one:

- rows 45-48 said the Zamba graphs are 'not from the pin; yes at fork head
  6e42864a6'. Verified in the pinned tree (b970d85ba, fetched): conversion/zamba.py,
  zamba2.py, zamba2vl.py, src/models/zamba.py, zamba2.cpp all present and
  src/llama-arch.cpp carries 4 LLM_ARCH_ZAMBA* registrations. The rows now say
  'from the pin', which is what the tree says.
- the sentence naming a fork head is replaced by the rule that cannot rot: the pin
  is whatever 'git ls-tree origin/main third_party/llama.cpp' reports, with a dated
  verification beside it rather than a substitute for it.
- the c16424f56 literal survives only in the historical sentence that says the page
  used to carry it, which is the one form where a literal is honest.

Remaining shas on the page are historical identifiers (the merged PRs #203/#218, the
deleted bench build, the corpus commit) or file digests - not current-pin claims.
bong-water-water-bong added a commit that referenced this pull request Nov 8, 2026
…pter form) (#1405)

* docs: Zyphra family showcase - measured quantization sweet spots (adapter form)

Every number is measured: original weights at a recorded revision -> our BF16 GGUF
-> every arm quantized from that BF16 -> llama-perplexity --kl-divergence against
that BF16 on 16x512 wikitext windows (32 where the top-1 half of the bar sat inside
the noise), and a code slice on 8x512 windows for the four models that have one.
Bar = mean KLD <= 0.03 AND same-top-1 >= 95%.

What the page is explicit about:
- Zamba2 rows are the adapter form (fork #218, engine #1036 cause 2), re-measured
  because the merged-form files were superseded. That change moved Zamba2-7B-Instruct's
  sweet spot from Q5_K_M (which cleared the bar by 0.025 points and now misses it) to
  Q6_K, while Zamba2-2.7B-instruct's pick survived and its files shrank 9-11%.
- The throughput columns are marked not citable: the build they were measured on was
  removed from the box, and a 2026-11-08 control re-measured an unchanged file 2-2.9x
  away from its own published row, with 71% sd on decode.
- ZAYA1-VL-8B has no row and the page says why (the image-span attention mask is
  missing from the graph); ZAYA1-74B-preview is deferred on size.

No AMD-training claim except the ZAYA1 line, worded and sourced from Zyphra's reports.

* docs(zyphra): stop presenting the withdrawn 5-bit pick as current

A number audit of the page against the measured results files (47 KLD/same-top-1
pairs, tolerance = half the last printed digit) found 45 matching a measured row and
2 that only match the superseded merged-form rows: both were in *current prose* in
the family summary, still claiming Zamba2-7B-Instruct's Q5_K_M clears the top-1 bar
at 0.01936 / 95.03 %.

That is no longer true: under the adapter form (fork #218) the same arm measures
0.019383 / 94.792 % at 32 chunks, misses the bar, and the sweet spot moved up to
Q6_K (0.010430 / 96.593 %). The two bullets now say so, and the historical pick is
labelled as the merged-form record instead of being presented as the current answer.

No other number moved: the remaining 45 pairs and every MiB figure in the current
tables match their results rows.

* docs(zyphra): cause 2 landed too - stop describing the per-layer adapter as open

The #1036 paragraph still ended by calling the per-layer FFN adapter 'cause 2 of
#1036 and ... a graph change, not a converter fix', written before fork #218
(21c814079) landed. A reader would take that as open work.

It is merged, and the consequence is on this same page: the adapter form is a
different (smaller, not bit-identical) artifact, so the Zamba2 rows are re-measured
in it and Zamba2-7B-Instruct's Q5_K_M is retired because it misses the top-1 bar
there. The paragraph now says both halves of #1036 are resolved and points at those
sections.

* docs(zyphra): scope this page to measurements and hand conversion to zyphra-models.md

pi-zarch's review of #1405 found the real blocker: there are two Zyphra docs and
one is index-linked, so two tables of the same picks will drift (the Q5_K_M
retirement already had to be corrected once between lanes).

Taking their option (2): the family page owns what the files are and how to
convert/quantize them (sizes, the --tensor-type ffn_gate_up_adapter=f16 trap,
layout asserts, input-layer placement); this page owns what the arms measure.
Neither repeats the other's tables, each links the other. This commit is only my
half - the scope statement and the cross-link.

* docs(zyphra): finish my half of the split - drop duplicated ref sizes, name the quantizer mechanism

Both edits follow from the agreed split with zyphra-models.md (pi-zarch's review,
option 2):

- the byte-level ref sizes and tensor counts are that page's subject, so mine now
  keeps only what a measurement needs (that cause 1 rebuilt the refs and the KLD
  rows were unaffected) and points there for the table;
- the throughput caveat gains the third reason those numbers are not citable: a
  quantizer older than the F16 default quantizes the rank-128 adapter pair, whose
  B matmul then leaves HRX on every hybrid layer (block formats need
  input_size >= 256, the float path only % 4) with no error. That is documented
  with numbers and the --tensor-type remedy on the family page; here it settles
  why a tok/s row is inseparable from which quantizer built the file.

* docs(zyphra): say why the two code cells are still pending, with the measured blockers

The reason has changed since it was first written. It was 'stopped to stop
starving the GPU queue'; the attempts since then were refused by preconditions
that are worth naming because they are the box's, not the code's:

- a 4-core thermal-run job measured 0.19 of one core while three scopes shared
  the same pinned cores (an arm that takes 8-11 minutes took >40);
- and today there is not enough free RAM for a 7B perplexity to load (~7 GiB
  needed against ~4 GiB available).

Cells stay marked rather than filled from a neighbouring window.

* docs(zyphra): quote the produced adapter types, not the requested ones

pi-zarch corrected my reading of their trap with code, and they are right: HRX
admits block formats at input_size >= 256 and float formats at >= 4, so the
adapter's B pair ([128, 28672], input_size = 128) leaves the device for ANY block
type - including the Q8_0 the quantizer substitutes when the requested block does
not fit. My 'q8_0 handles k=128' was wrong: the block size is not the gate, the
input_size threshold is.

So a reader cannot fix this by asking for a block type explicitly, and the useful
recipe is the one they suggested: report the types actual read from the produced
file (_a = Q6_K / _b = Q8_0 for the q6_K request), which is this page's
'labels are not evidence' rule applied to the tensors inside the file.

* docs(zyphra): measure the last two code cells - the code table is now complete for all four models

Zamba2-7B-Instruct, adapter form, 8x512 code-slice windows against the same
base-code.kld as the other rows:

  Q6_K  0.003939 / 98.186 %   (wikitext 0.010430 / 96.593 %)
  Q8_0  0.000488 / 98.971 %   (wikitext 0.001669 / 98.603 %)

So all four models now have both corpora measured for every pick, and the 7B's
code column behaves like every other arm's: better than wikitext, with the same
ordering. The pending-note becomes the history of why it took four attempts - CPU
starvation (0.19 of one core) and RAM (under 6 GiB for a ~7 GiB load) - which is a
fact about this box, not about the files.

* docs(zyphra): the quantizer trap is now measured here, 8.1x at pp8, and say what the histogram cannot see

Two arms that differ only in the adapter tensors' type, benched back to back in
one ticket: F16 pairs 114.19 tok/s vs Q6_K/Q8_0 pairs 14.03 at -p 8 (8.1x for a
50 MiB difference), which upgrades 'most likely explanation' to a measurement and
states plainly that the shape is launch-dominated, not the ~1.3x the same trap
costs at pp512.

Also recorded because it cost me a wrong prediction: the dispatch registration sets
of the two arms were near-identical (one extra line, none missing). The log names
registrations that DID run, so an op that never dispatches on HRX leaves no line -
a fallback appears in the timing, not in the registration set.

* docs(zyphra): fix a typo in the sentence I just added

* docs(zyphra): the trap costs 5.4x at pp512 here, measured on the comparable shape

Second run of the same A/B at -p 512, so the number can be compared with the
1.27x the lane that found the trap reports on its own build:

  pp8    F16 114.19  ->  block-quantized  14.03   (8.1x)
  pp512  F16 145.09  ->  block-quantized  26.63   (5.4x)
  tg128  F16  16.50  ->  block-quantized  10.24   (not a stable reading)

5.4x at the shape that matters, for a 50 MiB difference in a 5.8 GiB file, arms
identical otherwise. The magnitude is file- and shape-dependent (1.3x on their
build, 5.4x here); the direction and the cause are not.

* docs(zyphra): address the four review items at fb65273

1. the throughput table no longer bolds the retired merged-form pick:
   Zamba2-7B-Instruct Q5_K_M is labelled '(merged-form pick, retired)' and the
   legend says the adapter form's sweet spot (Q6_K) has its own row coming from
   the re-bench in flight - so no ranking is to be read from a bold cell there;
2. the page is now reachable: one link from zyphra-models.md's 'what to publish'
   section, which is where a reader choosing a file already is;
3. tg128's ratio is stated by the same F16-over-block convention as the prefill
   rows, 1.61x rather than '0.6x' (which read as the block arm being faster);
4. pp512 is labelled 'direction stable, magnitude not' with both arms' CVs
   (55% / 32%), and pp8's 8.1x the same way - the ratio is an order of magnitude,
   not a measured multiple.

* docs(zyphra): the 7B adapter-form row is missing on purpose, with the numbers that say why

The re-bench landed but cannot join the table: every row in it came from build
9ad387fb9 (deleted), the re-bench ran on a3e8d42c9, and two of its three figures
prove the difference is the build, not the file:

  7B Q6_K   pp512 5.09   pp4096 12.54   tg128 18.55   (pp512 below pp4096 - a
            first-test warmup cost, i.e. not a property of the file)
  2.7B Q6_K pp512 535.93 pp4096 97.03    tg128 45.07   (pp4096 3.9x the 25.10
            this table carries from the old build)
  2.7B Q8_0 pp512 686.74 pp4096 91.57    tg128 21.16

So the row stays out, the footnote carries the numbers and the reason, and the
2.7B's 25 -> 97 between builds is recorded as the size of the error a mixed column
would have introduced. Window itself was controlled: its own logs moved 37.5 ->
39.9 GiB.

Also fixed in the harness: the GTT control assertion globbed every
bench-*-adapter.log on disk and judged this window with a previous window's
readings (it called a 2.4 GiB move 'NOT controlled'). It now reads only this
run's logs, timestamped at window start.

* docs(zyphra): stop asserting the pin - read it from the submodule gitlink instead

Fourth pass on the same three sentences, and the reviewer's argument is right: any
literal pin sha on this page has a shelf life shorter than the review loop. So the
page no longer asserts one:

- rows 45-48 said the Zamba graphs are 'not from the pin; yes at fork head
  6e42864a6'. Verified in the pinned tree (b970d85ba, fetched): conversion/zamba.py,
  zamba2.py, zamba2vl.py, src/models/zamba.py, zamba2.cpp all present and
  src/llama-arch.cpp carries 4 LLM_ARCH_ZAMBA* registrations. The rows now say
  'from the pin', which is what the tree says.
- the sentence naming a fork head is replaced by the rule that cannot rot: the pin
  is whatever 'git ls-tree origin/main third_party/llama.cpp' reports, with a dated
  verification beside it rather than a substitute for it.
- the c16424f56 literal survives only in the historical sentence that says the page
  used to carry it, which is the one form where a literal is honest.

Remaining shas on the page are historical identifiers (the merged PRs #203/#218, the
deleted bench build, the corpus commit) or file digests - not current-pin claims.

---------

Co-authored-by: pi-zquant <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant