Skip to content

bench: refresh the 0.7.0 sweeps and fix the dtype, rotary and rope defects they exposed - #1617

Merged
inureyes merged 153 commits into
mainfrom
bench/0.7.0-refresh
Sep 8, 2026
Merged

inureyes merged 153 commits into
mainfrom
bench/0.7.0-refresh

Conversation

@inureyes

@inureyes inureyes commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

Refreshes the 0.7.0 benchmark sweeps on M1 Ultra and M5 Max, and fixes the defects the sweeps exposed. The measuring turned out to be the smaller half: most of the diff is the runtime bugs that only showed up once two machines were compared row by row.

Performance

Gemma3n held two dtypes in one checkpoint. The load policy kept the language MLP bf16 and converted everything else to f16, and MLX promotes f16 met with bf16 to f32, so every boundary between them promoted and the decode path read promoted weights the whole way down. Loading uniformly bf16 moves M5 Max decode from 38.02 to 47.48 tok/s and prefill from 2143 to 2371, taking decode from 78% of mlx-vlm to 97%. This is not a claim that bf16 beats f16: on families with no forced-bf16 subset the two land within noise, qwen2.5-0.5b-bf16 at 401.8 against 397.3 and llama-3.1-8b-bf16 at 33.07 against 33.02. The mixture is what costs, so every other family keeps converting.

The 3D rotary dropped the input dtype. cos and sin are built in f32 on purpose, and the rotated result left the function as f32, carried through attention and the output projection, and made every later layer promote its own weight to match. Restoring the dtype is worth up to 2.45x on M1 Ultra and 3.26x on M5 Max, largest on the non-quantized checkpoint and smallest on 4-bit dense, in proportion to the weight bytes the promotion reached.

Two defects in nemotron_nas, and the family had never run. b429947c fixed the rotation order and was insufficient on its own; the remaining defect read only factor out of rope_scaling and applied 1 / factor as a uniform position scale, which is the linear scheme, to a checkpoint declaring rope_type: "llama3" whose rescaling is piecewise in the frequency. Before the first fix the model emitted a single "I"; after it, a fluent loop; only with both does it answer. It measures 19.37 against mlx-lm's 19.55 tok/s on the same machine, 99%.

Method

Three of the day's mistakes came from reading a tool's output without checking its premise, so the guards are part of the diff.

bench_decode.sh stamps mlxcel_commit from git, not from the executable, so a sweep run without rebuilding after a rebase records provenance its binary does not have. That happened, and the rows read as "this change does nothing on this machine" for a change worth 3.26x there; both arms of the follow-up A/B were the same stale binary, so they agreed. The harness now refuses to run when the source is newer than the benchmark binary.

A verification at a length that cannot reach the changed branch is not evidence. The nemotron_nas rope fix first passed a 1300-token needle test, but original_max_position_embeddings is 8192 and the llama3 low-frequency band only carries positions past it. Re-run at 14737 tokens the fixed arm answers and the reverted arm does not, which is the test discriminating. docs/benchmarks.md gains the falsification condition.

Catalog

Sixty directories held a name that disagreed with the checkpoint inside them: llama-3.1-8b-4bit held Meta-Llama-3.1-8B-Instruct-4bit, nemotron-h-30b-4bit held NVIDIA-Nemotron-3-Nano-30B-A3B-4bit, glm4-flash-4bit held GLM-4.7-Flash. A benchmark row is read by its name, and a table that shows a bf16 checkpoint beside a 4-bit one is only readable if the names say which is which. docs/model-catalog.md documents the rule and docs/model-catalog.tsv records what each name rests on, including the aliases that join a past-dated row to a current one.

Nine duplicate directories were byte-identical to a correctly named twin and were dropped, and two were names with no model behind them: a config, a README and no shards at all, tens of gigabytes unmaterialised in .cache/ blobs, both listed for transfer to the other host. The catalog now carries a shard verdict per host so directory presence is no longer the only check.

Known

#1717 and #997 track a sporadic NaN in the Granite 4 Vision text-only forward, about one process in six, present before this branch and unrelated to it. The gate is otherwise clean: fmt, clippy --workspace --all-targets, and 10532 tests.

The harness hardcoded `hardware` to `NVIDIA_GB10_122GB`, so a CSV produced anywhere else silently carried the GB10 label and could not be trusted beside the GB10 ladder it exists to sit next to. It now detects the host the way `bench_decode.sh` does: `Apple_M5_Max_128GB` here, an `nvidia-smi`-derived string on CUDA.

Image cells sent the fixture as an absolute `file://` URL and every one returned HTTP 400 once #1481 confined request media. `resolve_media_file_in` strips the leading separator and joins onto the media root, matching llama-server b10621, so an absolute path is probed under the root and reported missing while a relative one resolves. The fixture is now inlined as a base64 `data:` URI, which needs no `--media-path` and keeps the ladder runnable on a host where nobody set one. Visual token counts match the GB10 pass exactly: 71 on Qwen3-VL-Embedding, 264 on Llama-Nemotron-VL-Embed.

Refs #1612
Full text and VLM sweep on 0.6.0 with `--cooldown 30 --big-cooldown 30`, plus speculative, batched-serving, and embedding/rerank passes. 175 text checkpoints walked, 161 measured, and no decode regression across the 159 comparable with 0.4.0-rc.1.

The sweep now runs under a 90 GB weight budget (`BENCH_MEM_OVERHEAD_FACTOR=1.209`), so `deepseek-v3-4bit` at 99.96 GiB records `SKIP:oom_estimate` instead of being launched and recorded as a failure.

Two fixes that landed after 0.4.0-rc.1 changed the measured condition rather than the speed, and the docs now say so before any delta is read: #792 stopped upscaling every image to a fixed square, and the chat template now renders Llama's official prompt at 42 tokens against 98 before, matching the canonical tokenization exactly. Both shorten the prompt, and `prefill_tok_s` is prompt-length sensitive, which accounts for 10 of the 13 double-digit prefill drops.

Three stale claims are corrected: the GLM-5 pair is an interrupted local download rather than a load-path defect, `minicpm-v-4.6-mxfp4` passes now, and `deepseek-v3-4bit` is a capacity exclusion. The 12 duplicate checkpoint directories are recorded so they stop inflating the model counts.

`docs/benchmarks.md` command examples now match the actual script interfaces; `bench_decode.sh` takes a positional path and has no `-m` or `--runs`.

Refs #1612, #1613, #1614, #1615
@inureyes inureyes added type:docs Documentation improvements or additions area:benchmark Benchmark harness and performance measurement (bench_*.sh, /update-benchmarks) priority:medium Medium priority labels Sep 4, 2026
`mlx_version` reads `Cargo.toml`, which does not move between releases, so every sweep taken across a development cycle records the same version however far `main` has travelled. A cross-hardware table assembled over weeks then cannot tell a hardware difference from a code difference, which is exactly the shape this branch is for: it collects the other hosts' sweeps, taken at different times, while being rebased forward.

`bench_decode.sh` now writes an 8-character `commit` column, with `-dirty` appended when tracked files were modified. Untracked files are excluded, since a stray note does not change the measured binary. The column is appended last so positional readers of column 11 (`mlx_version`) keep working, and it sits before any trailing `SKIP:` or `FAIL:` token so classification still reads the last field. `bench_embeddings.py` pins its existing commit capture to 8 characters to match.

The five CSVs from this sweep are backfilled with `b2ff1eee`, the commit the embeddings CSV had already recorded on its own.

`docs/benchmarks.md` states the rule: check that hosts share a commit before attributing a gap to hardware, and say so where they do not.
The branch now carries `v0.7.0-beta.1` while the CSVs record `mlx_version` 0.6.0, which reads as stale data unless the relationship is written down.

The sweep ran at `b2ff1eee`, when `Cargo.toml` still said 0.6.0, and the `commit` column records that. The tag (`64f5d9b4`) is exactly one commit later and touches no compiled source: the diff is manifests, `Cargo.lock`, `CHANGELOG.md`, `CITATION.cff`, `README.md`, `docs/environment-variables.md`, the recipes registry, and an issue template. `git diff --name-only b2ff1ee v0.7.0-beta.1 | grep -E '\.(rs|cpp|metal|cu|h|hpp)$'` returns nothing, so these are the beta's numbers rather than a release behind.

