Skip to content

model:add Zaya1 8B (Zyphra) - #32071

Merged
ngxson merged 5 commits into
ggml-org:masterfrom
varun10221:zyphra-zaya
Nov 18, 2026
Merged

ngxson merged 5 commits into
ggml-org:masterfrom
varun10221:zyphra-zaya

Conversation

@varun10221

@varun10221 varun10221 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Please enter the commit message for your changes. Lines starting

Overview

  • Added the support for Zaya1 8B.
  • Fixed the SSM_CONV case, so the model runs on cuda without abort.

Additional information

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure:
    • YES , Used AI for scoping, generating code and running some portions of testing.

@varun10221
varun10221 requested review from a team, CISC and ggerganov as code owners November 11, 2026 08:59
@ggml-gh-bot

ggml-gh-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

Hi @varun10221, thanks for your contribution!

Caution

Your AI agent does not seem to follow AGENTS.md

Many agents do not load AGENTS.md on their own. Please tell your agent explicitly, e.g.:
Read AGENTS.md and follow it strictly. Then review all changes in this branch against it and fix any violation.

Then update this PR accordingly.

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • PR Template not respected: Please respect the template when creating a new pull request. Make sure to fill out all required sections.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

@ggml-gh-bot ggml-gh-bot Bot added the draft PR will be changed to draft by github-actions bot label Nov 11, 2026
@varun10221

Copy link
Copy Markdown
Contributor Author

Hi @varun10221, thanks for your contribution!

Caution

Your AI agent does not seem to follow AGENTS.md

Many agents do not load AGENTS.md on their own. Please tell your agent explicitly, e.g.: Read AGENTS.md and follow it strictly. Then review all changes in this branch against it and fix any violation.

Then update this PR accordingly.

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • PR Template not respected: Please respect the template when creating a new pull request. Make sure to fill out all required sections.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

Updated to conform to template.

@github-actions github-actions Bot added model Model specific testing Everything test related ggml changes relating to the ggml tensor library for machine learning CUDA Related to the CUDA backend conversion labels Nov 11, 2026
@github-actions
github-actions Bot marked this pull request as draft November 11, 2026 10:05
@github-actions github-actions Bot removed the draft PR will be changed to draft by github-actions bot label Nov 11, 2026
@ngxson

ngxson commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

/bot review

@ggml-gh-bot

ggml-gh-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Automated code review

Review of PR #32071 (Zaya1 8B support). I checked the new arch against AGENTS.md/CONTRIBUTING.md and the add-model conventions, and traced the CCA state math, the router-MoE path, the converter, and the ggml_ssm_conv kernel change. Scope and quick-reject gate pass: prior issue #32069 is linked, the change is single-purpose, backends touched are CPU (generic) + a minimal CUDA dispatch case with a test-backend-ops addition, no new ggml op, AI usage is disclosed.

Will slow the review (correctness/robustness)

  1. src/models/zaya1.cpp silently assumes a very specific head geometry. The value path splits attn_v into halves (n_v_half = n_embd_v_gqa/2, views at n_v_half * es), then reshapes Vcur to {n_embd_head, n_head_kv, n_tokens} so that kv head 0 gets the "current" half and kv head 1 the "delayed" half. That is only correct when n_embd_v_gqa == 2 * n_embd_head_k (i.e. n_head_kv == 2 with equal head dims). For any other n_head_kv there is no shape mismatch and no assert - heads are silently assigned wrong values. Same for the CCA conv: zaya1_conv_grouped hard-codes kernel 2 and n_hist = 2 * (ssm_d_conv - 1), which only reproduces n_seq_tokens outputs when ssm_d_conv == 2. And build_router_moe hard-codes top-1 (ggml_argsort_top_k(real, 1)) while n_expert_used is still read from the GGUF, so a GGUF with expert_used_count != 1 dies later with an obscure mul_mat_id shape assert. Please add explicit checks in load_arch_hparams (throw, not GGML_ABORT, the loader already catches): n_embd_v_gqa() == 2*n_embd_head_k(), ssm_d_conv == 2, n_expert_used == 1. They document the layout and turn silent corruption / cryptic failures into clear errors.

  2. src/models/zaya1.cpp:125 - static_cast<const llama_memory_hybrid_context *>(mctx) is unguarded. It is fine for the standard context path (zaya has no SWA and no MTP), but any caller that builds this graph with a different memory type gets UB instead of an error. Other hybrid models guard or use std::conditional_t (see src/models/lfm2.cpp:163). A cheap assert on the arch/memory type would match existing practice.

