Repository navigation
Conversation
ashhart
added a commit
that referenced
this pull request
Nov 16, 2026
…ffine checkpoints, each served once qualified has its row Llama 3's scaled rope (rope_type llama3) builds transformers' inverse frequencies, pinned word for word for Llama 3.1's and 3.2's configs; any other type stays refused by name. A tied config's head reads the embedding table. model_type mistral is admitted with sliding_window absent or null, and 128-wide heads under a wider hidden keep q, o and the caches a query row wide. MLX affine checkpoints at 4 or 8 bits in groups of 32 or 64 with bf16 tables are read in place: the shared row kernels' strided form a window, affine_mm at the row's pitch a prompt chunk, the embedding dequantized as MLX rounds it, a tied head on the embedding's codes; float16 tables are refused by name. Admission compares every field a qualified row shares with the config. No row is added: config_test.zig's expected rows for Llama 3.1 8B, 3.3 70B, 3.2 3B and Mistral 7B v0.3, NeMo and Small 3 wait for their device check. The GEMM control edits the macro form the GEMM moved to, and llama_f64_reference.py reads Llama 3's rope and tied heads.
…o their own file, keeping metal.zig at 600 lines
ashhart
force-pushed
the
lead/llama-mainstream
branch
from
November 22, 2026 07:56
3b7ec92 to
3963325
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
llamafamily on Metal admits only the Nanbeige checkpoints. Every mainstream Llama-architecture config is refused when it is read:rope_type: llama3;tie_word_embeddings;model_type;quantization.This is the code layer that lets the family read them. It adds no served checkpoint: each one is admitted by its own
qualifiedrow after its device check, in a follow-up stacked here.What this changes
Llama 3's scaled RoPE (
rope_type: llama3):core/rope_llama3.zigbuilds transformers' inverse frequencies, following its fp32 steps. A host test pins them word for word for Llama 3.1's and 3.2's configs, using values from transformers 5.3.0 run locally. Any other rope type stays refused by name.Tied heads: a tied config's head reads the embedding table. A tied config that also stores
lm_head.weightis refused by name.model_type: mistral: admitted whensliding_windowis absent or null; Mistral 7B v0.1's window is refused by name. Explicit 128-wide heads under a wider hidden (Mistral NeMo and Small: hidden 5120, query width 4096) keep q, o and the caches a query row wide.MLX affine checkpoints: 4 or 8 bits, in groups of 32 or 64, with bf16 tables, read in place.
affine_mmat the row's pitch, with q|k|v and gate|up read where they're packed.bf16(bf16(s*q)+b)) by a new kernel,ll_embed_affine. A tied head is a row projection over the embedding's codes, as MLX'sas_lineardoes it.Admission: it now compares every field a
qualifiedrow shares with the config, so adding a checkpoint is one row.config_test.zigholds the expected rows for Llama 3.1 8B, 3.3 70B, 3.2 3B (bf16 and MLX 4-bit) and Mistral 7B v0.3, NeMo 12B and Small 24B (2501). A test checks each published config parses to its row.Unchanged: Nanbeige4.3-33B and its INT4 release serve exactly as before.
cmp), and identical 48-token greedy replies.The new paths, on four tiny checkpoints (MLX q4 g64 tied, MLX q8 g32, bf16 tied, and Mistral with Llama 3's band in use):
Kernel contract:
ll_embed_affineis registered with a planted control: one rounding instead of MLX's two.affine_mmare registered as Llama q|k|v forms with two controls, each part written at its own width.ControlEditMissingsince aac12dd) and is fixed with the same edit llama on Metal: Qwen2 checkpoints, Bimo-7B-CyberAgent's bf16 release with its q, k and v biases and YaRN at HF's rounding points #2890 carries.tools/zig/llama_f64_reference.pyreads Llama 3's rope and tied heads. The Nanbeige recipe anddocs/kernel-contract.mdare updated.Issue: n/a for a new family. This admits mainstream checkpoints into the existing
llamafamily under its existing gate: the float64 judge, the near-tie rule and window exactness fromdocs/recipes/nanbeige-4.3-33b-metal.md. Each checkpoint's row lands with its own receipt. It came from the 16 Nov check of competitor gap docs against main, where Llama 3.x and Mistral are the most-served models the family refuses.Stacked on: main.
atc overlap --json: to run after review.config.zig,model.zig,state.zig,weights.zig,native/metal.zig, the controls file, the Nanbeige recipe and the float64 tool. With admission now driven by rows, its bias and YaRN fields become admission fields of their own, and its rope reader can join this one (default, llama3, yarn). llama on Metal: Qwen2 checkpoints, Bimo-7B-CyberAgent's bf16 release with its q, k and v biases and YaRN at HF's rounding points #2890 already conflicts with main by itself.metal_llama_controls.zig; keep both edits.Checks on this head
tools/pr_check.py: 0 errors, 1 advisory warning, the PR number).zig build test-llama(new step, macOS): 98/98. On base, every published config is refused: 3.1 and 3.3UnsupportedLlamaRotary, 3.2 and its MLX copyUnsupportedLlamaGeometry, the three Mistral configsBadLlamaConfig.zig build test-kernel-contract: 205/205.zig build dev-tools: 268/268.zig build native -Dcpu=apple_m1builds.zig build test-goldenandtest-clipass, andfmtandgit diff --checkare clean.zig build test-native: one failure, the qwen27_served reply-end test, which fails on base the same way (test-qwen27-reply-cache-host3 pass, 1 fail).tf-kernel-contract --only llama --rotary-accuracy RECEIPT:SUMMARY 38 kernels: 38 pass gates 1-4, 0 fail, 2 known findings; 17 controls: 17 red as planted, 0 missed; 0 limit problems(exit 0). The 2 known findings are main's existingoffset_infrecord for 4-bitaffine_mm(metal_affine.zig), carried onto its new q|k|v registration.metal masked-V LFM2 prompt nax inf/nan. The base binary fails them the same way, so they come from main.tf-rotary-sweep(COMPLETE, 302,008,320 cases).Receipt
n/a for this layer: no new checkpoint is served, and Nanbeige's served bytes are unchanged (logits compared byte for byte above).
Each checkpoint's qualification, in the follow-up:
expectedintoqualified.contracts.geometriesand decode_vec's served shapes: (32, 8) for 8B, 7B, NeMo and Small, (64, 8) for 70B, (24, 8) for 3B. Then run the family's contract.llama_f64_reference.py) throughllama_teacher_judge.py, with HF's bf16 run as the baseline.bench_openai,bench_concurrent --alone --serial, cold prefill from 2k to 64k, structured output, tools and sampling, and, for Llama 3, contexts past 8,192 where the llama3 band applies.The prompt path needs Metal 4 tensor units, so it runs on an M5 only. The 70B in bf16 needs a 192-256 GB Mac.
Checklist
The title and description match the head commit.
New tests fail before the change, pass after it, and skip cleanly without their dependency.
Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
No precision traded: float16-table checkpoints are refused rather than converted, and Nanbeige's bytes are unchanged.
Synthena (Ash's Agent)