[GH-ISSUE #3932] [Engine] Run Qwen3.6-35B-A3B on the Mac (Metal) engine #1681

Open
opened 2026-11-04 01:53:09 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @keithhu1982 on GitHub (Oct 24, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3932

Area

[Engine] (speed, kernels, models, the server and API)

What do you want to do?

Run Qwen3.6-35B-A3B on an Apple Silicon Mac with the Strata engine.

Today the Mac engine runs no Qwen3.6 model at all. Qwen3.6-35B-A3B (GGUF architecture qwen35moe) is the only Qwen3.6 model Strata supports on any backend, and it runs on NVIDIA and AMD only:

  • Its engine path in src/qwen35/ is CUDA/HIP.
  • The Metal build never compiles that path: STRATA_HAVE_QWEN35 is not defined there, so strata --families lists only qwen4exp, and a qwen35moe file is refused at model_family_not_supported.
  • The Metal Window is built for the Flash-Next shapes.

docs/QWEN36.md, docs/MAC.md and docs/MODELS.md all say the Mac engine does not run it.

Out of scope here: other Qwen3.6 models such as the dense Qwen3.6-27B, which Strata does not run on any backend. This issue is only about bringing the existing 35B-A3B support to the Mac.

Who needs it: Mac users with 64 GB. Flash-Next only fits there as Q2_0. Qwen3.6-35B-A3B fits as UD-Q6_K_XL (32.6 GB), which is close to lossless, and it reads pictures.

I have a working port on a local branch (not published yet) and would like to agree the scope before opening pull requests.

What the port does (all Metal-only; nothing under src/, include/, setup.py or serve/ changes):

  • A separate Metal engine path, metal/src/qwen35/, that defines strata::qwen35::run.
    • metal/CMakeLists.txt defines STRATA_HAVE_QWEN35 for the Metal strata, so the existing family switch in generate.cpp routes qwen35moe files to it.
    • The serve protocol (GEN, GENI, STOP, READY, PP, T, DONE) is the CUDA engine's solo path, ported.
  • Kernels.
    • The existing gemv, moe_gu (Q6_K), moe_down (Q8_0), mm_* (prompt) and gdn kernels are reused.
    • New kernels live in metal/kernels/q36/: rms norm with prepared planes, a 256/top-8 router, dense full-context attention with M-RoPE, MTP concat, prompt glue, and a matmul2d prompt attention.
    • One shared-kernel change: gdn.metal and gdn_prompt.metal get an opt-in function constant (12, GDN_SILU_Z) for the silu output gate. When it is unset, the output is bit-identical (hashed against HEAD; gdn_parity and gdn_prompt_parity are unchanged).
  • Features.
    • Decode windows of T = 1..8 with verify/commit.
    • Greedy MTP speculative decoding, plus exact speculative sampling (point-mass draft, so the output distribution is preserved).
    • An exact 8-row window prompt mode and a chunked GEMM prompt mode.
    • Pictures via strata-vision with M-RoPE.
    • Conversation checkpoints, so multi-turn chats reuse the prefix even though the template drops <think> blocks from history.
  • Setup: ./setup.sh --family qwen36 --model UD-Q6_K_XL (metal/setup_q36.py and a few lines in setup_mac.py).

Measured on an M5 Pro with 64 GB, macOS 26.5, UD-Q6_K_XL. llama.cpp is the pinned commit 3cf03257, Metal build, same file.

Strata Metal (port) llama.cpp Metal
Decode, greedy 74.6 tok/s 64.1
Decode, MTP (--mtp 2) 105-114 tok/s greedy, 95-110 sampled 62 (draft-mtp)
Prompt 4K / 32K 1,923 / 1,413 tok/s 1,545 / 898
Needle, 8K-64K found at every size found at 32K

The decode gemv and MoE kernels run at 264-297 GB/s, which is about the memory ceiling.

Correctness, against llama.cpp Metal one token at a time, 10 parity prompts x 128 steps:

  • Teacher-forced: mean KL 3.7e-4 (median 1.6e-8), top-1 99.7%.
  • Free-running greedy: 8 of 10 prompts identical for 128 tokens. The 2 divergences are at llama.cpp near-ties (margins 0.08).
  • --mtp 0/2/3 give identical tokens.
  • The kernels have double-precision CPU parity tests (metal/tests/q36_*), plus a synthetic qwen35moe GGUF generator for GPU tests that need no download.

Proposed scope and split (one problem per PR):

  1. [Engine] the GDN silu function constant (small, opt-in).
  2. [Engine] the Metal qwen35moe engine path and its tests.
  3. [Other] Mac setup for --family qwen36, plus docs.

Limits / not done:

  • Only Unsloth's UD-Q6_K_XL file of Qwen3.6-35B-A3B. The other two pinned sizes are not done: UD-Q4_K_XL needs Q5_K/Q6_K moe_down kernels that the Mac engine does not have, and Q8_0 (37.8 GB) is untested.
  • 64 GB Macs only.
  • Tested on M5 Pro only. M4 and M1 are untested; the existing coop_k4 fallback should apply.
  • No --parallel, logit_bias or SAVE/RESTORE.

Questions for you:

  • Is a separate Metal path (rather than generalising Window) acceptable?
  • Would you want the split above, or something else?

What do you do today instead?

On the Mac: Flash-Next Q2_0 through Strata, or Qwen3.6-35B through MLX servers (oMLX), at about 71 tok/s decode and 1,420 tok/s prompt on the same Mac with a 4-bit MLX file.

Originally created by @keithhu1982 on GitHub (Oct 24, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3932 ### Area [Engine] (speed, kernels, models, the server and API) ### What do you want to do? Run Qwen3.6-35B-A3B on an Apple Silicon Mac with the Strata engine. Today the Mac engine runs no Qwen3.6 model at all. Qwen3.6-35B-A3B (GGUF architecture `qwen35moe`) is the only Qwen3.6 model Strata supports on any backend, and it runs on NVIDIA and AMD only: - Its engine path in `src/qwen35/` is CUDA/HIP. - The Metal build never compiles that path: `STRATA_HAVE_QWEN35` is not defined there, so `strata --families` lists only `qwen4exp`, and a `qwen35moe` file is refused at `model_family_not_supported`. - The Metal `Window` is built for the Flash-Next shapes. `docs/QWEN36.md`, `docs/MAC.md` and `docs/MODELS.md` all say the Mac engine does not run it. Out of scope here: other Qwen3.6 models such as the dense Qwen3.6-27B, which Strata does not run on any backend. This issue is only about bringing the existing 35B-A3B support to the Mac. Who needs it: Mac users with 64 GB. Flash-Next only fits there as Q2_0. Qwen3.6-35B-A3B fits as UD-Q6_K_XL (32.6 GB), which is close to lossless, and it reads pictures. I have a working port on a local branch (not published yet) and would like to agree the scope before opening pull requests. **What the port does (all Metal-only; nothing under `src/`, `include/`, `setup.py` or `serve/` changes):** - A separate Metal engine path, `metal/src/qwen35/`, that defines `strata::qwen35::run`. - `metal/CMakeLists.txt` defines `STRATA_HAVE_QWEN35` for the Metal `strata`, so the existing family switch in `generate.cpp` routes `qwen35moe` files to it. - The serve protocol (GEN, GENI, STOP, READY, PP, T, DONE) is the CUDA engine's solo path, ported. - Kernels. - The existing gemv, moe_gu (Q6_K), moe_down (Q8_0), mm_* (prompt) and gdn kernels are reused. - New kernels live in `metal/kernels/q36/`: rms norm with prepared planes, a 256/top-8 router, dense full-context attention with M-RoPE, MTP concat, prompt glue, and a matmul2d prompt attention. - One shared-kernel change: `gdn.metal` and `gdn_prompt.metal` get an opt-in function constant (12, `GDN_SILU_Z`) for the silu output gate. When it is unset, the output is bit-identical (hashed against HEAD; `gdn_parity` and `gdn_prompt_parity` are unchanged). - Features. - Decode windows of T = 1..8 with verify/commit. - Greedy MTP speculative decoding, plus exact speculative sampling (point-mass draft, so the output distribution is preserved). - An exact 8-row window prompt mode and a chunked GEMM prompt mode. - Pictures via `strata-vision` with M-RoPE. - Conversation checkpoints, so multi-turn chats reuse the prefix even though the template drops `<think>` blocks from history. - Setup: `./setup.sh --family qwen36 --model UD-Q6_K_XL` (`metal/setup_q36.py` and a few lines in `setup_mac.py`). **Measured on an M5 Pro with 64 GB, macOS 26.5, UD-Q6_K_XL.** llama.cpp is the pinned commit 3cf03257, Metal build, same file. | | Strata Metal (port) | llama.cpp Metal | |---|---|---| | Decode, greedy | 74.6 tok/s | 64.1 | | Decode, MTP (`--mtp 2`) | 105-114 tok/s greedy, 95-110 sampled | 62 (draft-mtp) | | Prompt 4K / 32K | 1,923 / 1,413 tok/s | 1,545 / 898 | | Needle, 8K-64K | found at every size | found at 32K | The decode gemv and MoE kernels run at 264-297 GB/s, which is about the memory ceiling. **Correctness**, against llama.cpp Metal one token at a time, 10 parity prompts x 128 steps: - Teacher-forced: mean KL 3.7e-4 (median 1.6e-8), top-1 99.7%. - Free-running greedy: 8 of 10 prompts identical for 128 tokens. The 2 divergences are at llama.cpp near-ties (margins 0.08). - `--mtp 0/2/3` give identical tokens. - The kernels have double-precision CPU parity tests (`metal/tests/q36_*`), plus a synthetic qwen35moe GGUF generator for GPU tests that need no download. **Proposed scope and split (one problem per PR):** 1. `[Engine]` the GDN silu function constant (small, opt-in). 2. `[Engine]` the Metal qwen35moe engine path and its tests. 3. `[Other]` Mac setup for `--family qwen36`, plus docs. **Limits / not done:** - Only Unsloth's UD-Q6_K_XL file of Qwen3.6-35B-A3B. The other two pinned sizes are not done: UD-Q4_K_XL needs Q5_K/Q6_K `moe_down` kernels that the Mac engine does not have, and Q8_0 (37.8 GB) is untested. - 64 GB Macs only. - Tested on M5 Pro only. M4 and M1 are untested; the existing `coop_k4` fallback should apply. - No `--parallel`, `logit_bias` or SAVE/RESTORE. Questions for you: - Is a separate Metal path (rather than generalising `Window`) acceptable? - Would you want the split above, or something else? ### What do you do today instead? On the Mac: Flash-Next Q2_0 through Strata, or Qwen3.6-35B through MLX servers (oMLX), at about 71 tok/s decode and 1,420 tok/s prompt on the same Mac with a 4-bit MLX file.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 24, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Fill in "Area".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6381355767 --> @github-actions[bot] commented on GitHub (Oct 24, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Fill in "Area". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Oct 24, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6384185956 --> @github-actions[bot] commented on GitHub (Oct 24, 2026): Thanks, this follows the format now.
Author
Owner

@keithhu1982 commented on GitHub (Oct 29, 2026):

Hi @Niko1221, a gentle ping, no rush. Would you be open to this, and is the 3-PR split above OK? Happy to adjust or close if it doesn't fit your plans. Thanks!

<!-- gh-comment-id:6502061180 --> @keithhu1982 commented on GitHub (Oct 29, 2026): Hi @Niko1221, a gentle ping, no rush. Would you be open to this, and is the 3-PR split above OK? Happy to adjust or close if it doesn't fit your plans. Thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1681
No description provided.