Skip to content

Zyphra Zamba v1 on Vulkan, and a converter fix for SentencePiece-style tokenizer.json vocabs - #117

Merged
bong-water-water-bong merged 2 commits into
mainfrom
zamba1
Sep 26, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
zamba1

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Next step of Zyphra-family support. third_party/llama.cpp-vulkan → 1bit/vulkan-upstream ee6e4e0d (the current adb2af5d + two commits of ours):

5319c0e6 model: Zamba v1 (Zyphra/Zamba-7B-v1), our code in src/models/zamba.cpp / conversion/zamba.py:

  • Mamba-1 layers split into 2 heads with their own x_proj/dt_proj (batched matmuls); B/C enter the scan as groups, on the Vulkan Mamba-1 scan from Vulkan: Mamba-1 selective scan on the GPU #116.
  • One shared transformer block on concat(h, embeddings), no RoPE, attention scale (head_dim/2)^-0.5, erf-GELU gated MLP; stored once, every hybrid layer points to it (duplicating it would have added ~4.6B parameters).
  • Converter de-interleaves in_proj's [x, gate] rows and writes A = -exp(A_log).

ee6e4e0d gguf-py: LlamaHfVocab scores from the merge ranks — an upstream converter bug: models with only a SentencePiece-style BPE tokenizer.json (Zamba, Zamba2, …) got every token score -1000, so llama.cpp's SPM tokenizer picked merges arbitrarily.

Check (Strix Halo) Result
Zamba-7B-v1 Q8_0, teacher-forced top-1 vs transformers FP32 (3 prompts × 32) 96/96
Greedy continuations vs the reference identical
Tokenizer vs HF, wikitext-2 (1500 lines) before 318/1500, after 1500/1500
llama-bench Q8_0 pp256 543, tg64 14.9 tok/s; 2 graph splits (all compute on Vulkan0)
registry_check PASS Zamba-7B-v1, PASS Zamba2-1.2B-instruct (reconverted)

Registry: ZambaForCausalLM → vulkan. docs/vulkan.md lists both commits and says to reconvert Zamba/Zamba2 GGUFs made before ee6e4e0d.

🤖 Generated with Claude Code

…e tokenizer.json vocabs

third_party/llama.cpp-vulkan -> 1bit/vulkan-upstream ee6e4e0d (adb2af5d + two
commits of ours):

- model: Zamba v1 (Zyphra/Zamba-7B-v1). Mamba-1 layers split into two heads
  (per-head x_proj/dt_proj; B/C enter the scan as groups, on the Mamba-1
  Vulkan scan from #116) plus one shared transformer block on
  concat(h, embeddings), no RoPE, stored once. Teacher-forced top-1 vs
  transformers FP32: 96/96; greedy continuations identical; pp256 543,
  tg64 14.9 tok/s, all compute on Vulkan0.
- gguf-py: LlamaHfVocab gave every token score -1000, so llama.cpp's SPM
  tokenizer picked merges arbitrarily for any model with only a
  SentencePiece-style BPE tokenizer.json (Zamba, Zamba2, ...): Zamba-7B-v1
  tokenized 318/1500 wikitext lines like HF. Scores are now -rank of the
  producing merge: 1500/1500. Upstream bug; GGUFs converted before need
  reconverting.

registry: ZambaForCausalLM -> vulkan; registry_check PASS for Zamba-7B-v1 and
the reconverted Zamba2-1.2B-instruct. docs/vulkan.md lists both commits.

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

context7 Bot commented Sep 26, 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 c593829

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit c593829)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

116 - Partially compliant

Compliant requirements:

  • Vulkan SSM_SCAN for Mamba-1 implemented
  • Mamba-1 layers now run on GPU
  • Performance measured and documented (pp256 228 → 6736 tok/s, tg64 25.8 → 173.5 tok/s)
  • Greedy completions verified as identical
  • Test-backend-ops cases added

Non-compliant requirements:

  • None

Requires further human verification:

  • Hardware performance verification on Strix Halo
  • Manual confirmation of test-backend-ops cases
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Documentation Inconsistency

The documentation mentions that Zamba v1 was converted with the ee6e4e0d commit, but the registry shows that the Vulkan source was updated to ee6e4e0d in the architecture mapping. This could be confusing for users trying to trace the exact commit that introduced Zamba v1 support.

Zamba v1 (`ee6e4e0d`), `Zyphra/Zamba-7B-v1` Q8_0: teacher-forced top-1 vs transformers FP32 **96/96** on three prompts; greedy continuations identical to the reference's; pp256 543, tg64 14.9 tok/s; 2 graph splits (all compute on Vulkan0: each layer's two-head scan runs on the Mamba-1 Vulkan kernel from `adb2af5d`). GGUFs of Zamba or Zamba2 converted before `ee6e4e0d` have the broken token scores: reconvert them.
Architecture Mapping Update

The architecture mapping for ZambaForCausalLM is added to the Vulkan backend, but the change in the number of architectures and mapped entries suggests that this might be an unintended side effect of the update. It's important to confirm that this change is intentional and doesn't introduce any regressions.