Sweeps taken from here record `0.7.0-beta.1` in `mlx_version`, which leaves the `commit` column as the discriminator within the cycle.
One CSV column named `mlx_version` carried three different things depending on which script wrote it: the mlxcel crate version from `bench_decode.sh` and `bench_embeddings.py`, an actual MLX release in files written before the value stopped being hardcoded on 2026-06-12, and `mlx-lm-<v>` or `mlx-vlm-<v>` from `bench_mlxlm.py`. The command doc had to document the mismatch as a quirk to preserve.

Columns are now named for what they hold: `mlxcel_version` (88 files), `mlx_version` kept only where it really is an MLX release (15), and `baseline_version` for the Python baselines (26). Every header was decided per file from its own values rather than by position, and an audit confirms no column is misnamed. The five CSVs from this campaign additionally gain `mlx_commit`, the pinned MLX C++ revision, because a pin bump changes kernels without moving either mlxcel field; `commit` becomes `mlxcel_commit` for symmetry.

Those five are relabelled `0.7.0-beta.1`. They ran at `b2ff1eee` when `Cargo.toml` still said 0.6.0, but the tag is one commit later and touches no compiled source, and `mlxcel_commit` pins the revision regardless.

`mlxcel_version` stays at column 11, so the positional readers keep working.
`scripts/bench_embeddings.py` writes one server log per checkpoint to its default `--logdir`, `benchmarks/perf_logs/`. Those are transient run artifacts rather than results, they embed absolute local paths, and the GB10 embedding pass did not commit them either. An overly broad `git add -A` swept 18 of them in.

Untracked and added to `.gitignore` so the harness's default output cannot be committed again.
`bench_decode.sh all` enumerated every directory under `MODELS_DIR` with no notion of checkpoint identity, so a checkpoint present under two directory names (a re-download alias, or a symlink into a shared model store) was loaded, prefilled, decoded, and cooled down twice and landed in the CSV as two rows. On the M1 Ultra host `models/mlx` holds 15 such duplicate groups covering 16 redundant directories and 124.5 GB of redundant weights, present in every committed sweep back to `metal_m5max_2026-04-04.csv` and reaching `docs/benchmark_results/model_tests_m1ultra.md` and `docs/benchmark_results/model_tests_m5max.md` as separate table rows for three of the groups.

`all` mode now computes a cheap checkpoint identity key before the first model runs: sha256(config.json) plus the sorted (basename, byte size) list of every *.safetensors shard, with no weight hashing. This does not collapse checkpoints that differ only in quantization or weight dtype, since their config.json differs in the quantization block (verified against the bitnet-b1.58-2b-4t / bitnet-b1.58-2b-4t-4bit pair). Directories that resolve via realpath to the same physical path are also collapsed, independent of content. A directory with no config.json is never grouped by content and is always measured. The survivor in a group is the first directory the sweep's own glob enumeration reaches; every other member is skipped and recorded as its own CSV row with the trailing status SKIP:duplicate_of=<survivor-name>, so total row count is unchanged. The collapsed groups print to stderr once before the first measurement. --no-dedup restores the prior behavior exactly, and single-model mode is untouched.

Verified the grouping helper against MODELS_DIR=models/mlx: it found the same 15 groups and 16 redundant directories the issue's evidence table lists, byte-for-byte. Built a temporary MODELS_DIR of symlinks covering two small duplicate groups (gemma-3-1b-it-4bit/gemma3-1b-4bit and qwen2-0.5b/qwen2.5-0.5b-4bit) plus one control model and ran a real `all` sweep both with and without --no-dedup: the dedup run measured one row per group plus the two SKIP:duplicate_of alias rows, and --no-dedup measured all five directories individually. Ran bash -n and shellcheck on the script; no cargo command was run since nothing under src/ changed.

Refs #1615
The "Why the image cells use a data URI" section described a rule that PR #1620 changes. It said an absolute `file://` URL can never resolve under `--media-path`, which was true when this pass ran and is no longer true: the concatenation stays primary, and an absolute reference whose concatenated candidate does not resolve is now canonicalized and put through the same containment check, so a file inside the root is read and one outside it is refused as an escape rather than as a missing file.

The observations from the run are kept in the past tense, since they record what the M5 Max pass actually saw. The reason the harness still sends a base64 `data:` URI survives the fix unchanged: a data URI needs no server flag, which keeps the ladder reproducible on a host where the operator never set `--media-path`.

The stale docstring on `_image_data_uri()` in `scripts/bench_embeddings.py` is named as a residue rather than fixed here, because that file is one of the many this PR already rewrites and the docstring is still right about why the harness uses a data URI. It changes no measurement.

Refs #1612
inureyes added a commit that referenced this pull request Sep 4, 2026
## Summary

`--media-path` permitted `file://` reads only for references interpreted as relative to the root, so the absolute form every other tool accepts was the one form that could never work. `resolve_media_file_in` stripped `file://`, stripped the leading separators, and joined the remainder onto the root, reproducing llama-server b10621's `media_path + file_path`. `file:///srv/media/cat.png` under `--media-path /srv/media` was therefore probed at `<root>/srv/media/cat.png` and answered with `file does not exist or cannot be opened`, naming a file that is present and readable, while the candidate actually probed was never disclosed.

The concatenation stays the primary resolution, so b10621 compatibility and every containment property already asserted here are unchanged. On top of it, when the concatenated candidate does not canonicalize and the reference is itself absolute, the reference is canonicalized and handed to the same `starts_with(root)` test the joined candidate goes through. There is no second containment path: an absolute path inside the root resolves to exactly what the relative spelling resolves to, and one outside the root is refused as `Escape`. The fallback is gated strictly on `Path::is_absolute`, so a relative reference can never canonicalize against the server's working directory.

## What changed

- `src/server/media_root.rs`: the absolute-path fallback inside `resolve_media_file_in`, a private `unresolvable()` helper that logs the probed candidate at `debug` and keeps it out of the returned error, and the `--media-path` resolution rule written into the module documentation.
- `src/server/media_root.rs`: `MediaPathError::Unresolvable` now ends with `(paths are resolved relative to the --media-path root)`. Upstream ends the sentence at the path, which left an operator whose file is present and readable with nothing to go on.
- `src/server/media_root_tests.rs`: five new cases (absolute inside the root equals the relative form, absolute outside the root is an `Escape`, a relative reference never reaches the working directory, the three short forms still agree, and the 255-byte cap refuses an over-long absolute path before the fallback), plus the two extra assertions on the unresolvable message: it states the rule and it does not disclose the root.
- `src/server/media_root_tests.rs`: `an_absolute_looking_path_is_concatenated_not_joined` now expects `Escape` rather than `Unresolvable` for `file:///etc/passwd`. The file is still never opened, so the security property is unchanged; the half of the test proving the concatenation is still primary is untouched.
- `src/cli/multimodal_compat_args.rs` and `docs/llama-server-compat.md`: the resolution rule stated with one accepted absolute form and one accepted relative form, plus the 255-byte cap that applies to the whole path and runs before either form is tried.
- `compat/llama-server/b10621/multimodal-and-audio.json`: two new entries on the `--media-path` entry's checked `divergence` list, not prose in `notes`. Upstream answers every absolute spelling with `file does not exist or cannot be opened`; mlxcel now reads the one inside the root and answers the one outside it with `file path escapes the --media-path root`. And mlxcel's unresolvable sentence carries a clause upstream's does not, with the probed candidate confined to the debug log.

The change lands in the shared resolver. `media_root::resolve_media_file` has exactly one caller, `read_confined_bytes_with_limit` in `src/server/media.rs:1437`, reached from `try_read_image_url_with_limits`, which serves embeddings, rerank, chat, responses and Anthropic image parts, so every live handler gets it at once.

## Verified end to end

`nvidia/llama-nemotron-embed-vl-1b-v2` from the issue is not on this host. The check ran against `models/mlx/qwen2.5-vl-3b-instruct` on `/v1/chat/completions`, which reaches the identical funnel, with `--media-path <repo>/tests/fixtures`, once with a binary built from `main` and once with this branch. The chat route answers `400 image resolution cardinality mismatch` when an image part is dropped, so HTTP status alone separates an accepted image from a refused one.

| URL in the request | before | after |
|---|---|---|
| `file://<repo>/tests/fixtures/test_image.png` (absolute, inside root) | 400, `file does not exist or cannot be opened: <abs path>` | **200**, image consumed |
| `file://test_image.png` | 200 | 200 |
| `test_image.png` | 200 | 200 |
| `file:///test_image.png` | 200 | 200 |
| `file://<scratch>/outside/outside_image.png` (absolute, outside root) | 400, `file does not exist or cannot be opened: <abs path>` | 400, `file path escapes the --media-path root: <abs path>` |
| `file:///etc/passwd` | 400, `file does not exist or cannot be opened: /etc/passwd` | 400, `file path escapes the --media-path root: /etc/passwd` |
| `file://absent.png` | 400, `file does not exist or cannot be opened: absent.png` | 400, `file does not exist or cannot be opened: absent.png (paths are resolved relative to the --media-path root)` |

On the last row the server logged `DEBUG mlxcel::server::media_root: local media reference did not resolve under the --media-path root reference="absent.png" probed=<repo>/tests/fixtures/absent.png`. The probed candidate appears there and nowhere in the response.

## Test plan

- [x] `cargo test --profile test-fast --features metal,accelerate --lib server::media_root` (20 passed, including the five new cases and the eight pre-existing containment tests)
- [x] `cargo test --profile test-fast --features metal,accelerate --lib server::media::` (42 passed) and `--lib llama_compat` (3 passed)
- [x] `cargo test --profile test-fast --features metal,accelerate --test llama_compat_manifest` (4 passed)
- [x] `python3 scripts/ci/check_llama_compat_manifest.py`
- [x] `cargo clippy --lib --tests --features metal,accelerate -- -D warnings`
- [x] `cargo fmt --all -- --check`
- [x] End-to-end before/after against `models/mlx/qwen2.5-vl-3b-instruct`, table above

## Two premises in the issue that did not hold on main

The issue was filed minutes before PR #1617 opened and its file references point at that branch, so two of them needed correcting before implementing.

- `docs/benchmark_results/embeddings-rerank-m5max-2026-09-04.md` does not exist on `main`; it exists only on `bench/0.7.0-refresh`. The acceptance criterion about its "Open finding" was also already satisfied there before this work started: the section reads "Why the image cells use a data URI" and already described the relative-only rule accurately. The real remaining edit is the opposite of what the issue asked, because this change makes that description stale, and it is committed on `bench/0.7.0-refresh` rather than here.
- `scripts/bench_embeddings.py` does not claim `file://` is refused outright at `:106` and `:171`. On `main` it builds `f"file://{IMAGE}"` from an absolute `IMAGE`, which is exactly the failing form; on `bench/0.7.0-refresh` it already sends a base64 `data:` URI through an `_image_data_uri()` helper whose docstring described the pre-change behavior correctly. That docstring is stale after this change, but the helper exists only on `bench/0.7.0-refresh`, and that file is one of the 123 files PR #1617 already rewrites, so the correction is deferred to a follow-up on that branch rather than made here or there. It documents why the harness sends a data URI, which is still the right reason, and it changes no measurement.

## Where each acceptance criterion is satisfied

Satisfied on this branch: the absolute form inside the root is accepted through the shared resolver; an absolute form outside the root is an `Escape` with the symlink and traversal tests unchanged; the three short forms still resolve; the unresolvable error states the rule while the probed candidate stays in the debug log; `--help` and `docs/llama-server-compat.md` state the rule with both forms; the divergence is recorded as a checked field on the `--media-path` manifest entry.

