Skip to content

model: ZAYA1 (Zyphra) with a converter (HRX and ROCm follow in #5) - #2

Merged
bong-water-water-bong merged 4 commits into
1bit/hrx-vulkan-patchedfrom
1bit/zaya
Sep 25, 2026
Merged

bong-water-water-bong merged 4 commits into
1bit/hrx-vulkan-patchedfrom
1bit/zaya

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Sep 25, 2026 •

Copy link
Copy Markdown

Note: this PR merged at ee7ed7d, which runs ZAYA1 on Vulkan and the CPU. The HRX and ROCm changes described below came after the merge and are in #5.

Adds ZAYA1 (Zyphra) to the llama.cpp the engine pins. ZAYA1-8B now runs on the Strix Halo GPU through Vulkan, HRX and ROCm (HIP), next to Qwen.

The ZAYA code was on 1bit/hrx2-archive, a branch the engine no longer pins. Upstream's draft (ggml-org#23112) was closed on 2026-09-05. This PR ports it onto the per-model class layout (src/models/zaya.cpp) and fixes what a check against transformers' ZayaForCausalLM turned up.

Correctness fixes

  • Skip expert: the router's skip expert can now win, which zeroes the MoE output as HF does.
  • Expert shape: ffn_down_exps is {n_ff, n_embd, n_expert}. The 8B only worked before because n_ff == n_embd.
  • Model saver: it writes the model-level input and final residual scales.
  • Converter: conversion/zaya.py converts the transformers checkpoint.
    • RoPE theta is 5e6, from rope_parameters.hybrid; the old converter wrote 1e6.
    • The router EDA scale is included.
    • Non-special added tokens such as "\n" stay USER_DEFINED.
    • The grouped conv is written tap-major, which the graph needs (below).

Graph changes (speed, and running on every backend)

  • Grouped conv: it is one batched matmul per tap on tap-major weights, where it used to be per-group im2col + conv_1d + concat. Q4_K_M decode on Vulkan went from 50 to 93 tok/s.
  • Recurrent state: two whole rows per sequence, the conv state in r and the previous hidden state in s. HRX can't copy into part of a row.
  • q/k normalisation: rms_norm, the same value as l2_norm × √head_dim.
  • EDA ordering: the router's EDA term is built before its down projection, because HRX fuses that projection with the EDA add.
  • ROCm fixes: contiguous router scores before argsort, and a 2-tap kernel for ssm_conv in ggml-cuda/HIP.
  • Quantisation: llama-quantize keeps cca_conv_grp in F16, like ssm_conv1d.

Build fixes (existing fork files)

llama-kv-share.cpp now builds with GCC and on Windows, and the Vulkan dma-buf import is compiled on Linux only. The Windows CI jobs stopped at both before.

Checks (strixhalo, Radeon 8060S)

Accuracy against transformers FP32, teacher-forced on 3 prompts (96 positions):

  • The F16 GGUF agrees on the top-1 token at 95/96 positions. The miss is a 0.07-nat tie.
  • For scale, HF BF16 vs FP32 agrees at 91/96.

test-llama-archs -a zaya: Vulkan NMSE 9.6e-8 and ROCm 8.1e-14 vs the CPU; roundtrip OK. The full suite shows 0 FAIL on Vulkan.

Speed, ZAYA1-8B Q4_K_M:

Device Prefill (pp512) Decode (tg128) Perplexity (engine docs, c=512)
Vulkan0 3,437 tok/s 93.0 tok/s 21.57
ROCm0 ~2,400 tok/s (noisy) 61.5 tok/s 21.78
HRX0 1,175 tok/s 25.5 tok/s 21.55

🤖 Generated with Claude Code

bong-water-water-bong and others added 2 commits September 25, 2026 20:01
GCC rejects `extern "C" GGML_API ...` when GGML_API expands to extern
("invalid use of extern in linkage specification"); clang accepts it. The
braced form means the same to both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every ZAYA1 layer is CCA attention (q/k through a 2-tap depthwise conv and a
grouped conv over time, v from the current and previous hidden state) followed
by a top-1 MoE whose router carries state between layers (EDA) and can pick a
skip expert. Ported from the 1bit/hrx2-archive branch onto the per-model
class layout, with fixes found against transformers' ZayaForCausalLM:

- the grouped conv is one batched matmul per layer instead of per-group
  im2col + conv_1d + concat (decode 50 -> 90 tok/s on a Radeon 8060S, Q4_K_M);
- the skip expert: the MoE output is zeroed where the biased skip slot beats
  the best real expert, as HF's router does;
- ffn_down_exps is {n_ff, n_embd, n_expert} (the old shape only worked
  because the 8B has n_ff == n_embd);
- the model saver writes the model-level input and final residual scales.

conversion/zaya.py converts Zyphra/ZAYA1-8B: rope theta from
rope_parameters.hybrid (5e6, was 1e6), the router EDA scale, and the
tokenizer's non-special added tokens (such as "\n") kept USER_DEFINED.

Checked against transformers in FP32, teacher-forced on three prompts: F16
agrees on the top-1 token at 95/96 positions (the miss is a 0.07-nat tie; HF
BF16 vs FP32 itself agrees at 91/96). test-llama-archs passes for zaya
(Vulkan NMSE 7.9e-8 vs CPU, roundtrip OK) and the rest of the suite.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong and others added 2 commits September 25, 2026 20:08
unistd.h is only needed to close the dma-buf fd of a shared KV region, which
exists on Linux only; the Windows CI jobs stopped at the include.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The zero-copy import (ggml-vulkan-dmabuf.inc) needs unistd.h and dma-buf fds,
so Windows builds stopped at its include; elsewhere the proc is simply absent
and llama-kv-share falls back to separate KV caches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong
bong-water-water-bong merged commit ec07f7e into 1bit/hrx-vulkan-patched Sep 25, 2026
12 of 28 checks passed
@bong-water-water-bong bong-water-water-bong changed the title model: ZAYA1 (Zyphra) on the engine pin, with a converter model: ZAYA1 (Zyphra) on Vulkan, HRX and ROCm, with a converter Sep 26, 2026
@bong-water-water-bong bong-water-water-bong changed the title model: ZAYA1 (Zyphra) on Vulkan, HRX and ROCm, with a converter model: ZAYA1 (Zyphra) with a converter (HRX and ROCm follow in #5) Sep 26, 2026
bong-water-water-bong pushed a commit that referenced this pull request Nov 8, 2026
…se release() nulls slot.task (engine ggml-org#1489)

A CLIP encode failure killed llama-server with SIGSEGV three milliseconds after it had already produced the
error. Reproduced with a backtrace, and the frame names the site:

  Thread 1 received signal SIGSEGV
  #0 server_context_impl::pre_decode()::{lambda(server_slot&)#5}::operator()(server_slot&)
  #1 server_context_impl::iterate(std::vector<server_slot>&, std::function<void(server_slot&)>)
  #2 server_context_impl::pre_decode()
  #3 server_context_impl::update_slots()

The failing path is the multimodal chunk loop in pre_decode(): process_mtmd_chunk() returns non-zero, the slot's
error is sent, slot.release() runs - which does both "task_prev = std::move(task)" and "task.reset()", leaving
slot.task null - and then "continue" re-enters that loop, whose first statement reads slot.task->n_tokens(). Null
dereference, every time.

Return instead: the slot has been released and must not be batched in this pass. Upstream master's equivalent
handler does exactly that, with the comment "the slot is done, skip it entirely".

No other site in this file releases a slot and then continues.

Not verified by a rebuild in this lane: the tree here has no configured HRX build, and the only configured one on
this box is a shared build tree whose rebuild is precisely the ggml-org#1403 incident (it swaps libraries under running
services). The pre-fix crash is recorded with the full backtrace in engine ggml-org#1489; the post-fix acceptance is the
issue's own - an HTTP error and a live process - which CI's build can run.
bong-water-water-bong added a commit that referenced this pull request Nov 8, 2026
…se release() nulls slot.task (engine ggml-org#1489) (#246)

Same one-line fix as #245, cherry-picked onto 1bit/hrx-vulkan-patched -- the branch the engine actually pins.
The bug site is identical on this branch (tools/server/server-context.cpp:3667-3670), so until this lands the
pinned tree still dies on a failed CLIP encode.

A CLIP encode failure kills llama-server with SIGSEGV three milliseconds after it has already produced the error.
Reproduced with a backtrace, and the frame names the site:

  Thread 1 received signal SIGSEGV
  #0 server_context_impl::pre_decode()::{lambda(server_slot&)#5}::operator()(server_slot&)
  #1 server_context_impl::iterate(std::vector<server_slot>&, std::function<void(server_slot&)>)
  #2 server_context_impl::pre_decode()
  #3 server_context_impl::update_slots()

The failing path is the multimodal chunk loop in pre_decode(): process_mtmd_chunk() returns non-zero, the slot's
error is sent, slot.release() runs - which does both "task_prev = std::move(task)" and "task.reset()", leaving
slot.task null - and then "continue" re-enters that loop, whose first statement reads slot.task->n_tokens(). Null
dereference, every time.

Return instead: the slot has been released, nothing is left to advance (the failed chunk was never added to the
prompt or the cache), and it must not be batched in this pass.

Upstream check, since the reviewer of #245 could not reach it from the fork tree: at upstream origin/master the
equivalent handler does

    slot.release();
    return; // the slot is done, skip it entirely

(verified by fetching origin/master into a fork checkout and reading tools/server/server-context.cpp there; the
honest caveat is that upstream has since refactored the chunk helper into free functions, so the surrounding code
differs while the failure handling does not).

No other site in this file releases a slot and then continues (checked on this branch).

Not verified by a rebuild in this lane: this tree has no configured HRX build, and the box's only configured one is a
shared build tree whose rebuild is precisely the ggml-org#1403 incident. The pre-fix crash is recorded with the full
backtrace in engine ggml-org#1489; the post-fix acceptance is the issue's own - an HTTP error and a live process.

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