"ZambaForCausalLM": {
 "gguf": "zamba",
 "backends": [
  "vulkan"
 ]
},

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit c593829

@bong-water-water-bong
bong-water-water-bong merged commit db0c036 into main Sep 26, 2026
5 checks passed
bong-water-water-bong pushed a commit that referenced this pull request Oct 20, 2026
…, G8 #12); --parallel on qwen35 family

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Oct 20, 2026
…ily (#480)

* serve: the placement report covers every graph, not just the warmup

--placement-report passed GGML_HRX_REPORT=1, and the backend's 1 is the
first graph only, so serve printed a clean report for a model that leaves
nodes on the CPU in later graphs: the 20 Oct census found LFM2 --parallel 4
(20 nodes, 5 splits) and ZAYA1-8B (1-3 nodes) reading "all nodes on HRX".

Ask for every graph (2), keep the worst one instead of the last, and print
serve's line again whenever a graph is worse than every graph before it,
with the graph count. --strict-device reads the same worst graph. Without
--placement-report serve keeps 1, so no log volume is added by default.

tests/hrx_placement_test.cpp covers a clean warmup followed by a par4 graph
and a later clean graph.

Co-Authored-By: Claude Opus 5 <[email protected]>

* serve: --strict-device reads the report it needs

--strict-device only passed GGML_HRX_STRICT=1 to the backend. It did not pass GGML_HRX_REPORT=2 and it
did not add the -lv 4 that lets llama-server's log level carry the placement report through, so the graph
that would have been refused was never reported and serve fell through to "the backend printed no
placement line" while starting normally. Both flags are now treated the same way: GGML_HRX_REPORT=2 and
-lv 4 whenever either is set, so the refusal reads the same worst graph that --placement-report prints.

Found on device: `1bit serve ... --strict-device --parallel 4` (LFM2-1.2B) answered requests instead of
refusing, with that "no placement line" message in its log.

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

* serve: --parallel on qwen35 / qwen35moe / qwen3next

These architectures were refused with "--parallel on --device hrx does not run <arch> yet (no
multi-sequence gated delta-net on HRX)". That was true when the HRX gated-delta-net matchers held
kMaximumSequences 3; they hold 8 now (llama.cpp 1bit/hrx-gdn-multi-sequence), and a four-sequence run keeps
every node on the device.

Measured on Qwen3.8-27B UD-Q4_K_XL, `--parallel 4`, four concurrent chats: 4 of 4 answered, placement "all
3655 nodes on HRX, 1 graph splits", zero error lines. The forced `-np 1` for these architectures when
--parallel is not given stays: llama-server's own default opens several slots, and that is a different
question from the explicit flag.

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