Notes

  1. The CCA state math checks out: saving 2 raw q/k columns lets the next ubatch recompute the depthwise output at p-1 as grouped-conv history, and the v_del chain (v_rs + delayed half of the current tokens) yields v_prev[t] = delayed(t-1) with the write-back at column n_seq_tokens. No issue found - stating this since it is the riskiest part of the graph.

  2. ggml/src/ggml-cuda/ssm-conv.cu - kernel size 2 is exercised in the ring-buffer and smem paths of both kernels and in test-backend-ops; the abort message was updated. One inherited constraint worth noting in the PR description: the CUDA path still asserts nr % 128 == 0, so n_cca_qk = (n_head + n_head_kv) * head_dim must be a multiple of 128 (true for the 8B config with head_dim 128, silent constraint for future variants). Metal takes nc dynamically and the MTL fusion baseline implies it was run there already.

  3. Quantization handling is consistent between tensor_force_quant (converter) and tensor_allows_quantization (src/llama-quant.cpp:344): ffn_router_* and cca_conv_grp stay F32 on both sides. Good. Since CCA layers also carry a regular attention KV cache, please smoke-test the quantized-KV path (-ctk q8_0 -ctv q8_0) once - the arch test only covers f16.

  4. src/llama-arch.cpp:1285 - LLM_TENSOR_RES_SCALE_IN is classified LLM_TENSOR_LAYER_REPEATING even though it is a single input-level tensor (which is why load_arch_tensors must pass a dummy bid 0). Classify it LLM_TENSOR_LAYER_INPUT like TOKEN_EMBD and create it without a bid. Similarly, the {bid}-less entry in arch_block_mappings_cfg (gguf-py/gguf/tensor_mapping.py:3233) belongs in mappings_cfg per the TODO already sitting at the top of that dict.

  5. conversion/zaya1.py:32 - gguf.LlamaHfVocab(self.dir_model) is constructed twice (once in __init__, again in set_vocab), each time loading tokenizer.json and instantiating the HF fast tokenizer. Keep the instance from __init__ (you already store _n_vocab from it).

  6. Nits: (a) the softmax over the router logits is computed twice per layer (once in build_router_moe, once inside build_moe_ffn from the same logits) - acceptable given build_moe_ffn's contract, just be aware; (b) LLM_TYPE_8B_A1B is reused from lfm2moe, so logs will print 8B.A1B for Zaya - harmless, but a Zaya-specific type label would read better; (c) the inserted LLM_TENSOR_INFOS block in src/llama-arch.cpp swallowed the blank line that separated the lilicorr entries from ATTN_V_GATE; (d) in tests/test-llama-archs.cpp zaya passes the n_head_kv == 2 requirement only by accident of the defaults - adding it to the explicit GQA list at line 334 would document the constraint the arch actually has (see point 1).

Everything else (tensor name parity gguf-py/C++, saver coverage for res_scale_in/res_scale_in_b, moe_mandatory, fusion baseline row, ASCII/comment style, RoPE via build_rope, no trailing ggml_build_forward_expand on logits) looks correct and conventional.

This review was generated automatically by pi coding agent using zai-org/GLM-5.3. It may contain mistakes. Maintainers make the final call.

@varun10221
varun10221 marked this pull request as ready for review November 12, 2026 06:29
Comment thread conversion/zaya1.py Resolved

@CISC CISC left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase.

Comment thread conversion/zaya1.py Resolved
Comment thread src/models/zaya1.cpp Resolved
varun added 5 commits November 17, 2026 16:45
- Added the support for Zaya.
- Fixed the SSM_CONV case, so the model runs on cuda without abort.

 Please enter the commit message for your changes. Lines starting
1) Added runtime asserts when loading wrong KV head size, unsupported conv kernel size.
2) Removed the static cast usage.
3) Fixed double load of tokenizer.
4) Updated res_scale_in to be input tensor.
@ngxson
ngxson merged commit 98d67c8 into ggml-org:master Nov 18, 2026
30 of 35 checks passed
@varun10221
varun10221 deleted the zyphra-zaya branch November 18, 2026 18:27
fencerJP pushed a commit to fencerJP/llama-apu that referenced this pull request Nov 21, 2026
* model:add Zaya1 8B (Zyphra)
- Added the support for Zaya.
- Fixed the SSM_CONV case, so the model runs on cuda without abort.

 Please enter the commit message for your changes. Lines starting

* Made the following changes based on the bot reviewer feedback:
1) Added runtime asserts when loading wrong KV head size, unsupported conv kernel size.
2) Removed the static cast usage.
3) Fixed double load of tokenizer.
4) Updated res_scale_in to be input tensor.

* - Moved the res_scale_in back to layer 0 to fix the cuda bug

* i)  Removed the EOS addition.Team agreed that updating Tokenizer is the right move.
ii) Fixed formatting

* Fixed the comment to make it clear

---------

Co-authored-by: varun <[email protected]>
Annieren pushed a commit to Annieren/llama.cpp-upstream that referenced this pull request Nov 23, 2026
* model:add Zaya1 8B (Zyphra)
- Added the support for Zaya.
- Fixed the SSM_CONV case, so the model runs on cuda without abort.

 Please enter the commit message for your changes. Lines starting

* Made the following changes based on the bot reviewer feedback:
1) Added runtime asserts when loading wrong KV head size, unsupported conv kernel size.
2) Removed the static cast usage.
3) Fixed double load of tokenizer.
4) Updated res_scale_in to be input tensor.

* - Moved the res_scale_in back to layer 0 to fix the cuda bug

* i)  Removed the EOS addition.Team agreed that updating Tokenizer is the right move.
ii) Fixed formatting

* Fixed the comment to make it clear

---------

Co-authored-by: varun <[email protected]>
Mr-J-369 pushed a commit to Mr-J-369/llama.cpp-Android that referenced this pull request Nov 25, 2026
* model:add Zaya1 8B (Zyphra)
- Added the support for Zaya.
- Fixed the SSM_CONV case, so the model runs on cuda without abort.

 Please enter the commit message for your changes. Lines starting

* Made the following changes based on the bot reviewer feedback:
1) Added runtime asserts when loading wrong KV head size, unsupported conv kernel size.
2) Removed the static cast usage.
3) Fixed double load of tokenizer.
4) Updated res_scale_in to be input tensor.

* - Moved the res_scale_in back to layer 0 to fix the cuda bug

* i)  Removed the EOS addition.Team agreed that updating Tokenizer is the right move.
ii) Fixed formatting

* Fixed the comment to make it clear

---------

Co-authored-by: varun <[email protected]>
(cherry picked from commit 98d67c8)
Nindaleth pushed a commit to Nindaleth/llama.cpp that referenced this pull request Nov 26, 2026
* model:add Zaya1 8B (Zyphra)
- Added the support for Zaya.
- Fixed the SSM_CONV case, so the model runs on cuda without abort.

 Please enter the commit message for your changes. Lines starting

* Made the following changes based on the bot reviewer feedback:
1) Added runtime asserts when loading wrong KV head size, unsupported conv kernel size.
2) Removed the static cast usage.
3) Fixed double load of tokenizer.
4) Updated res_scale_in to be input tensor.

* - Moved the res_scale_in back to layer 0 to fix the cuda bug

* i)  Removed the EOS addition.Team agreed that updating Tokenizer is the right move.
ii) Fixed formatting

* Fixed the comment to make it clear

---------

Co-authored-by: varun <[email protected]>
@Hi-Angel

Copy link
Copy Markdown

@varun10221 hello, I read the model presentation and I see the high quality performance is achieved via Markovian RSA. As I gather from the sentence "Markovian RSA has favorable inference properties", it's used during inference in particular.

However, this PR does not mention implementing Markovian RSA, which would make benchmark results moot. So I'm kinda confused: as it stands, does llama.cpp run this model with Markovian RSA or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conversion CUDA Related to the CUDA backend ggml changes relating to the ggml tensor library for machine learning model Model specific testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Support Zaya1 -8B Model

5 participants