Not on this branch: the acceptance criterion covering `docs/benchmark_results/embeddings-rerank-m5max-2026-09-04.md`. That document lives only on `bench/0.7.0-refresh` (PR #1617), which is deliberately staying open until the M1 Ultra, M3 Ultra and GB10 sweeps land in it, so its update is a separate commit there. This PR can merge and close the issue while that part is still unmerged.

Closes #1612
The `_image_data_uri` docstring and the `--media-path` comment both described the pre-#1612 server, where only a relative `file://` URL resolved and an absolute one was concatenated onto the root and reported missing. PR #1620 kept that concatenation as the primary resolution and added a fallback that canonicalizes an absolute reference and puts it through the same containment check, so both spellings resolve now.

Comments only. The harness still sends a base64 `data:` URI, for the reason it always did: that needs no server flag, so the ladder stays reproducible on a host where the operator never set `--media-path`.

Refs #1612
`speculative_bench` drove only a Gemma 4 Unified target until #1613 replaced that match with per-variant adapter selection and added the Qwen 3.8 27B pairings to `REACHABLE_PAIRINGS`. This records the first sweep run against that binary. Measured on the Mac Studio M1 Ultra 128 GB (Metal), mlxcel 0.7.0-beta.1 at `a74348f8`, MLX pin `9a795735`, `speculative_bench --sweep --batch 1 --max-tokens 128`: 16 rows, 4 baselines, 9 measured MTP rows at K=2/4/8 across Gemma 4 31B, Gemma 4 Unified 12B and Qwen 3.8 27B, and the 3 DFlash rows still deferred on their own blocker.

Every MTP pairing reads below 1.00x on this host and acceptance is not the reason: Gemma 4 Unified 12B accepts more here than on M5 Max at the same K (39.6% and mean accepted length 1.19 at K=4 against 35.0% and 1.05) and still lands at 0.74x where M5 Max reads 1.57x. The verify round is the difference, at 2.70 classic decode steps against 1.27, which is the reading already recorded in `speculative-decoding-m1ultra-2026-08-19.md` and the basis of the static gate that declines B=1 MTP on Apple GPU generation 13.

K=8 splits by drafter family. The Gemma 4 assistants clamp to their configured block size of 4, so acceptance and mean accepted length are identical at K=4 and K=8. The `qwen3_5_mtp` head honors the wider request instead, proposing 7 per round against 3 while accepting the same 1.51, which drops acceptance to 21.6% and throughput to 9.3 tok/s.

The M5 Max matrix keeps its own numbers. Its `unsupported target` cell and the two paragraphs explaining it now say the harness restriction was lifted and that an M5 Max re-run against a binary carrying the fix has not been made, rather than describing a limitation that no longer exists. The CSV index row and the overall-status row are updated for the same reason, and the M1 Ultra reachable-pairings table keeps its older reading with a pointer to the new matrix.

Refs #1613
inureyes added a commit that referenced this pull request Sep 4, 2026
## Summary

`run_mtp` in `src/bin/speculative_bench.rs` matched `LoadedModel::Gemma4Unified` and bailed on every other variant with `std::mem::discriminant`, so the bench could produce MTP numbers for exactly one checkpoint. Every adapter the other families need already exists and the server burst path already dispatches them, so the harness was the only place pretending the support was absent. This replaces the unwrap with per-variant adapter selection and adds the Qwen 3.8 pairings the restriction was blocking.

## What changed

`src/bin/speculative_bench.rs`: `run_mtp` now selects the `MtpTarget` adapter per `LoadedModel` variant, mirroring `src/server/batch/speculative_burst.rs`. Gemma 4 text, VLM and Unified wrappers take their `gemma4_mtp_target` adapter (block-size-armed, because their rotating cache is sized from it); Qwen 3.5 text, MoE and VLM wrappers take their `qwen3_5_mtp_target` adapter. The drafter is loaded, compat-checked and bound against the `LoadedModel` enum's own `LanguageModel` impl, and the per-sequence release goes through the same reference, so only the adapter construction needs a match.

`src/bin/speculative_bench.rs`: the warm-up burst, the timed generate, the acceptance capture and the sequence release moved into one `run_mtp_timed` function generic over `T: MtpTarget`. Each variant arm calls it with its own adapter constructor; the timed body is not copied per variant.

`src/bin/speculative_bench.rs`: an unsupported variant now fails with a message naming the loaded variant, the target directory and the supported families, rather than printing `Discriminant(26)`. That check runs before the drafter is loaded, the same ordering the burst path uses and for the same reason: without the hoist a `validate_target_compat` hidden-size mismatch fires first and describes a drafter problem for what is a target problem. The variant name comes from the burst path's own label table, which reports anything outside the speculative-capable set as `other`, so the message names the target directory too; widening that table is out of scope here.

`src/bin/speculative_bench.rs`: Qwen 3.5 MTP exactness is Metal-only in the server path, so the bench declines the same way when `mlxcel_core::metal_is_available()` is false and records the reason as that row's status instead of emitting a number the runtime cannot vouch for. Drafter load failures, `validate_target_compat` mismatches, missing checkpoints and `block_size < 2` all stay per-row statuses and the sweep still completes its remaining rows.

`src/bin/speculative_bench.rs`: `REACHABLE_PAIRINGS` gains a `qwen3.8-27b-4bit` baseline (`BenchKind::None`) and the same target paired with the `qwen3.8-27b-mtp-4bit` drafter (`BenchKind::Mtp`, `block_size: Some(4)`).

`src/server/batch/speculative_burst.rs` and `src/lib.rs`: `model_variant_label` is `pub` and re-exported at the crate root. The bench is a separate crate from the library, so `pub(crate)` would not reach it, and the re-export is what lets the bench reuse the existing table instead of carrying a second copy of it. No other change to `speculative_burst.rs`.

`docs/benchmarks.md`: the paragraph claiming the 31B pairing "runs once the checkpoints are present in the model store" was not true before this change, since the target-variant gate rejected the 31B target with both checkpoints on disk. It now records that and the widened family list.

## Scope beyond the issue text

`resolve_model_dir` probed `<CARGO_MANIFEST_DIR>/models/<name>` and then `../mlxcel-internal/models/<name>`. On a host whose checkpoint store is `models/mlx/<name>` neither probe resolves, so every pairing in a `--sweep` silently falls through to the "checkpoint missing on disk" skip: the sweep completes, reports no error, and measures nothing. Two `models/mlx/<name>` probes now run after the existing two (repo-local, then sibling checkout), so no host that resolves today changes behavior. Without this the acceptance criteria below could not be verified at all on this host.

## Host substitution

The issue's figures come from an M5 Max sweep. This work was implemented and verified on **Apple M1 Ultra 128 GB (Metal)**, mlxcel 0.7.0-beta.1, MLX pin `9a795735`. The dispatch fix and the `REACHABLE_PAIRINGS` additions are host-independent; the numbers are not. The issue's K=4 figure of 70.9 tok/s for Gemma 4 Unified 12B is an M5 Max reading and is not the M1 Ultra expectation, so nothing here is asserted against it, and the M5 Max table in `docs/benchmark_results/model_tests.md` is not overwritten with M1 Ultra numbers. The M5 Max re-run against this binary is still pending.

## Test plan

- [x] `cargo build --release --features metal,accelerate --bin speculative_bench`
- [x] `cargo clippy --bin speculative_bench --features metal,accelerate -- -D warnings` (clean)
- [x] `cargo fmt --all -- --check` (clean)
- [x] `./target/release/speculative_bench --target models/mlx/gemma-4-31b-it-4bit --draft models/mlx/gemma-4-31b-it-assistant-bf16 --kind mtp --block-size 4 --max-tokens 128` on M1 Ultra: `[bench/mtp] Done: prompt=14 prefill_ms=306.0 decode_ms=5936.1 generated=88 tok/s=14.8 (wall 6.2s) rounds=34 acceptance_rate=0.529 mean_accepted_len=1.59`. This pairing fails on the pre-change binary.
- [x] `./target/release/speculative_bench --target models/mlx/qwen3.8-27b-4bit --draft models/mlx/qwen3.8-27b-mtp-4bit --kind mtp --block-size 4 --max-tokens 128` on M1 Ultra: `[bench/mtp] Done: prompt=13 prefill_ms=290.2 decode_ms=7051.4 generated=119 tok/s=16.9 (wall 7.3s) rounds=47 acceptance_rate=0.504 mean_accepted_len=1.51`. This pairing did not exist before.
- [x] `./target/release/speculative_bench --sweep --batch 1 --max-tokens 128` on M1 Ultra: 16 rows, 4 baselines and 9 measured MTP rows across Gemma 4 31B, Gemma 4 Unified 12B and Qwen 3.8 27B at K=2/4/8, 3 DFlash rows still deferred, and no row carrying a status that starts with `MTP bench currently supports`. Full table recorded on `bench/0.7.0-refresh` (see below).
- [x] `./target/release/speculative_bench --target models/mlx/gemma-3-4b-it-4bit --draft models/mlx/gemma-4-12b-it-assistant-4bit --kind mtp` reports `MTP bench: target <path> loaded as other, which has no MTP target adapter; supported families are Gemma 4 (Gemma4, Gemma4VLM, Gemma4Unified) and Qwen 3.5 (Qwen35, Qwen35Moe, Qwen35VLM, Qwen35MoeVLM)` as the row status, without aborting.

Every MTP pairing reads below 1.00x on this host, which is expected rather than a defect: `docs/benchmark_results/speculative-decoding-m1ultra-2026-08-19.md` measures a block-4 verify round at 2.70 classic decode steps on M1 Ultra against 1.27 on M5 Max, so a mean accepted length near 1.2 cannot clear break-even here. The `MLXCEL_ENABLE_MTP_B1` static gate already declines B=1 MTP on this Apple GPU generation for that reason. The numbers are the harness reporting the host it ran on, not a regression.

No unit tests are added: the binary has none today, its behavior is real-checkpoint dispatch, and a synthetic target cannot exercise the adapter selection this change is about.

## Where the acceptance criteria are satisfied

This issue splits across two destinations, so this PR closes it while part of its acceptance evidence sits unmerged elsewhere. Satisfied on `main` by this PR: `run_mtp` accepts `Gemma4`, `Gemma4VLM`, `Gemma4Unified`, `Qwen35`, `Qwen35Moe`, `Qwen35VLM` and `Qwen35MoeVLM` and names the loaded variant and the supported families otherwise; the Gemma 4 31B MTP pairing produces numeric tok/s, speedup, acceptance rate and mean accepted length at K=2/4/8 on M1 Ultra (18.4 / 14.9 / 14.9 tok/s, 0.93x / 0.75x / 0.75x against a 19.9 tok/s baseline, acceptance 74.0% / 52.9% / 52.9%, mean accepted length 0.74 / 1.59 / 1.59); the Qwen 3.8 27B baseline row and MTP pairing are in `REACHABLE_PAIRINGS` and both produce numbers (24.9 tok/s baseline, 22.5 / 17.2 / 9.3 tok/s at K=2/4/8); the Gemma 4 Unified 12B rows still produce numbers (38.4 tok/s baseline, 36.0 / 28.5 / 29.3 tok/s at K=2/4/8, acceptance 54.5% / 39.6% / 39.6%); clippy and fmt are clean.

Satisfied on `bench/0.7.0-refresh` (PR #1617), not on `main`: the `docs/benchmark_results/model_tests.md` edits that drop the unsupported-target limitation and record the new rows with their host named, and the M1 Ultra sweep CSV under `benchmarks/`. Those files are benchmark artifacts and that branch is the repository's benchmark-refresh PR, which is deliberately staying open until the M1 Ultra, M3 Ultra and GB10 sweeps land in it. Do not read this PR merging as those doc edits reaching `main`.

Closes #1613
…1616

Issue #1616 read the M5 Max batched-serving rows as the MoE decode path declining the fused kernel at B>=2 and falling back to `gather_qmm`. Profiling on M1 Ultra found a different cause. `Qwen3MoeModel` never overrode `forward_batched`, so the server's batched decode ran the `LanguageModel` default: one single-sequence `forward` per row, evaluated together. Each of those rows is a single routed token, so the fused kernel was reached on every one of them and the token-count gate was never what stood in the way.

The attribution document records the op-level measurements that decided what to build. Per-token fused launches scale linearly (3.9, 7.5, 14.7, 29.2 ms per 48 layers at n=1/2/4/8); identical and disjoint expert sets cost the same at every n, so expert-plane traffic is not the limiter and deduplicating expert ids across the cohort buys nothing; and a prototype of the batched fused kernel the issue proposed, bit-identical to per-token launches, loses to `gather_qmm` from n=4 (11.1 against 9.3 to 9.7 ms). That kernel was therefore not built, which is the outcome the issue's acceptance criteria allow when the profile does not support it.

The M1 Ultra ladder is in `benchmarks/metal_m1ultra_batch_2026-09-04.csv`, whose `mlxcel_commit` column separates the two passes: `bf1cdb72` is main before the change and `4aee0fb9` is the code PR. The after pass was re-measured on the final commit after a `cargo build --release` showed an earlier pass had been taken from a binary predating the last edit to the branch; the conclusion is unchanged and the numbers move by about 1%.

The dense-versus-MoE contrast this issue is named after is much narrower on this host than on M5 Max. There dense reads 3.17x and 3.25x against the MoE model's 1.55x; here dense reads 1.77x and 2.09x against 1.86x after the change and 1.72x before it. The M5 Max section is left as measured with a pointer to this work, because re-running that ladder is what would show the change's effect there.

Refs #1616
inureyes added a commit that referenced this pull request Sep 4, 2026
…#1623)

## Summary

Attribution first, then the fix the profile justified. Issue #1616 assumed that at B>=2 `qwen3_moe` loses the fused MoE kernel and falls back to `gather_qmm`. Measured, that is not what happens: `Qwen3MoeModel` (like all 16 MoE families carrying the `== 1` gate) never overrode `forward_batched`, so the server's batched decode ran the `LanguageModel` default, one single-sequence `forward` per row evaluated together. A B=4 tick was four serialized single-token graphs, each still launching the fused kernel, overlapping only about 30% on the GPU. This PR gives `Qwen3MoeModel` a real batched forward (Rust only, mirroring the Qwen3 dense port), fixes the MoE profile hook so it reports the path it actually timed, and documents which families batch for real.

**Host substitution (approved by the user):** the issue's numbers are M5 Max; everything here was measured on Mac Studio M1 Ultra 128 GB (macOS 26.6.2, mlxcel 0.7.0-beta.1, MLX pin `9a795735`) against this host's own before-baseline. None of the M5 Max values (169.6, 65.5, 1.55x, 3.25x, 3.17x) was used as a target, and an M5 Max re-run against this PR is pending.

## What the profile found (M1 Ultra)

- Before ladder (`bench_serving_concurrency.py --prompt-tokens 512 --max-tokens 128`, `--parallel 4 --max-batch-prefill 4`, one fresh server per model): qwen2.5-0.5b-bf16 216.2 / 174.2 / 367.5 tok/s aggregate at B=1/2/4 (1.70x), llama-3.1-8b-4bit 57.2 / 105.6 / 120.5 (2.11x), qwen3-30b-a3b-4bit 54.3 / 88.0 / 93.3 (1.72x); a second pass reproduced every B=4 aggregate within 0.3%. The dense-versus-MoE gap on this host is 0.39x of scaling, not 1.7x.
- `MLXCEL_PROFILE_BLOCKS=1` on the server: 128 block summaries for 128 ticks at B=1 and 518 for 128 ticks at B=4, four per tick, each with the same 25:75 attention:MoE split. `gather_qmm` is never reached at B=4.
- Op-level microbench on the real layer-0 expert planes (48-layer graph, min of 3x10 pipelined evals): per-token fused launches scale linearly (3.9 / 7.5 / 14.7 / 29.2 ms at n=1/2/4/8), identical and disjoint expert sets cost the same at every n (plane traffic is not the limiter, so cross-cohort dedup buys nothing here), and a batched prototype of the proposed kernel (grid z of `k * n_tokens`, bit-identical to per-token launches, built from the verbatim Metal source) loses to `gather_qmm` from n=4 (11.1 vs 9.3 to 9.7 ms). So the batched fused kernel was not built; `do_sort` at 32 slots is a measured 1% of a tick and is left alone.
- TTFT at B=4 is prompt-cache serialization, not decode: dense prompt-cache entries are one-shot, so only as many rows adopt as entries were donated by the previous level (one at B=2, two at B=4) and the rest pay a cold 440-token prefill serialized ahead of the first decode tick. llama adopts on every row (paged clone adoption) and its TTFT stays at 165 ms.

## What changed

- `src/models/qwen3_moe.rs`: `Attention::apply_rope_batched`, `Attention::forward_split_attention` (batched Q/K norm and per-row RoPE, per-sequence dense-cache update and SDPA), `DecoderLayer::forward_batched` / `forward_batched_timed`, `Qwen3MoeModel::forward_batched_impl`, and the `LanguageModel::forward_batched` / `forward_batched_with_context` overrides. One row keeps the exact single-sequence graph (fused kernel included), zero rows return the trait default's empty logits, two or more rows take the batched forward, where the MoE block sees `[B, hidden]` and its experts run through `gather_qmm` over `B * top_k` slots. The paged decode backend is not opted into.
- `src/models/qwen3_moe.rs`: `SparseMoeBlock::forward_profiled` follows the production dispatch and returns a `MoeProfile` with `path` and `tokens`, so `MLXCEL_PROFILE_QWEN3_MOE_DETAIL=1` no longer attributes a gather path the single-token step never launched.
- `src/models/qwen3_moe_tests.rs`: batched-equals-sequential on a synthetic three-expert model with different per-row RoPE offsets, one-row delegation, and the empty batch.
- `docs/CONTINUOUS_BATCHING.md`: names the families that override `forward_batched` and what the default does for the rest.

## Results (M1 Ultra, same harness)

- qwen3-30b-a3b-4bit: B=4 aggregate 93.3 to 102.9 tok/s (1.72x to 1.86x of B=1), per-request decode 29.8 to 33.9 tok/s; B=2 unchanged within noise (88.0 to 85.0, at 16 slots `gather_qmm` and two fused launches cost about the same); B=1 81.5 to 81.0 tok/s.
- Dense rows unchanged inside the run-to-run band: llama-3.1-8b-4bit 120.5 to 118.9, qwen2.5-0.5b-bf16 367.5 to 369.5 at B=4.
- The after pass was re-measured on this PR's final commit. An earlier pass read 103.7 at B=4 but came from a binary built before the last edit to the branch, which a `cargo build --release` on the final commit exposed by recompiling. The conclusion is unchanged and the numbers move by about 1%. Gate on the final tree: `cargo test --workspace --profile test-fast --features metal,accelerate` 10510 passed, 0 failed.
- `./target/release/mlxcel generate -m models/mlx/qwen3-30b-a3b-4bit -p "Hello" -n 128 --temp 0`: byte-identical text before and after (only the load-time and tok/s lines differ).
- Four simultaneous greedy 128-token requests at B=4 produce four identical rows that match the single-sequence `MLXCEL_FUSED_MOE=0` output character for character; the only divergence anywhere is the pre-existing fused-versus-gather numeric difference at B=1.

## Where the acceptance criteria live

The user split this work across two destinations. On `main` through this PR: the code change, the profile-hook fix, the tests, the batching doc note, and therefore the criteria "MoE B=1 decode unregressed with byte-identical greedy output", "dense B=4 rows unchanged within noise", and the measured B=4 gain itself. `cargo test --release -p mlxcel-core fused_moe_parity_tests` is unaffected because no kernel changed; its pre-existing `fused_moe_geglu_kernel_matches_references_gemma4_shape` failure at seed 886 (#964) is not touched by this PR. On `bench/0.7.0-refresh` (PR #1617), as separate commits: the recorded profile `docs/benchmark_results/moe-batched-decode-m1ultra-2026-09-04.md`, the CSVs `benchmarks/metal_m1ultra_batch_2026-09-04.csv` (before) and `benchmarks/metal_m1ultra_batch_2026-09-04_pr1616.csv` (after), the new "Batched serving (B = 1/2/4)" section in `docs/benchmark_results/model_tests_m1ultra.md`, and the M5 Max section note that its re-run is pending. So this PR can merge and close the issue while the profile and CSV criteria sit unmerged in #1617; they are not satisfied on `main` by this PR alone.

## Test plan

- [x] `cargo test --profile test-fast --features metal,accelerate -p mlxcel qwen3_moe::tests::` (9 passed)
- [x] `cargo clippy --lib --tests --features metal,accelerate -- -D warnings`
- [x] `cargo fmt --all -- --check`
- [x] `cargo build --release --features metal,accelerate`, then the B=1 greedy byte-identity check, the B=4 greedy equivalence check and the three-model serving ladder above on M1 Ultra

## Follow-ups (not in this PR)

- The other 15 MoE families with the `== 1` gate still run the per-row default; each needs its own `forward_batched` after the same premise check.
- One-shot prompt-cache adoption for dense-backed families makes N simultaneous identical prompts pay N minus (entries) cold prefills; the paged backend's clone adoption is the fix pattern.
- Dense batched decode on M1 Ultra (llama-3.1-8b at 2.11x) is far from the M5 Max 3.25x and deserves its own profile.

Closes #1616
The script header comment said the survivor within a duplicate group is "the first name in sort order". The code picks the first directory the sweep's own glob reaches, and that glob yields paths with a trailing slash, so where one name is a prefix of another the longer name wins: `pixtral-12b-4bit` survives over `pixtral-12b`, not the other way round. Six of the fifteen groups on the M1 Ultra store are prefix pairs, so the stated rule predicted the wrong survivor in 40% of cases.

`docs/benchmarks.md` already described the behavior correctly but did not say what the enumeration order implies for prefix pairs, which is the only case where the two readings diverge. Both now state it and name an example.

Comments and prose only; no behavior change.

Refs #1615
@inureyes inureyes added the status:review Under review label Sep 4, 2026
Decode throughput was timed over a model-dependent number of tokens: a 6-token chat prompt, up to 100 tokens, stopping at EOS. On the 2026-09-04 M1 Ultra sweep only 25% of models reached the budget and 16% stopped under 20 tokens. The bias is not one-directional, which is why it went unnoticed: re-measuring moved `granite-4.1-8b-4bit` +117% (1 token, charging first-token latency to throughput) and `gemma2-2b-4bit` -45% (18 tokens, enjoying an almost-empty KV cache). Rankings invert under it, so per-model numbers were never comparable.

Both harnesses now use a deterministic 512-token synthetic prompt and exactly 128 generated tokens with end-of-generation suppressed: llama-bench's pp512/tg128, already what `scripts/bench_serving_concurrency.py` uses. `mlxcel-bench-decode` grows `--ignore-eos` as the `-inf` token bias the server uses for #1436, not a cleared stop set, because the generator merges the model's own `eos_token_ids()` with `SamplingConfig::stop_token_ids`. `bench_mlxlm.py` suppresses EOS through `logits_processors` and synthesizes its prompt from a corpus byte-identical to the Rust one, and resolves its interpreter through `MLXLM_PYTHON`, the uv-created `.venv-mlxlm`, `uv run`, then `python3`, since the system Python is 3.14 and has no mlx wheels.

Two classification gaps found while testing: a directory with no `config.json` or no readable `*.safetensors` now reports `SKIP:not_a_checkpoint` or `SKIP:missing_weights` before any model load rather than the `FAIL:bench` a real defect also produces, which covered 5 of 21 failures last sweep; and the #1615 dedup grouped two weightless directories as duplicates of each other because an empty shard list compared equal, hiding both.

Validated on `qwen3-0.6b-4bit`: both sides report `prompt_tokens=512`, `gen_tokens=128`, mlx-lm `finish_reason=length`.
…step

`apply_token_bias_stage` read the pre-bias argmax id back to the host on every decode step to feed the B9 suppression counters. That `eval` plus `item_i32` breaks the async lookahead pipeline the decode loop is built on, and it costs the same regardless of vocabulary size, which is what makes it a per-step tax rather than a per-token one.

Measured on M1 Ultra as the delta between `--ignore-eos` and no flag, both at pp512/tg128: +65.4% decode time on `qwen3-0.6b-4bit`, +30.4% on `llama-3.2-1b-4bit`, +24.0% on `qwen3-30b-a3b-4bit` and +13.6% on `llama-3.1-8b-4bit`. After gating the readback behind `MLXCEL_LANG_BIAS_COUNTERS=1` the same deltas are -0.6%, -1.2%, -0.4% and -1.0%, so the cost is gone rather than moved. `LANG_BIAS_APPLIED_TOTAL` stays always-on because incrementing it is free; only the two suppression counters, which need the argmax id, became opt-in.

`apply_token_bias` also no longer uploads a vocab-sized f32 vector per step to bias a handful of ids; it reads the biased positions with `take_along_axis`, adds, and writes back with `put_along_axis`, so the work is O(biased ids). That was the first hypothesis for the slowdown and was not the dominant cost, but the op is correct on its own terms and the 15 `token_bias` unit tests cover the additive semantics.

Nothing is affected unless a request or server opts in: `logit_bias`, `ignore_eos`, or `--lang-bias` / `LLAMA_ARG_LANG_BIAS`. An empty bias map still returns before any graph node is built, so the default path is unchanged. Language steering was the worst case, since the map stays resident for the whole session and every token paid.

Found while fixing the benchmark harness, whose new `--ignore-eos` made the instrument distort the measurement it was added to take.
Lists all 191 checkpoints under models/mlx with the upstream repo id, how that id was recovered, and how many CSV rows and doc mentions carry the local name. The last two columns are what makes a rename safe to apply: qwen3-30b-a3b-4bit alone appears in 64 CSV rows and 36 doc mentions, so the cost of a rename is not uniform across the set.

The verified_by column exists because the obvious extraction is wrong often enough to matter. Taking the first repo-id-shaped string in a checkpoint README returns license URLs for some models, so aya-vision-8b read as cohere.com/c4ai-cc-by-nc-license and bitnet-b1.58-2b-4t-4bit as huggingface.co/microsoft. Reading base_model from the README frontmatter covers 98, a domain-filtered match against known orgs covers 63, 6 rest on a weaker match and 24 have no recoverable id. Anything not marked frontmatter should be confirmed against the config before a name is changed on the strength of it.

Removes models/mlx/gemma-3-1b-it-4bit, a symlink into the excluded ~/.cache/mlxcel store whose target is byte-identical to the real gemma3-1b-4bit in the same store. The store now holds no symlinked checkpoints. The name is the wrong way round, since the real directory is the it-tuned model, and that correction belongs to the coordinated rename rather than to this commit.

Force-added past the /docs_internal/ ignore rule, matching how pending_model_renames.tsv is already tracked. The catalogue has to be visible on both hosts to be worth keeping.
Fifty-six directories carried a name that disagreed with the checkpoint inside them, and the disagreement was not cosmetic: `llama-3.1-8b-4bit` held `Meta-Llama-3.1-8B-Instruct-4bit`, `nemotron-h-30b-4bit` held `NVIDIA-Nemotron-3-Nano-30B-A3B-4bit`, and `glm4-flash-4bit` held GLM-4.7-Flash. A benchmark row is read by its name, so a name that misstates the tuning or the family misstates the measurement.

Names now come from the `# mlx-community/...` heading in each README, which identifies the artifact including its quantization. The `base_model:` frontmatter field does not: it names the checkpoint the artifact was converted from, so reading it renames a 4-bit conversion after its bf16 original. Only three directories fell back to it, all published by the original author rather than converted by mlx-community, and all three lost a precision marker that way. Their suffixes are restored from the safetensors headers, which matters most for `qwen3.5-9b-bf16`: it sits beside `qwen3.5-9b-4bit`, and without the suffix the pair reads as base against quantized when it is bf16 against quantized.

Three further directories turned out to duplicate a correctly named twin byte for byte and were dropped rather than renamed. `hunyuan-1.8b-4bit` keeps its name against its README, which points at a 4B model while the checkpoint measures 1.85B at bits=4.

The two current M5 CSVs follow: every model name resolves to a real directory and no `duplicate_of=` target dangles. Past-dated CSVs keep the names they were measured under. `docs_internal/model_catalog_m5max.tsv` records what each name is based on, so a later reader can tell a heading-derived name from a fallback.
`llama-3.1-8b-bf16` resolved to `mlx-community/Llama-3.1-8B-Instruct`, whose name carries no precision, and the directory sits beside `meta-llama-3.1-8b-instruct-4bit`. Dropping the suffix made the pair read as base against quantized when it is bf16 against quantized, the same ambiguity `qwen3.5-9b` had. The rule is that a precision token present only in the local name survives the rename.
One file both machines can hold a column in, replacing the two per-host rename lists that could not be read side by side.

`aliases` carries the names each checkpoint was measured under before today's rename, which is what keeps a past-dated CSV row joinable to the current one. Sixty-four of the 186 entries have at least one. A rename is not a deduplication: the older rows are the same model's record, so they are kept and linked rather than folded.

`id_source` records whether the upstream id came from the README heading, which names the artifact including its quantization, or from the `base_model` frontmatter, which names the unquantized original the artifact was converted from. Reading the second as if it were the first renames a 4-bit conversion after its bf16 source, and it is also the path by which a `datasets:` entry can end up proposed as a model name. Three entries here fall back to it and are flagged rather than trusted.

`csv_rows` and `doc_mentions` price a revert before it is needed. The cost is not uniform: `meta-llama-3.1-8b-instruct-4bit` spans 161 CSV rows and 130 doc mentions counting its aliases, while most entries sit in the single digits.

Also removes an empty `models/models/` directory, a stray from a path that interpolated an empty variable.
Two files naming what has to move in each direction, so the transfer runs off a file rather than off a list retyped into a message. sync_m1_to_m5.tsv holds the 29 checkpoints present here and absent from the M5 catalogue, each with its precision, size and the staging path under models/mlx/_m1_only where a clone is already waiting. sync_m5_to_m1.tsv holds the 24 the M5 catalogue has and this host does not, to be staged there under models/mlx/_m5_only.

Both lists compare against local_name and every alias in model_catalog.tsv, so a checkpoint renamed on one host but not the other is matched rather than counted twice.

models/mlx-big is out of scope by decision, so its five entries are excluded. Two of those are present only here, mimo-v2-flash-4bit and minimax-m2-3bit, which leaves them measurable on M1 Ultra alone. A missing M5 row for either is that decision, not a gap.

The M1 side is staged with APFS clones, so the 395 GB it reports costs no additional space and each file still reads independently.
`eos_token_ids` returned a hardcoded `vec![2]` described as the standard EOS for most models. This family is DeciLM over a Llama-3 tokenizer, where the checkpoint declares `[128001, 128008, 128009]` and id 2 is an ordinary vocabulary entry, so generation would stop wherever the model happened to emit it and a correct answer would truncate mid-sentence.

The field is read as published, accepting either a scalar or a list, and falls back to the Llama-3 pair for a checkpoint that omits it.

This is a latent fix rather than an observed one. Token 2 did not appear in any of the greedy runs used to validate #1688, so no output changed. It is committed because the assumption is wrong, not because it was firing.
`glm-5-4bit` and `glm-5.1-4bit` were directory names with no model behind them. The first held a config, a README and a chat template but no `.safetensors` at all, with 21 GB sitting unmaterialised in its `.cache/` blobs; the second held only `.gitattributes`. Both carried a row in each current M5 CSV with every measurement column empty, which was the signal and went unread until a header check ran over the store.

The catalog gains a `shards_ok` column so the next reader does not have to notice an empty row to find this. It compares each shard's declared length, `8 + header_len + max(data_offsets[1])`, against the file size, which catches a truncated download and a corrupt header without reading the weights. All 184 remaining entries pass.

Directory presence was the only thing the catalog checked before, and it is not enough: both of these were present, named correctly, and listed for transfer to the other host.
scripts/check_checkpoint_weights.py validates every safetensors shard by comparing the size its header declares against the file on disk, which catches a truncated download without reading the tensor data.

Its first version skipped any directory that had no shards, and that is precisely the case it needed to catch. The M5 Max host holds two checkpoints, glm-5-4bit and glm-5.1-4bit, that have a config.json and no weight file at all: the download stopped with the blobs still under .cache, so `du` reports 21 GB while the model cannot load. Both had empty measurement rows in that host's CSVs, which was the signal, unread. The checker now reports a config with no weights as a failure.

This host reports 194 checkpoints with weights and 615 shards all consistent, and no directory with a config and nothing to load.

Adds shards_ok_m1ultra to model_catalog.tsv and drops the two broken entries from sync_m5_to_m1.tsv, which is 22 rows now. A catalogue that records only whether a directory exists will keep proposing to copy a name with nothing behind it.
CLAUDE.md pointed at `mlxcel list` as the authoritative answer to whether a checkpoint is supported. That command lists checkpoints already downloaded into the local store and says nothing about what can load; the architecture catalogue is `mlxcel arch`, with a `supported` alias and a `--json` recipes dump.

The M1 Ultra benchmark doc repeated the same pointer twice while explaining why `afm-4.5b` has no row, and its evidence was wrong a second way: `arcee` is not absent from the catalogue. An Arcee heading is there, listing the AFMoE / Trinity MoE variant, while this checkpoint is the dense `ArceeForCausalLM` that has no entry under it. Read the entry, not the vendor heading, or a family name will read as support it does not have. The conclusion stands, so the row is still a coverage gap rather than a defect.

Verified against the built binary: `mlxcel arch` prints the Arcee heading with the MoE entry only, the checkpoint declares `model_type: arcee` with `ArceeForCausalLM`, and `mlxcel generate` still exits with `Unsupported model type: arcee`.
Twenty-six of the twenty-nine M1 Ultra checkpoints landed in the store, bringing it to 210 entries, and every shard passes the declared-length check. `klear-46b-src`, `ling-lite-1.5` and `phixtral-4x2_8-src` did not arrive.

Most of what arrived has no README heading and no `base_model` line, which moves `id_source: none` from 44 to 57. Those names stay as they are: with no upstream id there is no evidence to rename against, and a name assembled from config would read as verified when it is a guess. The column says so rather than the name implying otherwise.

`present_on_m1ultra` is filled from the two sync lists, so the 22 marked `no` are the set staged for transfer rather than a claim about the other host's store after it completes.
llama-3_3-nemotron-super-49b-4bit arrived on this host today, so the family that had no real checkpoint here now has one. Decode reads 19.37 tok/s at a 512-token prompt and 128 generated, prefill 119.61 tok/s, measured at bdf8dd1 with a no-op build confirming the binary matches the tree.

No M1 Ultra parity figure accompanies it. mlx-lm 0.31.3 cannot load the checkpoint in this venv even though it ships a nemotron-nas module: transformers 5.16.1 asks to run the checkpoint's custom code, a non-interactive run declines, and the fallback builds a bare config that fails with `AttributeError: 'PreTrainedConfig' object has no attribute 'max_position_embeddings'`. Passing trust_remote_code through tokenizer_config does not change it, because the failure is in config loading rather than the tokenizer. Recorded as a harness failure with that reason rather than as an unsupported architecture, which it is not.

The M5 Max row for the same checkpoint reads 18.95. That is a cross-machine comparison and on its own says nothing about either runtime, so it is not a parity claim.
The harness recorded FAIL:warmup for this checkpoint and the first reading of that was wrong: mlx-lm does ship a nemotron-nas module, and trust_remote_code was already being passed. The real cause is that the mlx conversion kept config.json's `auto_map` pointing at `configuration_decilm.DeciLMConfig` while shipping no .py files, so transformers cannot build the custom config class, falls back to a bare PreTrainedConfig, and its rope standardization then reads a `max_position_embeddings` that object does not have. The traceback puts the failure in load_tokenizer's AutoTokenizer call, not in model loading, because mlx-lm reads the model config from config.json directly.

scripts/bench_mlxlm_nemotron_nas.py registers a stand-in AutoConfig whose only job is to satisfy that lookup, and leaves the checkpoint untouched. Same shape as the harness: 512-token prompt, 20-token warmup, 128 measured, prefill taken as time to first token.

mlx-lm 0.31.3 reads 19.55 tok/s decode and 119.40 prefill against mlxcel's 19.37 and 119.61, so 99 percent and 100 percent on the same machine. That is the first same-machine parity figure for this family; the M5 Max comparison was cross-machine and carried no such claim.

Drops the klear-46b-src and phixtral-4x2_8-src rows. Both were pre-conversion source checkpoints kept for reference rather than serving, and they have been removed from the store.
The transfer from M1 Ultra landed 26 of 29. Two of the three that did not are gone on purpose: `klear-46b-src` and `phixtral-4x2_8-src` are pre-conversion sources that serving never loads, and they have since been deleted on M1 Ultra too, so they are dropped from the catalog rather than carried as absent.

`ling-lite-1.5` is the real gap. It is not a source checkpoint, it is still present on M1 Ultra at 31.3 GB, and it was missed rather than excluded. An `m5_absence` column records that, so the next reader of a table with no row for it does not have to work out whether the model failed, was skipped, or never arrived.
The judging section already said what to measure and at what width, and both hosts still shipped a validation today that measured only the arm with the fix in it. That reading shows the code works; it does not show the probe would have noticed if it did not, and the section had no line asking for the second arm.

Adds two conditions beside the existing two. Run the arm with the change reverted and confirm the metric moves, because until that arm exists there is one reading rather than a comparison. And check that the input reaches the branch that changed, since a conditional path has a threshold and the threshold is usually written in the checkpoint's own config, which makes this knowable before the probe is written.

The nemotron_nas rope-scaling fix is the worked example, and it failed both ways in one day. Its config carries `original_max_position_embeddings: 8192`, so a 1300-token probe passed without touching the replaced scaling, its pass coming from head-layout and GQA paths a different commit had fixed. A 9500-token probe did reach the branch but ran only against the fixed build. The evidence came at 14737 tokens with that one file reverted, where the needle went unfound. Length selects which frequency band is live the same way forward width selects which kernel is dispatched, so the mistake the section already warns about for width was available for length and went unwritten.

Corrects the "two things" count to four.
The last checkpoint the M1 Ultra transfer missed is in the store: four shards, 33.6 GB, every shard's declared length matching its file size, and it loads and answers on the Bailing MoE path at 57 tok/s.

It was worth chasing rather than writing off with the two `-src` checkpoints. `docs/supported-models.md` names `inclusionAI/Ling-lite-1.5` as the validation checkpoint for that port, and the loader's non-obvious parts, the GPT-NeoX tensor naming, the uneven fused-QKV split at offsets (2048, 2560), the router key that collides with every expert's own gate, and the 64-expert stack assembly, were all written against it. It ships raw bf16 with no mlx-community conversion, so it is the distributed form rather than a pre-conversion source. Without it this machine could not exercise the family at all.

Every M5 Max entry now has a shard verdict and no entry carries an absence reason.
Regenerates both tables from the current CSVs: 167 text rows and 76 VLM rows, with llama-3_3-nemotron-super-49b-4bit added and the two source-repository checkpoints gone.

The coverage table listed klear-46b-src and phixtral-4x2_8-src as present-but-excluded. They are no longer present at all, having been removed as pre-conversion originals the runtime does not serve, so the row is replaced by a sentence saying what happened to them; a reader who finds the names in an older CSV needs that, and a row implying they are still on disk would be wrong.

Refreshes present_on_m1ultra and shards_ok_m1ultra across the 211 catalogue rows. After the two-way sync the two hosts hold the same set, so every row now reads present on both, and every one passes the shard-header check here.
`docs_internal/` held seven working files from settling the directory naming, and six of them were scaffolding: two pre-rule rename drafts, one host inventory, and two one-time transfer lists, none of which say anything the catalog does not. The rename mapping is the clearest case, with all 58 of its pairs already carried in the catalog's `aliases` column.

The catalog itself is worth keeping and was never documented, so it moves to `docs/model-catalog.tsv` with `docs/model-catalog.md` beside it. The doc is the durable half: the four-step naming rule, what each column means, and the three traps that cost real time. `base_model` names the checkpoint an artifact was converted from, so following it renames a 4-bit conversion after its bf16 original and can propose a `datasets:` entry as a model name. A precision token the upstream name lacks has to survive the rename, or `qwen3.5-9b` sits beside `qwen3.5-9b-4bit` reading as base against quantized when it is bf16 against quantized. And the config outranks the name: `hunyuan-1.8b-4bit` keeps its name against a README pointing at a 4B model, because the checkpoint measures 1.85B at `bits: 4`.

`shards_ok_*` is documented with the reason it exists. Directory presence was the only check before, and two entries passed it while holding a config, a README and no `.safetensors` at all, tens of gigabytes unmaterialised in their `.cache/` blobs, both named correctly and both listed for transfer.

`docs/benchmarks.md` gains two paragraphs in "What to record": the catalog as the join key across renames, and the rule that the binary must match the tree before measuring.
`resolve_repo_id` built the legacy `./models/<basename>` root from a constant while `locate_cached_snapshot`'s doc comment claimed it was "a parameter so unit tests can point it at a temp dir". The parameter existed; the public entry point had no way to set it.

That probe resolves against the process working directory and runs before every other reuse location, so `offline_mode_turns_a_repo_id_miss_into_an_error_without_downloading` and `offline_mode_still_answers_from_the_mlxcel_store` found a real `models/Qwen3-4B-4bit` ahead of the temp store they had just built. `MLXCEL_CACHE_DIR` and `HF_HUB_CACHE` already isolated the other two probes; this was the third and it was unreachable. Both tests failed on exactly the machines that have the checkpoint downloaded, which are the machines used for real-model work.

`ModelSourceOptions` gains `cwd_models_dir`, defaulting to the constant so every production caller is unchanged, and the two tests point it at an empty directory.

Also raises the unrouted ulp bound in `temperature_one_support_unchanged` from 2 to 4. The bound is a drift tripwire on the fused softmax, not the correctness gate: support equality is asserted beside it and the distribution is covered by the chi-square test. What it keeps catching is new hardware. #1419 replaced exact-bit goldens with a tolerance after Metal and CUDA moved 1 ulp, #1563 is sm_70 at 1 ulp, and M5 Max moves 3 at one token of one case and nowhere else. The helper now reports the worst drift across the row rather than the first token over the limit, which is the number needed to tell a tight bound from a real arithmetic change.

Closes #1715, closes #1716
@inureyes
inureyes force-pushed the bench/0.7.0-refresh branch from d4d5484 to 1b6760d Compare September 8, 2026 14:01
Auditing what `docs_internal/` held before it was removed, rather than asserting the catalog covered it, turned up one column with no home. Five of the six retired files carried only fields the catalog already has: `local_name`, `upstream_repo_id`, `verified_by`, `store`, `csv_rows`, `doc_mentions`, `precision`, and the rename pairs that became `aliases`. The transfer lists also carried `size_gb`, and nothing else recorded it.

On-disk footprint is what a transfer between machines has to be planned against, and it is the column that would have to be rebuilt by hand the next time. It is filled for all 211 entries, totalling about 2221 GB, with `qwen3-coder-480b-a35b-instruct-4bit` at 270 GB the largest single entry.

The rest of what those files held was bookkeeping that expires with the transfer: staging and request timestamps, and two drafts written before the naming rule settled.
@inureyes inureyes changed the title bench: refresh the 0.7.0 sweeps and fix the defects they exposed bench: refresh the 0.7.0 sweeps and fix the dtype, rotary and rope defects they exposed Sep 8, 2026
@inureyes
inureyes merged commit d653875 into main Sep 8, 2026
12 checks passed
@inureyes
inureyes deleted the bench/0.7.0-refresh branch October 6, 2026 12:12
@inureyes inureyes added this to the 0.7 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:benchmark Benchmark harness and performance measurement (bench_*.sh, /update-benchmarks) priority:medium Medium priority status:review Under review type:docs Documentation improvements or additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants