Repository navigation
perf(qmm): int8-activation prefill on tiled lane weights, default on for dense Qwen3.5/3.8 (+27-34% prefill on 27B) - #1384
Conversation
… on for dense Qwen3.5/3.8 A dense qwen3_5 trunk tiled for the lanes (NAX, DFlash drafter bound) now reads prompts through an int8 port of MLX's affine_qmm_t_int_nax on the tiled layout: the activation is quantized per 64-group row, the product runs on int8 tensor ops and each group's scale, bias and row sum fold into one fp32 step. Qwen3.8-27B, M5 Ultra: prefill 4-bit 1934 -> 2463 tok/s, 8-bit 1788 -> 2396, TTFT -19..-27%, decode level; echo-logprob KLD ~0.0013, perplexity unchanged. LOSSY: on by default for these trunks, `int8_prefill: false` opts out (Prism packs stay opt-in). 4/6/8-bit; 5-bit and views off the 64-column tile decline by name. Kernels registered with the kernel contract; the app shows the default and badges an opt-out.
…e 4-bit 32-column tile - NOTICE names the three ported MLX kernels. - int8_owners is set and read in one unit: listed in unit_globals_ok.txt. - The int8 test covers a 4-bit weight tiled at 32 columns (a GDN joined projection) with a 64-aligned view; the contract adds K 5120 and row/n tiles. - The quantizer builds on metal_stdlib alone (no NAX headers). - A width off a multiple of 64 falls back silently; only 5-bit is declined by name. - qwen3_5: a test of the int8_prefill default and override. - App: MiniCPM-V 4.7 defaults like the other dense trunks; one model-type lookup.
|
🤖 MLXServe-PRBot — code review The port is right:
One bug blocks; one thing needs saying:
Non-blocking: There are no conflicts with main, and CI is still running. It is under 1,000 lines, so it auto-merges once item 1 is fixed, an approved review is posted at that head, and CI is green. Generated by Claude Code |
- CHANGELOG: the v26.11.5 entry for everything since v26.11.4. - CONTRIBUTING: monitor your PR's bot review, follow AGENTS.md, which new models we take, self-review with a subagent, remember the Swift app. - docs/plugin-engine.md: writing an engine plugin; linked from README, plugins.md and plugin-model.md.
|
🤖 MLXServe-PRBot — code review The delta since
The drafter-coupling note and the app's hand-copied model-type list from the last review are unchanged and non-blocking. Generated by Claude Code |
The SSD tier's fingerprint did not know a load's prompts went through the LOSSY int8 prefill, so int8_prefill:false (or the same pack loaded without a drafter) could restore int8-computed K/V and GDN state, and the reverse. - lane_qmm's int8 owner set is Shared, so the engine can ask int8Armed() for a plugin's model under -Dunits; its allowlist line goes. - The load adds an int8-prefill-v1 marker to the layout namespace (int8PrefillNamespace) when the trunk is armed. Int8 off keeps the root. - The engage log names the bound drafter and the off switch; docs/performance.md documents the route, its numbers and how to A/B a drafter with it.
|
🤖 MLXServe-PRBot approved — reviewed at head The delta since
The release docs riding this PR are noted as intended. Still a follow-up: the app's hand-copied model-type list for the default. There are no conflicts with main, and CI is running. At +1,032/-36 it is past the auto-merge size limit, so ddalcu merges it. Generated by Claude Code |
What
On M5 (NAX), a dense Qwen3.5 / 3.6 / 3.8 trunk with a DFlash drafter bound has its projections tiled in place for the
lane_qmmrow lanes, so MLX's own int8 qmm (MLX_ENABLE_INT8_QMM) can never read them. This ports that path intolane_qmm's prefill on the tiled layout:lane_qmm_int8_quant.metal: MLX'saffine_quantize_rows. It quantizes each 64-group of the prompt rows to int8, with per-group f32 scales and sums, and pads to 64-row tiles.lane_qmm_int8{,_head}.metal: MLX'saffine_qmm_t_int_naxandQuantizedBlockLoaderInt, addressing the tiled weight. The product runs on int8 tensor ops; each group's scale, bias and row sum fold into one fp32 step.It is LOSSY and on by default for these trunks.
"int8_prefill": falseinmodel-settings.json(or Model Settings ▸ Int8 prefill ▸ Off) opts out. Prism (Bonsai 2) packs keep their own int8 route, opt-in as before. 4/6/8-bit weights take it. 5-bit declines by name, and a view whose width is not a multiple of 64 takes the fp prefill.Numbers (Qwen3.8-27B, M5 Ultra, int8 off → on)
Scope
Inkling, Flash Next, MoE Qwen and DeepSeek are unaffected: their weights are never tiled. A dense Qwen trunk without a drafter keeps its current prefill path.
Known
rows > 128on a tiled weight, not "this is a prompt". A batched verify or decode whose combined rows pass 128 (9+ DFlash slots × block 16) also takes int8 activations. Row-exactness already ended past 128 rows on the fp prefill path, and the crowd thresholds keep such groups rare. If we want it prompt-only, the caller has to say so; the row count can't.Tests
lane_qmm: int8 on a tiled weight vs the int8 activation's fp32 product, at 4/6/8 bits and both column tiles (64, and 32 for a GDN joined projection's shape), for the whole weight and a row view. 5-bit stays bit-equal to int8-off.knownfinding: MLX's quantizer drops a NaN from a group's absmax, as MLX itself does.Int8lossy, orInt8 off).units-check -Dunits=true: the newint8_ownersset passes (allowlisted: it is set and read in one unit). The check still flagsengines.mlx.spec.round_cost.build_id_mu, which this PR does not touch.