Repository navigation
qwen27: Qwen3.6-35B-A3B on Metal on the routed path, with staged references against float64 - #3239
Conversation
cc5048b to
ee8a658
Compare
|
Thanks @cshintov. One build fix remains after the rebase. At stage_planes.zig:6 and qwen27.zig:52, the code references core.qwen35_stages, but the production tensorfold.zig core does not export it. The host geometry check fails with "root source file struct 'tensorfold' has no member named 'qwen35_stages'". The standalone tools use separate core shims, so they miss this caller. Please export the recorder through the production core and rerun
|
|
Exported |
ee8a658 to
742ebb4
Compare
|
Thanks @cshintov. The production core export now compiles through the actual family recorder caller, and all 35 focused host cases pass with zero new lean findings. The missing-export control fails as expected. We will run the device check on our side on M5 for the native build, staged reference equality and served token equality.
|
|
DEVICE. Thanks @cshintov, the native build and 136 host tests pass, as do 46 contract kernels with all six controls caught. Native stages match across 128/16-row chunks, and solo/plain plus four concurrent drafted replies are identical. The independent references disagree: at reply position 41 MLX chooses 16251 and native chooses 328. On the same teacher-forced context, float64 favors 328; native matches its top-1 at 64/64 positions, MLX at 63/64. Stage bytes also differ between engines, starting at layer 0's mixer. The exact-MLX comparison therefore remains red; we need to settle that reference criterion before calling the gate green. No bound or expected token has been changed.
|
|
Settling the reference question: for a new checkpoint on our routed path, the reference is the float64 forward of the checkpoint's own weights, which
So this is READY, and it's queued to land.
|
|
@cshintov, a correction to my note above. The reference question is settled, but this head can't land until its own CI passes, and three jobs fail on 0343160:
|
0343160 to
ace0d46
Compare
|
Fixed on ace0d46 (rebased onto main e7e2424):
|
|
Thanks @cshintov, the earlier build and CI asks are answered. On an M5 Ultra, all 46 focused contract kernels pass with six controls caught. All 83 stage planes match across chunks, float64 agrees at 64/64 positions, and drafts, concurrency and resumed replies remain exact. The existing dense 27B still needs its default cost resolved. With the cache flag omitted, the greedy four-request median is 3.0355 s against 3.0201 s, +0.51%, with disjoint runs. Cache-off greedy and sampled spans are also disjoint at +0.33% and +0.21%. The default recorder hooks are the shared addition to check; these timings do not locate the cause. One scope gap also remains: this is described as text only, but
|
ace0d46 to
c9987fd
Compare
|
Both points are addressed on c9987fd (rebased onto main 3f1290f). Default cost of the dense 27B. The stage recorder is now compiled in only when the program's root declares
Only the UUID and
Checks on an M4 Pro: |
|
Thank you @cshintov. Both points are resolved. The stage recorder is now built only into tf-qwen27-run, and the served engine's code sections are byte-identical to a build without those hooks, so the earlier default span does not come from this change. --vision now refuses the 35B by name before the tower loads, and the other models keep their paths. The release line in CHANGELOG.md is ours to place, so the collision there is on our side. This is ready to land.
|
c9987fd to
41857b8
Compare
41857b8 to
0fb21b0
Compare
|
Rebased onto main 4f3f564 at 0fb21b0 to clear the conflict with the prompt tail change (881e224).
Checks on an M4 Pro: |
|
@cshintov @ashhart I followed the two documented test commands on Apple M5 Max with Zig 0.17.0 at zig build test-qwen27 test-kernel-contract -Dcpu=apple_m1 -j8 --summary allBoth targets passed, with 82/82 build steps, 413 tests passed and three skips. The first detail I'd add to the PR description is this head beside the kernel-contract result. The rebase comment names the head and the M4 checks, while the description's contract result is from the earlier revision. The head test-merged cleanly against current main Igor Lessio - AIFLOW LABS |
d7f3dd6 to
ce59a24
Compare
ce59a24 to
be8c034
Compare
be8c034 to
8cb4892
Compare
8cb4892 to
b42c940
Compare
… over 2 on main's attention Geometry
…hs (512 experts' rows over 2,048)
… float64 forward One stage vocabulary (families/qwen3_5/stages.zig): the residual stream after the embedding and after each layer's mixer and MLP, then final (the normed rows the head reads, not the residual) and the logits. tools/zig/qwen36_stage_ref.py measures each against float64 of the checkpoint's exact weights; a non-unit final norm fixture refuses a residual labelled final.
…, as the recorder allows While stages record, the last layer counts as tapped, so main's keys-only last layer stays off and the recorded stream and final are real rows. The stage hook (planes and glue) and the admit check move into stage_planes.zig, so the runner needs no forwarding function, and planes.end runs after the round is committed, so a recorder error leaves the runner consistent.
…16 query heads over 2
The A3B config in qwen27/config_test.zig is a new real config: Metal's 27B and HIP admit it, as main's rules did; the 2B, CUDA and XPU keep their refusal. The stage reference test needs mlx, which CI does not install.
… refuses the 35B-A3B
… layer read on main's prompt tail facts
b42c940 to
c278a42
Compare
|
Thank you @cshintov. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
This builds Qwen3.6-35B-A3B (text, no MTP, no images) on main's routed expert path (#1125), as asked when #1009 closed. Slice 1 of #931.
What this changes
qwen27: Qwen3.6-35B-A3B on #1125's routed path...).model.supportedtakes its shape, and the attentionGeometrytakes 16 query heads over 2 (a group of 8) on one Mac. A rank of 8 over 1 is refused. Config tests cover the shape and both refusals.docs/kernel-contract.md: one paragraph on the new widths.tf-qwen27-run --stages DIR). It writes the residual stream after the embedding, after each layer's mixer and MLP, thenfinaland the logits.finalis the normed rows the head reads, not the residual. A fixture with a non-unit final norm refuses a residual labelled final.tools/zig/qwen36_stage_ref.pymeasures each stage against a float64 forward of the checkpoint's exact weights. It reports the local error (each stage fed the engine's own input) and the chained error (from the token ids).finalare real rows.tf-qwen27-run. Every other build, the served engine included, is unchanged by it.--visionrefuses the 35B-A3B by its shape before the tower loads, since its image path is not qualified.Design
The 35B-A3B is the same family as Ornith-1.5-122B with other widths: 256 experts of 512 and a shared expert of 512 over a hidden width of 2,048, and 16 query heads over 2. So it adds no kernels and no loader. The router runs on its stored 8-bit g64 rows, stacked with the shared gate.
Alternatives rejected:
Receipts
Host and contract, current head
0fb21b0ab(on main4f3f564c8), M4 Pro (no tensor units), macOS 26.5:zig build test-qwen27 test-kernel-contract -Dfixed-cpu: 82 of 82 steps, 218 of 218 tests pass.zig build native tf-qwen27-run test-qwen35-rules-host test-qwen35-layers-host -Dfixed-cpu: all steps pass.tf-kernel-contract --only qwen27: 36 kernels pass gates 1-4, 0 fail, 0 known findings; 4 controls red as planted, 0 missed; 0 limit problems.tools/pr_check.py --base upstream/main: 0 errors.zig build test-qwen27 test-kernel-contract -Dcpu=apple_m1passes on this head (82 of 82 steps, 413 tests, 3 skips), from @AIFlowML's run below.Real checkpoint (
mlx-community/Qwen3.6-35B-A3B-4bitat38740b84), M4 Pro, headcc5048b6con mainaaac299d1, before the last two rebases.tf-qwen27-run --max-tokens 64 --chunk 128 --compare-chunk 16 --seams 16, greedy:All three replies are token for token the same on
cc5048b6c, on the same commits over mainc34ff562c, and before that rebase. The staged references below were measured on the run before that rebase. The real-checkpoint run was not repeated on0fb21b0ab.Staged references for the long prompt plus 72 teacher rows, against a float64 forward of the same weights:
finallocal max: 0.19%.Not run, and why
draft: false. This engine's Metal drafter reads DFlash2 contracts only (the 27B's and Ornith's). The 35B-A3B's only published drafter is DFlash v1 (sliding-window layers, no selector), so there is no drafted Metal run to compare. A drafter for it is a separate PR.zig build test. It was not run on this host; the qwen27 and kernel-contract suites above cover the changed files.