Repository navigation
qwen27 metal: serve the tied 0.8B and 4B, as CUDA does - #4634
joshuaswarren wants to merge 4 commits into
Conversation
…n rules CI on ashhart#4634 found what the target-Mac runs could not: the shared-reader counting tests assert the old admission totals, and the lean checker counted three comment problems the local dense steps never see. - qwen35_layers_host: the real-configs test now counts 26 admitted (config, backend) pairs - the tied 0.8B and 4B on Metal's 27B engine, the rows ashhart#3702 admits; the layer-pattern table itself is unchanged, so relaxed stays 0 (what moved is the tied-head gate below the pattern read, not the patterns). ashhart#1863's table takes one more row per the same admission (8 across the five entry points). - lean: the tied-head comments fit 120 columns and the routing note is one line.
|
Thanks @joshuaswarren. The tied-head loading direction looks good, but a few fixes are needed.
|
… twice Review on ashhart#4634 (ashhart): - Geometry.check admitted every GQA-16 pair, which let 16/1 in; only the one-Mac 32/2 is qualified. Keep the quotient-6 and quotient-4 arms and restore the exact 32/2 pair, so the rank refusal stays. - model.zig's neighbour test still expected the tied 4B refused; it is qualified now, so the test admits it. - the two qwen35 rules host counts move with the tied admissions: bases 6 -> 7 and cases 360 -> 420 in the row-and-value sweep; Metal 27B's zero-head bases 8 -> 18 and the without-head_dim derived 13 -> 18. - info's startup budget counts the embedding once while a tied load keeps it and packs a second head over the same tensors: qwen27_reserve adds the embedding module's checkpoint bytes when the config is tied (0 when the tensors cannot be read).
|
All three review points are fixed and pushed at
Gate: the (The red |
|
@joshuaswarren Thanks. The 32/2 narrowing, the 4B neighbour test and both rules counts are in. Four things are left. The first stops the Mac build, and the rest are on tied checkpoints:
|
|
|
|
Direct verification of fix 1 on this head: |
|
Status on the gate: GitHub's queue dropped the check runs for the current head ( |
|
CI status: the runs were dropped twice — the original queue for What has run, locally (Linux, Zig 0.17.0) at the content head:
The two macOS-only host suites ( |
…gate Upstream main landed its own tied-head mechanism (Config.tied_head, parseTied under TF_QWEN27_TIED_HEAD=1, tied_head.zig repack, reserve pricing) after ashhart#4634's review, superseding this PR's mechanism commits. This reworked PR carries the review's remaining content on that mechanism: the tied 4B and 0.8B size rows, the 0.8B's 8/2 shape in Geometry.check, the neighbour test admitting the 4B, and the new qualification test refusing strangers.
a08939e to
894249b
Compare
|
Reworked per the supersession: upstream main's own tied-head mechanism ( Whether the two sizes run tied by default stays behind your Gates at this head ( |
|
Thanks @joshuaswarren for moving this onto the shared tied-head mechanism. Two small fixes are still needed:
|
…gate Upstream main landed its own tied-head mechanism (Config.tied_head, parseTied under TF_QWEN27_TIED_HEAD=1, tied_head.zig repack, reserve pricing) after ashhart#4634's review, superseding this PR's mechanism commits. This reworked PR carries the review's remaining content on that mechanism: the tied 4B and 0.8B size rows, the 0.8B's 8/2 shape in Geometry.check, the neighbour test admitting the 4B, and the new qualification test refusing strangers.
…put kv_heads in the size-row comparison ashhart's two review fixes on ashhart#4634: - the tied 4B and 0.8B positives and the stranger now go through parseTied(.., allow_tied=true), so the positives stop at their intended shape admission instead of TiedEmbeddingHead, and the stranger reaches UnqualifiedQwenShape; - qualifiedSize compares kv_heads from the Size rows (27B/9B/4B kv4, 0.8B kv2) and the dense conjunct drops its hidden==1024 kv special-case, closing the exact-row-wrong-KV hole; two wrong-KV regression cases refuse UnqualifiedQwenShape before any weights or kernels load.
894249b to
03edf1c
Compare
|
Both fixes are in, pushed at
Gates at |
|
Thanks for reworking this on the shared tied-head support and for addressing the earlier feedback so quickly. The tied-aware positive and stranger cases now exercise the intended admission path, and exact KV counts are part of shape qualification. Two corrections are still needed before this is ready:
Once those are corrected, the remaining device checks can focus on exact token agreement for the tied 0.8B and 4B models. Thanks again for the quick turnaround.
|
|
The one failed job (
If you want it re-checked, a rerun of |
|
Thank you @joshuaswarren. The tied-aware parsing and production KV-count check are in place. Both latest requests remain on this head: the wrong-KV tests still keep the correct KV counts and change value heads instead, and the 8/2 exception also admits the previously refused two-rank 9B shape. Please correct those test arguments and preserve that split-attention refusal while admitting the whole 0.8B model. When we bring it up to date with main, we'll keep main's newer GQA8 shape beside the 8/2 one.
|
|
Review findings addressed at head c655e6b.
Tests run on the touched units: attention_plan 34/34 pass (incl. "target attention reads every config dimension without widening kernel qualification") and model 26/26 pass (incl. "a qwen3_5 dense checkpoint opens at the 27B and 9B shapes and refuses its neighbours"). |
|
Thanks @joshuaswarren. Both latest fixes are confirmed: the tests now change KV counts themselves, and the whole 0.8B 8/2 shape admits while split 9B 8/2 still refuses. This is ready for the tied 0.8B and 4B token checks. The attention merge is on our side, preserving main’s GQA8 and solo-prompt support alongside the whole-model exception, and the resulting file-size limit. The older 0.8B receipt does not yet qualify both sizes on the current tree.
|
|
Thanks for confirming both fixes — head is Token checks on this tree, CUDA arm on the RTX 5060 Ti (sm_120, aarch64 Linux; server built 50 sequential completions per size, one at a time:
Both sizes hold one deterministic token stream each on the tied head at this head. |
…gate Upstream main landed its own tied-head mechanism (Config.tied_head, parseTied under TF_QWEN27_TIED_HEAD=1, tied_head.zig repack, reserve pricing) after ashhart#4634's review, superseding this PR's mechanism commits. This reworked PR carries the review's remaining content on that mechanism: the tied 4B and 0.8B size rows, the 0.8B's 8/2 shape in Geometry.check, the neighbour test admitting the 4B, and the new qualification test refusing strangers.
…put kv_heads in the size-row comparison ashhart's two review fixes on ashhart#4634: - the tied 4B and 0.8B positives and the stranger now go through parseTied(.., allow_tied=true), so the positives stop at their intended shape admission instead of TiedEmbeddingHead, and the stranger reaches UnqualifiedQwenShape; - qualifiedSize compares kv_heads from the Size rows (27B/9B/4B kv4, 0.8B kv2) and the dense conjunct drops its hidden==1024 kv special-case, closing the exact-row-wrong-KV hole; two wrong-KV regression cases refuse UnqualifiedQwenShape before any weights or kernels load.
…unts in the wrong-KV cases
…_masks.zig, so attention_plan.zig keeps to 600 lines With ashhart#4634's whole_attention beside main's solo_prompt, attention_plan.zig came to 607 lines. prefixMasks, a check only the prefix-kernel test reads, moves whole to attention_plan_masks.zig; attention_plan.zig keeps a one-line alias, so the test and the plans step's name filter are unchanged. No behaviour change. Re-pins attention_plan.zig (its pin was stale on the PR head), main's note with ashhart#4634's segment.
c655e6b to
816a2cc
Compare
|
At
Igor Lessio - AIFLOW LABS |
What this changes
The qwen27 Metal engine refused
tie_word_embeddings, and engine routing sentevery tied checkpoint to the pinned 2B engine, which then refused any other
geometry - so Qwen3.5-0.8B and 4B had no Metal engine at all (#3702). CUDA
already admits the tied head and serves it from the embedding; the Metal 2B
path admits it for the 2B's pinned geometry. This brings the 27B Metal engine
to the same rule, and qualifies the two tied sizes it needs.
Three gates opened, test-first, each with a failing test first:
tiedrow read stays, the refusal goes, and the parsecarries
Config.tied.model.embed_tokens(the same physical tensors must load at one width) andpacks that module into the head Linear; the checkpoint has no
lm_head.size reroutes.
supported()gains the 4B (2560/9216/32) and 0.8B (1024/3584/24)rows;
kv_headsandk_headsmove into the size row and the fixedkv_heads == 4conjunct goes. Their projections satisfy the kernel contract(k mod 64, n mod 32, head_dim 256, dk/dv 128, rope 64), which the new test
asserts; a stranger size still refuses.
of three literal heads/kv pairs, so the 0.8B's 8-over-2 shape takes the same
group-4 shader build the 9B uses. A quotient of 5 still refuses.
Measured receipts (Mac Studio M1 Ultra, macOS 26.6.2, Mac13,2, Qwen3.5-0.8B-4bit
mlx-community/Qwen3.5-0.8B-4bit@da28692b, model.safetensors sha256f5a0d9dd…)Metal arm, this branch at
85f898d1, binary sha2565746bb20…: serve--context 8192 --parallel 1 --no-drafts --prompt-cache-gib 0, 50 completionsat temperature 0, max_tokens 128, one run at a time. All 50 produce one
identical token sequence,
token_sha256 8f50a6c33cf732d1ffe4931b641115a94c07f9141fe6edfb66a011a1af669ada;p50 0.9169 s and p50 138.82 tok/s per completion (server-reported).
CUDA arm, main
2eecb9635on an RTX 5060 Ti (-Dsm=120), binary sha2560775f492…, same checkpoint, same prompt:token_sha256 8f50a6c33cf732d1ffe4931b641115a94c07f9141fe6edfb66a011a1af669adaHost tests:
test-qwen-dense-route-hostandtest-qwen-dense-geometry-hostpass on the target Mac (119/119). Fixes #3702.