Skip to content

Muse Glimmer 30B: native NVFP4 tower, exact verify windows and the DFlash drafter - #423

Draft
jonathan308 wants to merge 56 commits into
mainfrom
feat/muse-glimmer-native
Draft

jonathan308 wants to merge 56 commits into
mainfrom
feat/muse-glimmer-native

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 14, 2026 •

Copy link
Copy Markdown

Refreshed 2026-11-15, merge only. Round 2: c1103b8c merges SDK main fe9b5282 (#434's merge, the pin of d-inference dev cc19fe003); no file changed: the tree is identical to round 1's. 39e5dc5e merges mlx-swift-lm#434 (c85e84cf, the GLM5 / Gemma / MiMo V2 grammar-only tool parsers). #434 is the SDK pin of d-inference dev bd67dec73, so this branch and the provider's dev pin agree. The merge had no conflicts. #434 then merged into main at 10:53Z (fe9b5282, whose tree equals c85e84cf's), so this PR's diff against main is its own 89 files again; merging the new main would change no file, so it was not merged. The measurements below were taken at 99c50f6c. The refreshed SDK, combined with #427–#432, compiled in the provider's debug build, and the provider's Muse Glimmer suites passed on it, apart from one dev-variant fixture that fails before and after. The SDK's own test target was not run here.

Draft. Muse Glimmer 30B (Meta, Apache-2.0) served from NVIDIA's native NVFP4 checkpoint, with the DFlash drafter and exact speculative verification. Branch feat/muse-glimmer-native on main 0ed99d07; 51 commits, all signed. The provider side (Layr-Labs/d-inference, feat/muse-glimmer-30b) will re-pin to this branch's final head; that PR follows.

Proposed changes

Model and artifact. A fork-only native text tower under Libraries/MLXLLM/Models/MuseGlimmer/ for nvidia/Muse-Glimmer-30B-NVFP4 @ 47818374517751c48c55cde2621594926b1888b6. The checkpoint is ModelOpt mixed precision, used as stored:

  • 213 projections are weight-only NVFP4;
  • 180 are FP8 W8A8 with static input scales, quantizing activations with saturating overflow;
  • 24 are BF16.

The architecture: 52 layers in a [sliding 2,048 ×3, full] ×13 pattern, RoPE on the sliding layers only, a sigmoid attention gate, centered RMS norms, and an output multiplier followed by a tanh softcap. Upstream's MLXVLM/Models/MuseGlimmer.swift is untouched. Vision tensors are hash-verified and not loaded (text first).

Strict pinned loading. MuseGlimmerCheckpointPin pins the index and the three shard SHA-256s.

  • Each projection's format comes from the verified tensor headers. hf_quant_config.json is only cross-checked; an unreadable one refuses.
  • Symlinked or oversized index and JSON files refuse.
  • Missing, extra or mis-typed tensors refuse with typed errors.

The new generic pieces are ModelOptWeightOnlyNVFP4Layout/Linear and ModelOptIndexedCheckpoint.

Backend. Paged KV only (requiresPagedKV); a contiguous or unsupported backend is refused, never degraded. Prefix reuse uses complete historical-attention checkpoints.

Exact verify windows. MLX's .nvfp4 product uses different sum orders for 1, 2–5 and 6–16 rows, so a verify window could differ from the decode steps it replaces.

  • New row-exact NVFP4 kernels use one fused multiply-add order for 1 to 16 rows.
  • FP8 gets a window schedule: a separate activation cast and 2 rows per thread. It is default-off and enabled for this tower only.
  • With setRowExactWindows(true), decode and verify rows are exact at any row count, in 16-row pieces. Prompt chunks keep MLX arithmetic, which is why prefill speed is unchanged.
  • Prompts are cut on a fixed 1,024-token grid: only at multiples of 1,024, at the prompt end, or at a boundary a prefix restore needs. Each 1,024 cell runs whole or waits a step, so a prompt's bytes do not depend on concurrent load or on another request's drafter.
  • The profile string is muse-glimmer-exact-windows-v4; the provider puts it in the checkpoint numerics fingerprint.

Batched exact verify attention. An opt-in paged path writes every column's K/V first, then runs one decode dispatch per layer for all (row, column) pairs, on sliding and full layers. Previously it took one dispatch per column per layer. It is default-off and requested by the Muse drafter.

DFlash drafter (MuseGlimmer/DFlash/):

  • the 5-layer, block-16 drafter that taps target layers [1, 13, 25, 37, 49];
  • a pinned quantized artifact (museGlimmer30BQuantized, 1.833 GiB, MLP 5-bit with attention and encoder.fc 8-bit, under the 2 GiB assistant cap) and a converter;
  • context kept as advisory state, never captured in or restored from checkpoints, through a new engine seam CBv2MTPAdvisoryHistoryDrafter;
  • rectangular-exact verification on an exact target, falling back to serial otherwise;
  • refusals for a target with other tapped layers and for .typical acceptance.

ATEM / Onyx parsing. Adds ToolCallFormat.atem, ReasoningParserFormat.onyx and OnyxTokenStreamDecoder. mlx-server reads Onyx tool frames strictly by default; reference parity is opt-in (--onyx-parsing reference-parity).

Shared code touched. Every shared change is additive and defaults to off:

  • RecurrentStateV2.requiresPagedKV and three lines in EngineV2.backendCapabilityViolation;
  • ModelOptRowExact.Schedule (default .standard);
  • the decode-rows attention option;
  • requiresExactAcceptance (default false);
  • the advisory-history seam;
  • CBv2ModelCapabilities.prefillChunkAlignment (default nil) in SchedulerV2 and the first-token deadline projection. With an alignment set, decode rows are planned before prompt rows, so a decode row waits at most one step for a cell, and the engine refuses a paged pool whose maxPrefillChunk cannot hold a cell.

Tests check that the defaults are unchanged.

Validation

Run on an M3 Ultra with the native build system. Real-weight suites are env-gated (MUSE_GLIMMER_NVFP4_DIR, MUSE_GLIMMER_ASSISTANT_DIR, MUSE_GLIMMER_ORACLE_DIR).

  • Against an independent Python oracle (it shares no code with this branch):
    • Argmax is equal on three prompts (71, 280 and 2,321 tokens; the last wraps the 2,048 ring).
    • Paged greedy tokens are equal up to near ties under the oracle's own noise (P2 parts at token 21, where the oracle's margin is 0.145).
    • The float32 drafter reproduces the oracle's 15 drafts exactly.
    • BF16 drafter traces: 1,711 of 1,725 tokens identical; the 14 others are near ties.
  • Exactness on the real checkpoint:
    • Verify windows of 8 and 3 tokens on all three prompts give byte-identical logits and K/V in every layer compared with one-row steps, with both the batched attention path and the per-column loop.
    • Drafter on equals drafter off, greedy and sampled.
    • Restore equals cold with the drafter on (tiny engine).
  • Tiny-model suites:
    • Windows of 1–8 at 1, 2, 8 and 16 requests and mixed lengths, across the 2,048 boundary and the ring wrap.
    • 65+ decode rows, and 9 and 16 requests at width 8.
    • Prompt chunks of 1–200 rows equal the plain tower byte for byte.
    • A request's decode bits are unchanged while another request prefills beside it.
    • A request's prompt K/V bytes and output are the same alone, beside another request's decode, and beside it with the drafter on (bf16 and float32). A restore under load equals the cold run. With the grid switched off, both tests fail.
    • Grid scheduler suites (cells, waits, claims, fairness bound), plus 391 scheduler, deadline and block tests unchanged at the default.
    • Loader negatives, drafter refusals, and default-off checks for every shared switch.
  • Wide regression: the only failure is flintMoEFusedCombineMatchesOriginalBytes, which fails the same way on main.
  • scripts/check_forkdiff.py: 2,149 of 2,149 files described. omlx does not appear in the diff.