* Pin llama.cpp cefbfc07 (fork #117, G9) and gpu-kernels 421d7a4e (G7 #11, G8 #12); --parallel on qwen35 family

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

* registry: regenerated at llama.cpp cefbfc07

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

* Pin llama.cpp dcf8c1ec (fork #118: narrower GDN claim) and gpu-kernels 449a809e (#13: v_f16 ABI + f16-V read fixes)

Fixes this PR's first hw-gate run (ops 618/649, Coder-30B HTTP 500).

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

* registry: regenerated at llama.cpp dcf8c1ec

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

---------

Co-authored-by: bcloud <bcloud@localhost>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: bcloud <[email protected]>
Co-authored-by: bong-water-water-bong <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Nov 21, 2026
…n (engine#3125) (#3148)

* serve: gated delta-net models take llama-server's own slot count again (engine#3125)

The `-np 1` default for qwen35 / qwen35moe / qwen3next on --device hrx is gone, and
the shared-KV treatment the explicit --parallel path already had is now shared with the
unasked case (apply_shared_kv, one place instead of two copies).

Measured 2026-11-21 through this gate on Qwen3.8-27B (arch qwen35), --device hrx
--no-strict-device, two simultaneous completions with distinct expected words:

  --parallel 4   n_slots=4 kv_unified=true   both 200, own word, no cross-talk   1.1 s / 1.1 s
  --parallel 2   n_slots=2 kv_unified=true   both 200, own word, no cross-talk   1.1 s / 1.1 s
  default (old)  n_slots=1 kv_unified=false  both 200, no cross-talk            1.1 s / 2.0 s
                                             (the second waited for the first)

So the recorded reason for the clamp -- a 500 at the multi-sequence softplus /
GATED_DELTA_NET -- does not reproduce, and the clamp costs a second concurrent request
its concurrency. The matcher side always agreed: kMaximumSequences = 8 at
dispatch_registration/llm/dispatch-gated-delta-net.cpp:53, and the 2- and 3-sequence ops
rows pass (tests/hrx-ops-test.cpp:5513 builds softplus + GATED_DELTA_NET at seqs = 2).

The clamp's removal makes the shared-KV treatment load-bearing for the unasked case:
auto resolves to 4 slots with kv_unified = true (tools/server/server.cpp:128-130), and
leaving qwen.attention on under a unified cache is what bleeds answers between requests.

tests/parallel_args.sh gains five arms: an unasked qwen35 server passes no -np, gets
-kvu, and the child env carries qwen.attention in GGML_HRX_DISABLE_DISPATCH; --parallel 4
on qwen35 still passes -np 4 + -kvu; a non-delta-net arch is untouched. Against the
pre-change binary the first three fail and the regression arms pass, measured here.
serve opens no device on this path (it names the HSA runtime it would dlopen and reads
the GTT counters from sysfs, then forks), so the arms stay device-free.

Not changed: the --device auto clamp for an explicit --parallel > 1 (serve_child prints a
warning and auto has no other GPU route); the measurement above is on --device hrx, which
is the path that clamp never covered.

docs/hrx.md's "Several sequences per batch fail ... refuses --parallel" was doubly stale
(the refusal was removed in a19c820 and the kernel has taken up to 8 sequences since
fork #117) and is corrected here, with app/serve.cpp's rag_device comment.

* serve: the unasked gated delta-net case chooses four slots, not none (engine#3125 review)

Fixes exactly what the CHANGES named: my previous head removed the `-np 1` clamp and
replaced it with nothing, but llama-server's default is one slot (common/common.h:477) and
the 4-slot + kv_unified resolution only fires for an explicit `-np -1`
(tools/server/server.cpp:126-131). So the clamp removal changed nothing a second concurrent
request could observe, while still turning a fused dispatch off for every gated delta-net
model — a regression with no measured gain, and the reviewer was right that the measurement
table's own "shipped default" row (1 slot, 1.1 s then 2.0 s) said so.

Now the unasked case asks for 4 slots:

    if (device == "hrx" && o.parallel == 0 && delta_net_arch(...)) {
        argv.insert(argv.end(), {"-np", "4"});
        apply_shared_kv(argv, env);
    }

4 is llama-server's own auto value (server.cpp:128-131), and `-np 4 -kvu` with
`qwen.attention` off is exactly the argv measured on 2026-11-21 (n_slots=4,
kv_unified=true, two simultaneous requests both 200, own answers, no cross-talk, 1.1 s
each). The default path is therefore the measured path, and the shared-KV treatment is
load-bearing for it rather than incidental.

Also corrected in the code comment: the claim that "the auto case reaches 4 unified slots"
was false for an unpassed -np, and it is now stated the right way round, with the two
constant names so the next reader can check it.

tests/parallel_args.sh: the three engine#3125 arms now assert `-np 4` + `-kvu` +
`qwen.attention` for an unasked qwen35 server, plus the two regression arms
(--parallel 4 still -np 4 + -kvu; a non-delta-net arch untouched).

What I could NOT verify here: the green direction needs a build. Worse, my attempt to show
the arms failing was worthless and I am not claiming it — `~/.cache/hrx-build/bench/1bit`
already emits `--jinja -kvu` with no `-np` for this case, i.e. it is not a build of main's
serve.cpp, so it cannot be the "before" for this change. The arms are correct against the
source on both sides; CI proves the pass, and the reviewer's build (from #3148's earlier
head) proves the instrument works.

---------

Co-authored-by: bong-water-water-bong <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Nov 22, 2026
…te a fresh kernel set (engine#3237) (#3265)

The decode gate merged into npu-dx twice today -- `addons/npu-dx/scripts/decode-gate.sh` (#117, the
check itself plus its hardening) and the `layer1.py` row-tile padding fix with the `tpc 6` golden
rows (#118) -- and **neither is reachable from the release path**, because the engine still pins
`3949f18e`. Measured on the tree, not assumed: a real `scripts/fetch-private.sh` run of the current
config produced an `addons/` checkout with `npu-dx/scripts/build-kernels.sh` and **no
`decode-gate.sh`**, i.e. `release-kernels.sh` in that tree is the pre-gate version and a weekly build
that missed the kernel cache would again ship a set nobody decoded.

So this is the same lag I filed against a fork pin this morning (engine#3192), on this lane's own
work: merged upstream, inert downstream until the pin moves.

  config/npu-kernels.config:
    sha=3949f18e826e99a84ec5e6e2e3041300215ddb61   ->  4e6261b7df9f4326a72fd1d8efef449b9ab24518
    require=CMakeLists.txt register.cpp release-kernels.sh
      -> … release-kernels.sh npu-dx/scripts/decode-gate.sh

The delta carries exactly the four files this issue needed: `decode-gate.sh` (+112),
`addons/release-kernels.sh` (+35, the call and the cache/verdict hardening), `npu_dx/designs/layer1.py`
(+5/-1, the per-phase padding) and `tests/golden/dx_layout_perm.tsv` (+2, the tpc 6 rows).

The `require=` addition is the part that keeps this true: the gate lives under `addons/`, and a pin
that loses it would otherwise fetch a tree whose release simply has no gate. Verified both ways with
the engine's own fetch:

  current config + this pin   fetch rc 0, addons/npu-dx/scripts/decode-gate.sh PRESENT (6663 B),
                              addons/release-kernels.sh carries 5 decode-gate references
  require= with a bad path    fetch rc 1, naming the missing file

Refs engine#3237.

Co-authored-by: bong-water-water-bong <[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