Repository navigation
feat(speculative): use a qwen4_exp checkpoint's own mtp.* head as the drafter - #2918
Merged
inureyes merged 3 commits intoNov 10, 2026
Merged
Conversation
… drafter A qwen4_exp target conversion that keeps its mtp.* tensors (mlx-community/Qwen3.8-Flash-Next-4bit-mtp) can now be passed again as --draft-model / --model-draft. resolve_drafter_kind detects the head from its tensors, like Inkling, and an explicit --draft-kind mtp on a checkpoint without them fails with the new DrafterError::NoEmbeddedMtpHead. Without --draft-kind such a directory resolves as before. Qwen4ExpMtpDraftModel::from_target_checkpoint derives the head config with Qwen4ExpMtpConfig::from_target_json (block_size 4, the target text_config, only the mtp.* quantization overrides with the prefix stripped) and loads only the shards the index maps a head tensor to through load_weights_from_dir_index_filtered, logging the head's resident size. The mtp prefix predicate now lives in mlxcel-core and the target sanitize delegates to it. The split qwen4_exp_mtp directory path is unchanged. Closes #2917
Replace `.err().expect()` with `.expect_err()` in the embedded-head refusal test (clippy::err_expect under -D warnings), correct the drafter_loader comment about when the qwen4_exp arm is reached, and record the M3 Ultra validation of mlx-community/Qwen3.8-Flash-Next-4bit-mtp in the supported-models row: byte identity with classic on three prompts, acceptance rates, the 1.61 GiB head and the single count in mlxcel inspect. Refs #2917
Member
Author
|
Real-model results on an M3 Ultra (512 GB), release build of
Command:
|
inureyes
marked this pull request as ready for review
November 10, 2026 02:13
inureyes
deleted the
feature/issue-2917-qwen4-exp-embedded-mtp-drafter
branch
November 10, 2026 02:13
This was referenced Nov 10, 2026
inureyes
added a commit
that referenced
this pull request
Nov 10, 2026
## Summary Records the timing and memory measurements that #2908, #2906, #2912, #2909, #2911 and #2918 deferred to a quiet host, in `docs/benchmark_results/qwen4-exp-deferred-measurements-m3ultra-2026-11-10.md` (Mac Studio M3 Ultra, 512 GB, `main` @ `60a3270c`). - Native MTP (#2880, #2917): 1.30x / 1.10x / 1.76x (code / prose / enumeration) for the OptiQ 2-bit target with the bf16 split head, 1.38x / 1.00x / 1.74x for the 4-bit target with its embedded head. - SSD expert streaming (#2882): decode 42.8 tok/s resident, 23.0 at a 24 GB arena (89.8% hit), 18.3 at 8 GB (74.9% hit). Router sync costs 8.0 s per run at both sizes, more than the I/O wait. Output identical across arms. - External PLE (#2881): 31 GB less resident (78.5 to 47.3 GB), same TTFT at 4K and 32K, identical output in every mode. - Prompt-cache second turn (#2885): 0.51 to 0.60 s cached vs 15.1 s (16K) and 28.6 to 28.9 s (32K) after a reset, byte-identical in 10/10 repetitions. - macOS memory soak (#2883): 0 compressions and 0 swap-outs in every setting. A 512 GB host cannot show the eviction the issue targets. ## Script changes - `scripts/bench_speculative.sh`: new `flashnext` and `flashnext4` pairings. - `scripts/macos_memory_soak.sh`: send the `model` field (every request got HTTP 400 without it), and default `--out` gets a `-wire-weights` suffix under `--wire-weights` so it no longer overwrites the plain run. ## Not covered A Mac with less memory than the checkpoint, the `prepare-expert-stream` contiguous file, and streaming combined with the external PLE table. Refs #2880, #2881, #2882, #2883, #2885, #2917
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
qwen4_exptarget conversion that keeps itsmtp.*tensors (mlx-community/Qwen3.8-Flash-Next-4bit-mtp) can now serve as its own MTP drafter: pass the target directory again as--draft-model(mlxcel generate) or--model-draft(mlxcel-server). No new flag, the Inkling convention.resolve_drafter_kindresolvesMtpfor aqwen4_expdirectory whose index or headers holdmtp.*/model.mtp./language_model.mtp.tensors. The predicate lives inmlxcel-coreand the target sanitize'sis_mtp_keydelegates to it.--draft-kind mtpon a checkpoint without the head fails with the newDrafterError::NoEmbeddedMtpHead; without--draft-kindsuch a directory resolves as before. Coreload_drafterrefusesqwen4_expby name, the binarydrafter_loaderbuilds it.Qwen4ExpMtpConfig::from_target_jsonbuilds the drafter config (block_size: 4, the targettext_config,tie_word_embeddings) and keeps only the default quantization pair plus themtp.*overrides with the prefix stripped, then runs the existingfrom_json.Qwen4ExpMtpDraftModel::from_target_checkpointloads throughload_weights_from_dir_index_filtered, so only the head shard is opened; it logs the head's resident bytes.total_sizealready counts the head once, so nothing changed there.qwen4_exp_mtpdirectory path and thehc_countcheck are unchanged.Tests: the tiny fixture written as a target checkpoint (with an unreadable non-mtp shard in the index) and as a split directory gives identical draft logits; quantization stripping and block size;
NoEmbeddedMtpHead; thehc_countrefusal for the embedded head; unchanged resolution withoutmtp.*; missing indexed shard named in the error. Real model (M3 Ultra,Qwen3.8-Flash-Next-4bit-mtp): offline MTP is byte-identical to classic on English, code and Korean prompts (acceptance 0.611 / 0.731 / 0.507), the head is resident at 1.61 GiB,mlxcel inspectcounts it once, and the server with--model-draftreturns the offline output; details, plus a pre-existing classic-server divergence on this target that the split drafter shows too, are in the PR comment.Closes #2917