Measured on the M3 Ultra, release bench through EngineV2 on paged KV, 256 new tokens. The machine had other sessions' builds running (load average 7–18).

Prompt Drafter off Drafter on, greedy Drafter on, sampled (T 1.0, top-p 0.95, top-k 64)
P1 (71 tokens) ~21 40.0 43.2
P2 (280 tokens) ~22 44.4 42.6
P3 (2,321 tokens) ~21 60.8 63.7
  • Drafter on equals drafter off in all 12 runs; P3 time to first token 7.7 s.
  • Prefill at 4,096 tokens: 303 tok/s, against 302 with MLX arithmetic.
  • Plain decode: 21.6 tok/s exact, against 23.7 tok/s with MLX arithmetic.
  • A verify window of 8 costs 72.7 ms, against 111.7 ms with the per-column loop.

On an M5 Ultra at 99c50f6c (same harness, warm process, two repetitions, quiet GPU checked before each section; one section was discarded for another session's CPU load):

Prompt Drafter off Drafter on, greedy Drafter on, sampled
P1 31.5–32.9 69.5 / 69.9 80.8 / 81.6
P2 31.5–32.9 78.3 / 61.7 83.3 / 83.6
P3 31.5–32.9 108.8 / 109.3 129.3 / 129.6
  • Drafter on equals drafter off in 64 of 64 runs.
  • A round takes 41–43 ms on P1 and P2 and 47 ms on P3; the rate follows acceptance (1.8 to 5.1 tokens per round).
  • P2 greedy has a repeating slow stretch (53–54 ms per round), which is the 61.7 run; under investigation.
  • Exact plain decode is 31.6 tok/s against 35.2 with MLX arithmetic; prefill at 4,096 tokens is 1,570 tok/s.

Not done / known

  • Strict Onyx parsing. Under the strict default, a user frame that ends at <|end_of_text|> leaves the marker in the content. This comes from the upstream OnyxStreamAdapter and is recorded with withKnownIssue. Reference parity handles it.
  • Not yet tested: checkpoint restore under .rectangularExact on a real-sized target (needs a new engine fixture). The process-global scalarRows is still shared between suites.
  • M5 kernels. The device-only kernel selection (review item D-5) will be merged here from a separate branch. NAX forms of the exact kernels were measured on the M5 and left out: they save nothing per round, cost about 3 ms per one-row step, and would need an M5-only numerics variant.
  • Speed. The M5 Ultra reaches 70 tok/s on every prompt except P1 greedy (69.5–69.9) and one P2 greedy run (61.7); the M3 Ultra does not (40–64), because its rounds are slower. These are engine benchmarks; the provider's HTTP path has not yet run on the M5.
  • Vision. Image input (vision tower) is a later milestone.

Checklist

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes (not --all-files, since main is not formatted; the lint job's swift-format 6.4.4 command was run on every Swift file this branch changes, at 99c50f6c)
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (docs/muse-glimmer.md, fork.yaml, tool-calling docs)

AI usage

  • I have read this PR description in full and approve it as my own, and it
    accurately describes the code changes.
  • AI usage disclosure: the code, tests, measurements and this description were produced by Claude Code agents under Jonathan's direction. An independent agent reviewed the diff read-only, and its findings are fixed or listed above. A person has not yet read this description or the diff; the box above stays unticked until they do.

🤖 Generated with Claude Code

jonathan308 and others added 30 commits November 13, 2026 00:56
A sibling of ModelOptProjectionLayout for the W4A16 form (U8 codes, E4M3
block scales, F32 weight_scale_2, no input_scale) and a public linear over
MLX's nvfp4 quantized matmul with weight_scale_2 applied verbatim in FP32.
Kernel tests decode a random matrix on the host from the producer's formula
and compare products; a 16-code row pins the nibble order and code table.

Co-Authored-By: Claude <noreply@anthropic.com>
A fork-only text decoder under MLXLLM/Models/MuseGlimmer. It runs the MLXVLM
tower's operations in the same order and dtypes: centered RMS norms with two
eps values, parameterless embed and QK norms, the FP32 query scale before
RoPE, RoPE on sliding layers only, the sigmoid gate from the layer input,
SwiGLU, a plain final norm, then output_multiplier and the tanh softcap.
Projection slots hold any UnaryLayer so ModelOpt layers can install there;
the attention has a CBv2 branch and the trunk can capture layer outputs.

On a tiny random model the logits equal the MLXVLM class bit for bit in BF16
and FP32, uncached and through chunked prefill plus 24 greedy steps past an
8-token window. The upstream file is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
Layer kinds (sliding window or full, no sharing, no sinks), newCacheV2, the
prompt-output seam, decode command-buffer limits, historical attention
checkpoints with a K/V dtype table, and capabilities: paged KV supported and
required in its native segmented form, packed prefill off.

CBv2ModelCapabilities gains requiresPagedKV, default off. requiresNativePagedKV
only constrains which paged pool a model accepts; a contiguous backend still
passes it. With the new flag EngineV2.backendCapabilityViolation refuses any
backend that is not paged. No existing model sets it.

Tests drive a tiny tower with the production attention geometry through
EngineV2 on PagedKVBackend: greedy tokens and logits against the eager caches
past the window, two concurrent requests against their solo runs, a complete
checkpoint exported and restored into a new model, and the backend refusals.

Co-Authored-By: Claude <noreply@anthropic.com>
ModelOptIndexedCheckpoint binds a hashed index to hash-verified shards with
no model-specific inventory. MuseGlimmerInstallation classifies every tensor
from header metadata: BF16 projections stay dense, F8_E4M3 with weight_scale
and input_scale become calibrated FP8 with saturating activation overflow,
U8 with weight_scale and weight_scale_2 become weight-only NVFP4. Coverage
is checked both ways before and after loading; missing, extra and misshapen
tensors throw typed errors. Vision tensors are verified and listed in the
receipt but not loaded. hf_quant_config.json is cross-checked, never used to
load. The pin holds the index and shard SHA-256 of revision 47818374.

Tests stage a synthetic three-format sharded checkpoint and cover the
refusals.

Co-Authored-By: Claude <noreply@anthropic.com>
A hidden-returning forward that also returns the residual stream after the
configured layers (default 1, 13, 25, 37, 49), a prompt variant that projects
logits for the last row only, raw token embeddings, the head, and
MuseGlimmerCBv2Adapter. The generic adapter is always a recurrent MTP model,
which the round driver refuses for a request-stateful drafter on a target
without recurrent state; the dedicated adapter is not, and reports
supportsRequestStatefulMTP. No shared engine file changes.

Co-Authored-By: Claude <noreply@anthropic.com>
MuseGlimmerRealArtifactTests stage the pinned NVIDIA checkpoint when
MUSE_GLIMMER_NVFP4_DIR is set and, with MUSE_GLIMMER_ORACLE_DIR, compare
against the independent float32 oracle fixtures: per-layer residual samples
at the last position, the drafter layers' last four rows, the final hidden,
top-50 logits, and greedy continuations through EngineV2 on the paged
backend, including a 2,321-token prompt across the window. A small reader
loads the fixtures' uncompressed npz files. MUSE_GLIMMER_BENCH adds a decode
and prefill timing. CI skips all of them.

Co-Authored-By: Claude <noreply@anthropic.com>
…ifact writer

The block drafter of meta-models/Muse-Glimmer-30B-assistant as a fork-only
module under MLXLLM/Models/MuseGlimmer/DFlash:

- configuration decode with typed refusals, and the pinned published values;
- the five pre-norm layers, the context projection and one block forward
  (block queries attend each other in both directions and the cached keys and
  values of committed target positions);
- a request-owned context ring of at most sliding_window positions keyed by
  absolute position, allocated once; a block's own keys and values never
  enter it;
- a strict loader: pinned SHA-256 for config.json and model.safetensors,
  exact tensor inventory, each projection's format read from the verified
  header;
- in-memory affine quantization and a deterministic artifact writer with a
  SHA-256 manifest.

Tests use tiny random models against a reference that recomputes a block
from every context row with plain products, an explicit mask and its own RoPE.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…s do

`ToolCallPolicy.onyxParsing = .referenceParity` selects a second reading of
Muse Glimmer output, next to upstream's strict one, which stays the default:

- one call for each complete invoke of a tool frame, in order
- a doubled tool name `X.X` is the declared tool `X`
- values typed by the tool schema: a string keeps its bytes, other values
  decode as JSON; a value that does not fit goes to the validation policy
- a call cut off by the token limit: complete invokes are kept, a cut-off
  invoke is never a call
- a frame left open before a bare `to=...<|message|>` header ends there
- output without a frame is content; a cut-off reasoning frame keeps its text

A tool that was not declared is still rejected. Marker-shaped text cannot
open a frame in the token decoder.

`OnyxTokenStreamDecoder` and `OnyxTextStreamDecoder` are the public
decoders for a host. `ToolCallFormat.infer(from: "muse_glimmer")` is `.atem`.

Tests port the vLLM Muse Glimmer parser cases and its schema value table.

Co-Authored-By: Claude <noreply@anthropic.com>
- `ReasoningParserFormat.onyx` splits text with visible Onyx markers into
  reasoning (`to=self`) and content, collected and streamed. Tool frames are
  never content.
- `MLXModelContainerEngine` reads the Onyx frames of an `.atem` model from
  the token ids and reports reasoning and content as `.parsed`, with the
  reference reading of tool calls. `Generation` has no reasoning event, so
  the text path would drop the reasoning.
- The server selects `onyx` for a loaded `.atem` model when no reasoning
  parser was requested (`ReasoningParserFormat.inferred`).
- `ServerToolParser` accepts `atem`, `onyx` and `muse_glimmer`.

`<|eot|>` and `<|end_of_text|>` end generation; `<|eom|>` does not. A
response cut off inside reasoning returns the partial reasoning, empty
content and `length`.

Co-Authored-By: Claude <noreply@anthropic.com>
The text model declared CBv2MTPForwardable with capture layers so the generic
adapter could report them. Nothing uses a frozen-KV drafter with this model
and no test covered it; the request-stateful path goes through
MuseGlimmerCBv2Adapter. forwardWithMTPHidden and prefillWithMTPHidden stay.

Co-Authored-By: Claude <noreply@anthropic.com>
Environment-gated tests on the published drafter and the two target tensors
it borrows (embed_tokens, the weight-only NVFP4 lm_head), read from pinned
shards:

- the first block of the independent oracle's P1 fixture, in float32 and in
  the checkpoint's BF16, against the oracle's drafts and top-five head values;
- every round of oracle traces that carry the target's five-layer context for
  each committed position;
- measurements, written as JSON: quantized drafters against the dense one,
  drafts with only the last N context rows, and the quantized artifact
  conversion with a reload check.

All are skipped unless MUSE_GLIMMER_NVFP4_DIR and MUSE_GLIMMER_ASSISTANT_DIR
are set.

Co-Authored-By: Claude <noreply@anthropic.com>
MuseGlimmerDFlashDrafter binds the block drafter to one target through the
MuseGlimmerDFlashTarget protocol (raw embeddings, bare head, context width).
Each request owns its context ring. Observed target rows and a round's
accepted rows are committed as they arrive; the first draft step of a round
runs one block forward and keeps up to seven proposals, later steps return
them. Target-prefix acceptance is on, so sampled rows speculate and the
emitted tokens stay the target's own. The ring is a fixed per-request charge
through the bounded allocation contract; one block forward is charged once
per engine.

Engine tests run the real CBv2 engine on the paged backend over a tiny random
target, with serial and rectangular verification: greedy and sampled output
equal the engine without a drafter for the drafter's own proposals, for
proposals that are always right and for a wrong proposal at each position;
every depth; cancellation while a round is built; two concurrent rows; a
request with image spans.

Co-Authored-By: Claude <noreply@anthropic.com>
…ling reference

- fork.yaml: a section for the reference reading of Onyx frames and ATEM
  calls, with its files and tests.
- skills tool-calling reference: `onyxParsing` and the two host decoders.
- mlx-server help lists the `atem` tool parser and the `onyx` reasoning parser.
- Whitespace around the first `to=...` header of a response is framing.

Co-Authored-By: Claude <noreply@anthropic.com>
…generic paged path

A request-stateful drafter may declare its request state advisory
(CBv2MTPAdvisoryHistoryDrafter): the state is rebuilt from the target rows
the engine hands over and, with exact acceptance, no emitted token depends on
it. For such a drafter the generic paged branch builds its complete
checkpoint codec and adopts checkpoints with no assistant state, exactly as
for an engine without a drafter. A request that adopts a checkpoint gets a
new request state, and each observation carries the absolute target position
of its first row, so the drafter starts at the restored boundary.

Every existing drafter is unchanged: without the conformance, or with typical
acceptance, checkpointsRequireAssistantHistory equals tracksPersistentHistory
and the position is not passed. The contiguous, native paged, recurrent and
hybrid branches are not touched.

Co-Authored-By: Claude <noreply@anthropic.com>
The drafter declares its context advisory and takes the absolute position of
each observation: rows it already holds are skipped and a gap restarts the
context, so a restored request's drafter starts at the restored boundary with
the right RoPE positions.

A target row or round call the drafter cannot serve no longer stops the engine
thread: the step returns a well-formed proposal and the request ends with an
error at the fence.

Tests: a restored request's tokens equal a cold request's with the drafter on
(greedy and sampled, serial and rectangular verification, both checkpoint
boundaries, donors with and without a drafter) and speculation resumes after
the restore; checkpoints saved with the drafter hold the same bytes as
without; drafters that are not advisory keep their refusal; misshapen target
rows end the request, not the engine. Adds block, head and commit timings to
the real-weight study and applies swift-format to the DFlash files.

Co-Authored-By: Claude <noreply@anthropic.com>
…test with the published tokenizer

- `ATEMReferenceScanner` matches tags scalar by scalar with a literal
  search, so a value that starts or ends with a combining mark keeps it.
- The search for a parameter stops at the invoke's close: a frame of many
  invokes is read in one pass.
- More decoder tests: bare headers at the start of a body and after a tool
  frame, a frame without a recipient, a stray `<|message|>`, stop strings
  (answer only), and protocol errors that hold no model output.
- `MuseGlimmerOnyxTokenizerLiveTests` runs the token decoder with the
  published tokenizer when `MUSE_GLIMMER_NVFP4_DIR` is set. It reads no
  weights.

Co-Authored-By: Claude <noreply@anthropic.com>
One order of fused multiply-adds defines every output element, so a row
has the same bytes at every row count and position. A simdgroup-matrix
kernel reads each weight once for up to 16 rows; a scalar kernel runs
the same order for one row on the GPU family where the two were measured
equal. Kernel tests compare raw bytes against one-row products and a
host loop in the documented order. An opt-in suite times the weight-only
NVFP4, FP8 and BF16 projections of a dense 30B decoder at their real
shapes.

Co-Authored-By: Claude <noreply@anthropic.com>
The pull request check formats every Swift file a change touches and fails
when the formatter changes it. Two older lines of this file were not
formatted.

Co-Authored-By: Claude <noreply@anthropic.com>
museGlimmer30BQuantized pins the conversion of the published BF16 drafter
that writeArtifact produces for museGlimmer30BQuantizedPlan: MLX affine,
group 64, MLP projections at 5 bits, attention projections and encoder.fc at
8 bits; 1,968,222,936 bytes, under the 2 GiB assistant bound. The conversion
is deterministic, so the hashes follow from the pinned source.

The real-weight test loads the artifact through the strict loader, compares
every tensor with an in-memory conversion and drafts the oracle's first block.

Co-Authored-By: Claude <noreply@anthropic.com>
…e-step benchmark

The scalar kernel was measured slower than the matrix kernel for one row
of a 202,048-output head. The benchmark suite gains one evaluation of all
projections of a decode step and the FP8 row-exact path with its
activation cast as a separate pass.

Co-Authored-By: Claude <noreply@anthropic.com>
A real-weight study, skipped without the checkpoints: blocks of 12 and 8
positions against the trained 16, by accepted drafts and wall time.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Freshness merge before integration. No MLX pin change (Package.swift and
Package.resolved unchanged; mlx-swift c633d221).

Co-Authored-By: Claude <noreply@anthropic.com>
The DFlash block drafter, its strict loader and pinned quantized artifact,
and the additive advisory-history seam for complete checkpoints. No
conflicts.

Co-Authored-By: Claude <noreply@anthropic.com>
MuseGlimmerTextModel conforms to MuseGlimmerDFlashTarget (raw embeddings, bare
head, tapped hidden width). Tests run the drafter through the engine over the
native tower and its CBv2 adapter on the paged backend: greedy and sampled
output equal the target alone, and a restored request equals a cold one.

Co-Authored-By: Claude <noreply@anthropic.com>
…native

Onyx frames and ATEM tool calls with an opt-in reference reading
(ToolCallPolicy.onyxParsing defaults to .strict). No conflicts.

Co-Authored-By: Claude <noreply@anthropic.com>
ModelOptRowExact.Schedule lays out the one-row and row-exact FP8
products: the activation cast as its own pass, and two output rows per
thread in one simdgroup. Both give the same bytes as the standard
layout. ModelOptCalibratedLinear.rowExactSchedule defaults to
.standard, so existing models keep their dispatches.

Co-Authored-By: Claude <noreply@anthropic.com>
setRowExactWindows(true) makes every call of 1 to 64 rows give each row
the bytes of a one-row call: weight-only NVFP4 through the row-exact
NVFP4 product (one-row steps included), FP8 through the row-exact
products on the window schedule, BF16 through ModelOptRowExact.matmul
past one row, all in pieces of 16 rows, and the block norms below
MLX's 32-row reduction switch. A projection without such a product is
refused up front. Off by default; calls above 64 rows keep MLX's
kernels either way.

Tests: windows of 1 to 8 tokens on paged caches equal the one-row steps
in logits and K/V across the sliding edge and after the ring wraps
(BF16 and float32, dense and mixed formats), 2 to 64 rows of several
sequences, block norms at the production width, unchanged BF16/FP8
decode and prefill bytes, and the refusal.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 and others added 12 commits November 13, 2026 18:01
With exact windows on, calls of more than 64 rows (a decode step of
more than 64 requests, a prompt chunk) left the projections and norms
to MLX's kernels while numericsProfile still claimed exact. Every call
now runs in the existing 16-row pieces (norms from 32 rows), so no row
count degrades. Prompt chunks read each projection's weights once per
piece and prefill is slower with exact windows on.

numericsProfile becomes muse-glimmer-exact-windows-v2: prefill bytes
differ from v1, so checkpoints of the two must not mix. A host that
pins v1 fails closed until it moves to v2.

decodeAndPrefillBytesDoNotMoveForBF16AndFP8 asserted that a 99-row
prefill keeps MLX's bytes with the switch on, which pinned the removed
fallback. It becomes decodeBytesDoNotMoveForBF16AndFP8: both towers
prefill with the switch off and the exact tower decodes with it on, so
one-row BF16 and FP8 steps from the same cache still keep their bytes.
New tests cover 65-row steps, 9 and 16 requests of width 8, and every
projection at 65, 99 and 200 rows against one-row calls.

Co-Authored-By: Claude <noreply@anthropic.com>
The drafter checked only the width of the target's hidden rows, so a
target that tapped other layers of the same count bound and drafted
from the wrong residual streams. MuseGlimmerDFlashTarget now names its
tapped layers and the drafter requires them to equal the artifact's
target_layer_ids (1, 13, 25, 37 and 49 for the published drafter).
Fixture tests refuse a drafter configuration and a tower with other
taps of the same width.

Co-Authored-By: Claude <noreply@anthropic.com>
Typical acceptance can keep a draft the target did not choose, and the
DFlash drafter's advisory history then loses its observation positions
(decision D6 is exact acceptance only). CBv2MTPDrafter gains
requiresExactAcceptance (default false, so every other drafter is
unchanged). When it is true and the configuration asks for any other
rule, CBv2MTPRoundDriver.build returns no driver and EngineV2 reports
"drafter requires exact acceptance"; requests run target-only.
MuseGlimmerDFlashDrafter returns true.

The checkpoint switch test now expects the refusal from the driver and
the engine, and still checks the typical-acceptance switches on a
scripted advisory drafter that waives it.

Co-Authored-By: Claude <noreply@anthropic.com>
Shards open without following symlinks and with their sizes checked,
but the index, config.json and hf_quant_config.json were read with
Data(contentsOf:): a symlink was followed and any size was read. A
present hf_quant_config.json that could not be read was treated as
absent (try?), which skipped its cross-check.

ModelOptIndexedCheckpoint.readRegularFile reads a small checkpoint file
only when it is a regular file and not a symlink, opens it O_NOFOLLOW,
and checks its size with fstat before reading (index 64 MiB, the same
bound the index parser applies; JSON records 4 MiB). Any failure throws
Failure.unsafeFile. stage(directory:) refuses a quantization record
that is present (any directory entry, a dangling symlink included) but
cannot be read. Pins and hashing are unchanged: these only add
refusals. Tests cover a symlinked index through both entries, a
symlinked and an oversized config.json, and an hf_quant_config.json
that is a directory, a dangling symlink or unreadable.

Co-Authored-By: Claude <noreply@anthropic.com>
The weight-only NVFP4 product is computed before weight_scale_2 is
applied, and that unscaled product can leave the FP16 range. The
installer accepted an F16 dense dtype, so an FP16-staged tower with
NVFP4 projections could produce inf. plan() now refuses FP16
activations whenever any projection is NVFP4 (Failure.dtype). The
pinned artifact is BF16, so the pinned path does not change; a tower
without NVFP4 projections still plans in FP16.

Co-Authored-By: Claude <noreply@anthropic.com>
MLXModelContainerEngine forced reference-parity parsing for every .atem
model, while the library default and fork.yaml say the strict reading
stays the default. The engine now takes onyxParsing (default .strict),
and the CLI selects the reference reading only with --onyx-parsing
reference-parity or MLX_SERVER_ONYX_PARSING. An unknown value is an
error.

Tests: a one-invoke frame calls under the default; a frame with two
invokes gives no call by default or with .strict and two calls with
.referenceParity; the handler emits nothing for a rejected call or a
protocol error and keeps reading; CLI defaults, option, environment and
errors. Under the strict reading a user frame that ends at
<|end_of_text|> keeps the marker as text (the upstream adapter closes
frames only at <|eom|> or <|eot|>); the end-of-text test runs both
readings and records that as a known issue instead of pinning it.

Co-Authored-By: Claude <noreply@anthropic.com>
MuseGlimmerOnyxTokenizerLiveTests sat at the top of the test target
without a type tag. It runs the token decoder with the published
tokenizer files, so it moves to Integration/MuseGlimmer/ and is tagged
.integration like the other Muse Glimmer suites. It stays skipped
unless MUSE_GLIMMER_NVFP4_DIR is set. fork.yaml drops the old glob;
the Muse Glimmer section's Integration glob now covers the file.

Co-Authored-By: Claude <noreply@anthropic.com>
Decode and verify rows stay exact at any row count and any number of
requests, in pieces of 16 rows. Prompt chunks, through cbv2Prefill and
prefillWithMTPHidden, now keep MLX's arithmetic with exact windows on:
the bytes of the plain tower, so prefill keeps MLX's matrix kernels and
the drafter on and off prefill alike. The engine never runs a prompt
chunk in a forward with decode or verify rows: packed prefill is off for
this model, and a one-token final prompt chunk is scheduled as a decode
row.

Prompt bytes change relative to v2, so numericsProfile is now
muse-glimmer-exact-windows-v3.

Tests: prompt chunks of 1 to 200 rows equal the plain tower through both
entry points; a request's decode and verify rows keep their bytes while
another request's prompt is prefilled beside them; the real-model window
test prefills through the prompt entry point.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
A model whose prompt bytes depend on where a prompt is cut can declare
`CBv2ModelCapabilities.prefillChunkAlignment`. The scheduler then cuts a
text prompt only at multiples of it, at the prompt end and at a boundary
a prefix restore requires, and runs each cell whole or not at all: a
cell that does not fit the step budget or the mixed-step quota waits and
takes the first claim on the next step (the multimodal block guard,
exempt from the quota). The solo stripe, the plain chunk and demanded
checkpoint ranges do not apply to such a row, and a step always holds
one cell.

Fairness: grid schedulers plan decode rows before prompt rows (after the
claim row; the running order is restored), and a claim step arms no
further claim, so a decode row waits at most one step for a cell and a
deferred cell runs within two steps.

The engine refuses a paged pool whose maxPrefillChunk cannot hold a
cell. The first-token projection plans the same cells and returns
unbounded where a cell would wait or a claim is pending. Nil keeps every
other model's scheduling unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
The tower declares prefillChunkAlignment 1024 (the solo stripe and the
checkpoint stride), so load, other requests and the drafter no longer
move a prompt's cuts or bytes. The numerics profile moves to
muse-glimmer-exact-windows-v4, since v3 checkpoints made under load may
hold off-grid prompt bytes.

Tests: a request's prompt K/V bytes and output are the same alone,
beside another request's decode, and beside it with the drafter on
(bf16, float32), and a restore under load equals the cold run. Test
engines with small pools lower the grid to their chunk.

Co-Authored-By: Claude <noreply@anthropic.com>
Runs the lint job's command (`swift format format --configuration
.swift-format` on the Swift files this branch adds or changes against
main). Layout only: line breaks and the indentation of conditional
imports in seven files.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 and others added 5 commits November 15, 2026 02:06
d-inference dev (bd67dec73, #2157) pins mlx-swift-lm at #434's head. The
provider's Muse Glimmer stack must build on the same SDK, so this branch
takes #434 until it merges into main.

Co-Authored-By: Claude <noreply@anthropic.com>
#434 (c85e84c) merged into main as fe9b528, whose tree equals c85e84c's. This branch already
merged c85e84c, so no file changes. d-inference dev (#2158) now pins main fe9b528, and the stack's
SDK pin must contain it.

Co-Authored-By: Claude <noreply@anthropic.com>
A parameter value is the model's text, and a client's prompt can steer
it. JSONSerialization reads 512 levels, and decoding the result,
encoding it, comparing, hashing and releasing it each recurse once per
level on a cooperative thread's 512 KiB stack. A provider encodes every
call's arguments before it sends them (JSONEncoder.openAIServer), so a
call whose value nested a few hundred levels deep killed the process
with SIGBUS before any error could be returned.

Measured on a cooperative thread, this file's decoding and the encoder
compiled -O -wmo: encoding exhausted the stack at 192 levels of objects
(224 of arrays), and decoding, comparing, hashing and releasing at 512
levels of objects. A debug build failed from 160.

The reader now counts a value's nesting without recursion before it
decodes it. Past 63 levels the value stays text, as a value
JSONSerialization cannot read already does. A call's arguments object
adds one level, so its arguments nest at most 64 deep, the limit
d-inference holds a request body and a replayed call to.

Co-Authored-By: Claude <noreply@anthropic.com>
Both ATEM readers type each value and then normalize the call by its
schema. For a parameter the schema types as an array or an object,
normalization reads the text as JSON again, and JSONSerialization reads
512 levels. So a value that the ATEM reader had kept as text, because it
nested too deep, was decoded whole once more. A d-inference provider
then exhausted a cooperative thread's 512 KiB stack while it encoded the
call, and stopped with SIGBUS. The strict ATEM parser types its values
through the same step.

The nesting count moves to ToolArgumentNormalization, and normalization
now keeps text nested past maximumValueDepth (63) as written. A Python
literal past 32 levels already stays text in the same way. Every caller
of this step gets the bound. Those callers are ToolCallProcessor and the
ATEM, Onyx, Harmony, Gemma, MiniMax, Qwen XML and Pythonic readers.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 18, 2026
#423 now keeps an ATEM value nested past 63 levels as text (824db4c) and bounds JSON text the same way
in the shared ToolArgumentNormalization (31a7ccb), so no Muse tool call can nest deep enough to exhaust
a 512 KiB cooperative stack when it is encoded. No conflicts.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 18, 2026
#423 now keeps an ATEM value nested past 63 levels as text (824db4c) and bounds JSON text the same way
in the shared ToolArgumentNormalization (31a7ccb), so no Muse tool call can nest deep enough to exhaust
a 512 KiB cooperative stack when it is encoded. No conflicts.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 18, 2026
#423 now keeps an ATEM value nested past 63 levels as text (824db4c) and bounds JSON text the same way
in the shared ToolArgumentNormalization (31a7ccb), so no Muse tool call can nest deep enough to exhaust
a 512 KiB cooperative stack when it is encoded. No conflicts.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 18, 2026
#423 now keeps an ATEM value nested past 63 levels as text (824db4c) and bounds JSON text the same way
in the shared ToolArgumentNormalization (31a7ccb), so no Muse tool call can nest deep enough to exhaust
a 512 KiB cooperative stack when it is encoded. No conflicts.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 18, 2026
#423 now keeps an ATEM value nested past 63 levels as text (824db4c) and bounds JSON text the same way
in the shared ToolArgumentNormalization (31a7ccb), so no Muse tool call can nest deep enough to exhaust
a 512 KiB cooperative stack when it is encoded. No conflicts.

Co-Authored-By: Claude <noreply@anthropic.com>
GumbiiDigital added a commit that referenced this pull request Dec 4, 2026
Muse Glimmer 30B: full multimodal baseline — text, vision, video (replay #423, #427, #429, #430, #432 on main)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant