You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prefill Accelerator: support qwen3_5_moe (e.g. Qwen3.6-35B-A3B)
#5351
The qwen3_5 adapter declares model_types = ("qwen3_5",), so adapter_for_model() returns None for qwen3_5_moe checkpoints and prefill stays on the host. That is the intended fallback for an unsupported family, so this is a feature request, not a bug report. I have a working implementation (branch: https://github.com/a-min-7/omlx/tree/feat/qwen3_5_moe-family, 8 commits on eec2544c, 20 files, +1,496/−557). Because that exceeds the 1,000-line threshold and I have no merged PRs here, I am posting the approach for review before opening a PR. I am willing to restructure it.
What it would take. Three changes, all required:
The adapter claims both families: model_types = ("qwen3_5", "qwen3_5_moe").
Mask builders are resolved through the checkpoint's language module instead of a fixed attribute. qwen3_5_moe's model class subclasses qwen3_5 and does not expose the attribute at the fixed location, so the resolution has to follow the class hierarchy. This changes a shared path, so the change adds two weight-free tests (test_mask_builder_resolution_dense, test_mask_builder_resolution_subclass) that run without model weights.
A qwen3_5_moe family in the helper. It reuses the dense blocks by moving them into _qwen35_layers / _qwen35_plan / _qwen35_stage rather than copying ~590 lines. A recorded contract fixture (tests/fixtures/prefill_contract/qwen3_5_moe, 4 files, 158 KiB, regenerated with python tests/fixtures/record_prefill_contract.py qwen3_5_moe, which needs the model weights) lets the MoE contract test run; CI skips it when the fixture is absent.
The model.Qwen3.6-35B-A3B-oQ4-mtp, model_type=qwen3_5_moe, text config: 40 hidden layers (30 linear-attention, 10 full), 256 experts with top-8 routing, one shared expert, one MTP layer. Quantisation: oQ4 — 4-bit base with 5/6/8-bit overrides on selected modules. Source: a private Hugging Face repo, Jundot/Qwen3.6-35B-A3B-oQ4-mtp at revision 883dbfad. Identical attention, linear-attention, norm and RoPE blocks to qwen3_5; only the MLP differs.
Measured. M3 Ultra 96 GiB host + DGX Spark GB10 helper, 10 GbE Ethernet, helper image omlx-cuda-helper:0.1.4-arm64-fromsource-3fdc9d39, helper runs layers 0–23 of 40 (the host-bound ceiling for that split is 40/16 = 2.5×). 38,817-token prompt, one run per cell:
configuration
prefill tok/s
TTFT (s)
host only
1,777
21.85
host + helper
3,629
10.70
ratio
2.04×
—
A second session with a median-of-legs convention on the same rig: 1,705 → 3,233 tok/s (1.90×), TTFT 21.8 → 11.1 s. Makespan (first request submitted → last request's final token) over c = 1…8 at 38,817-token prompts: 1.82× (c=1) to 2.28× (c=8); per-c table in the PR.
Correctness. A needle probe (ORBITAL-LYNX-7741): 32/32 rows in the first session and every row in the second PASS on exact substring match, cached_tokens = 0, helper engagement last_prompt = prompt − 1 on every ON row. We do not claim token-identical output: MoE routing can flip on near-tied router logits between Metal and CUDA — we have measured exactly that tie on this stack — so the claim is "same answer on these probes", not "same tokens".
Behaviour change. With the accelerator enabled, qwen3_5_moe checkpoints send layers 0..K−1 to a paired helper instead of staying local. Supported helpers: CUDA (Docker) tested; the Mac helper supports the family by construction — it selects an adapter by model_type out of a registry built from every adapter's model_types, so registering the type on Qwen35Adapter is enough there — but has not been measured on it. Host with this change paired to an older helper: not measured yet — the family is negotiated by name, so I expect the session to be declined and prefill to stay local, and I will verify that before opening the PR rather than assert it. No message-format change. The MTP head never reaches the helper: the adapter keeps .mtp. tensors and lm_head host-resident, so a 24-layer split is far below the head and the helper holds none of it. Helper memory for K=24 on the 35B: not measured yet (on the 27B the same 24 layers cost 18.7 GiB); it goes in the PR's compatibility notes.
Questions before I open a PR
Should qwen3_5_moe be claimed by the existing qwen3_5 adapter, as on the branch, or would you prefer a separate adapter?
The helper family reuses the dense blocks by moving them into _qwen35_layers / _plan / _stage. Is that extraction acceptable, or would you rather have a self-contained qwen3_5_moe family that duplicates ~590 lines?
If the extraction is acceptable: one PR with a pure-move commit followed by the family commit, or the move as its own PR with the family stacked on it as a draft? I will follow your preference.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
The
qwen3_5adapter declaresmodel_types = ("qwen3_5",), soadapter_for_model()returnsNoneforqwen3_5_moecheckpoints and prefill stays on the host. That is the intended fallback for an unsupported family, so this is a feature request, not a bug report. I have a working implementation (branch:https://github.com/a-min-7/omlx/tree/feat/qwen3_5_moe-family, 8 commits oneec2544c, 20 files, +1,496/−557). Because that exceeds the 1,000-line threshold and I have no merged PRs here, I am posting the approach for review before opening a PR. I am willing to restructure it.What it would take. Three changes, all required:
model_types = ("qwen3_5", "qwen3_5_moe").qwen3_5_moe's model class subclassesqwen3_5and does not expose the attribute at the fixed location, so the resolution has to follow the class hierarchy. This changes a shared path, so the change adds two weight-free tests (test_mask_builder_resolution_dense,test_mask_builder_resolution_subclass) that run without model weights.qwen3_5_moefamily in the helper. It reuses the dense blocks by moving them into_qwen35_layers/_qwen35_plan/_qwen35_stagerather than copying ~590 lines. A recorded contract fixture (tests/fixtures/prefill_contract/qwen3_5_moe, 4 files, 158 KiB, regenerated withpython tests/fixtures/record_prefill_contract.py qwen3_5_moe, which needs the model weights) lets the MoE contract test run; CI skips it when the fixture is absent.The model.
Qwen3.6-35B-A3B-oQ4-mtp,model_type=qwen3_5_moe, text config: 40 hidden layers (30 linear-attention, 10 full), 256 experts with top-8 routing, one shared expert, one MTP layer. Quantisation: oQ4 — 4-bit base with 5/6/8-bit overrides on selected modules. Source: a private Hugging Face repo,Jundot/Qwen3.6-35B-A3B-oQ4-mtpat revision883dbfad. Identical attention, linear-attention, norm and RoPE blocks toqwen3_5; only the MLP differs.Measured. M3 Ultra 96 GiB host + DGX Spark GB10 helper, 10 GbE Ethernet, helper image
omlx-cuda-helper:0.1.4-arm64-fromsource-3fdc9d39, helper runs layers 0–23 of 40 (the host-bound ceiling for that split is 40/16 = 2.5×). 38,817-token prompt, one run per cell:A second session with a median-of-legs convention on the same rig: 1,705 → 3,233 tok/s (1.90×), TTFT 21.8 → 11.1 s. Makespan (first request submitted → last request's final token) over c = 1…8 at 38,817-token prompts: 1.82× (c=1) to 2.28× (c=8); per-c table in the PR.
Correctness. A needle probe (
ORBITAL-LYNX-7741): 32/32 rows in the first session and every row in the second PASS on exact substring match,cached_tokens = 0, helper engagementlast_prompt = prompt − 1on every ON row. We do not claim token-identical output: MoE routing can flip on near-tied router logits between Metal and CUDA — we have measured exactly that tie on this stack — so the claim is "same answer on these probes", not "same tokens".Behaviour change. With the accelerator enabled,
qwen3_5_moecheckpoints send layers 0..K−1 to a paired helper instead of staying local. Supported helpers: CUDA (Docker) tested; the Mac helper supports the family by construction — it selects an adapter bymodel_typeout of a registry built from every adapter'smodel_types, so registering the type onQwen35Adapteris enough there — but has not been measured on it. Host with this change paired to an older helper: not measured yet — the family is negotiated by name, so I expect the session to be declined and prefill to stay local, and I will verify that before opening the PR rather than assert it. No message-format change. The MTP head never reaches the helper: the adapter keeps.mtp.tensors andlm_headhost-resident, so a 24-layer split is far below the head and the helper holds none of it. Helper memory for K=24 on the 35B: not measured yet (on the 27B the same 24 layers cost 18.7 GiB); it goes in the PR's compatibility notes.Questions before I open a PR
qwen3_5_moebe claimed by the existingqwen3_5adapter, as on the branch, or would you prefer a separate adapter?_qwen35_layers/_plan/_stage. Is that extraction acceptable, or would you rather have a self-containedqwen3_5_moefamily that duplicates ~590 lines?All reactions