feat(speculative): Mellum bundled MTP head as a drafter
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 8/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- ai-infra-agents
Direzione di ricerca
Start with src/models/mellum.rs (sanitize at lines 1081-1101, the rotating and standard cache setup near 771-815) and src/server/batch/speculative_burst.rs (mtp_target_family_supported near line 771). The work requires a new drafter module plus an MtpTarget adapter, and it is blocked by #2400. Done means the unit tests named in the issue pass and the real-checkpoint acceptance run is byte-identical with a non-zero acceptance rate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Use the MTP head bundled in JetBrains/Mellum2.1-12B-A2.5B-Thinking-MTP as a speculative drafter, with the same checkpoint passed as target and --draft-model. mlxcel runs the Mellum target (src/models/mellum.rs) but has no Mellum drafter and no Mellum MtpTarget adapter. Blocked by #2400, which adds the native-MTP detection (num_nextn_predict_layers > 0 or mtp.* tensors) and the bundled-drafter dispatch this issue plugs a second family into.
Upstream reference
Neywa-Labs/mlx-vlm#2677 (merge 8c5641c3, commit f417d6f5):
- https://github.com/Neywa-Labs/mlx-vlm/blob/main/mlx_vlm/speculative/drafters/mellum_mtp/mellum_mtp.py (
ModelConfig,MellumMTPDraftModel) - https://github.com/Neywa-Labs/mlx-vlm/blob/main/mlx_vlm/speculative/drafters/mellum_mtp/split.py (
MellumMTPSplitter: no RMSNorm shift) - https://github.com/Neywa-Labs/mlx-vlm/blob/main/mlx_vlm/models/mellum/language.py:
sanitizenow dropsmtp.*; the forward returns the post-norm hidden state when asked (return_hidden). mellum_mtpis registered as anmtp-kind drafter indrafters/__init__.py, andmelluminmtp_split.py.
Architecture (from upstream code and the checkpoint)
Checkpoint config: model_type mellum, num_nextn_predict_layers 1, 28 layers, hidden 2304, 32 heads, 4 KV heads, head_dim 128, layer_types repeating [sliding, sliding, sliding, full], sliding_window 1024, 64 experts top-8, vocab 98304, tie_word_embeddings false. Sliding layers use plain RoPE at rope_theta 500000; full layers use YaRN (factor 16).
- The head (205 tensors under
mtp.):fc.weight(Linear(2 * 2304, 2304, bias=False)),pre_fc_norm_embedding.weight,pre_fc_norm_hidden.weight, one decoder layerlayers.0.*(attention withq_norm/k_norm, per-expert MoEmlp.experts.N.{gate,up,down}_projand routermlp.gate), andnorm.weight. - Forward:
h = fc(concat(pre_fc_norm_embedding(embed(token)), pre_fc_norm_hidden(hidden))), then the single layer with the type oflayer_types[0](sliding_attention, so window 1024 and the sliding RoPE), thennorm; logits through the target'slm_headand embeddings through the target's table.hiddenis the target's post-final-norm state, one per token. - The norms are ordinary RMSNorm: unlike Qwen3-Next, no
+1shift (MellumMTPSplitter.run_sanitize). Experts are stacked toswitch_mlpas the target does. - The drafter cache is a plain, trimmable KV cache (not rotating), so a rejected draft never evicts accepted rows. Upstream requires exactly one prediction layer.
Current mlxcel behavior
MellumWrapper::sanitize(src/models/mellum.rs:1081-1101) drops a tiedlm_headand stacks experts, but does not dropmtp.*; check whether the MTP checkpoint loads as a target today (the acceptance test below pins the answer).- Mellum's target caches are model-owned and mixed:
Cache::Standardfor full layers andCache::Rotating(RotatingKVCache)for sliding layers (src/models/mellum.rs:771-815,MellumWrapperat:1135). A multi-row verify on a rotating cache can overwrite rows that rollback then needs; the Gemma 4 adapters solve the same problem by sizing a rollback buffer to the block (Gemma4MtpTargetAdapter::new_with_block_size,src/models/gemma4_mtp_target.rs:368). mtp_target_family_supported(src/server/batch/speculative_burst.rs:771) does not listLoadedModel::Mellum. Mellum's YaRN helper iscompute_yarn_rope(src/models/mellum.rs:196).
Required changes
src/models/mellum_mtp_drafter.rs(new, +_tests.rs):MellumMtpDraftModelimplementing the coreDraftertrait forDrafterKind::Mtp, built fromMellumModel'sDecoderLayer,Attention,SparseMoeBlockandRMSNorm(src/models/mellum.rs:275-830) and itsstack_experts; do not copy them.from_target_checkpoint(path)loads onlymtp.*tensors withload_weights_from_dir_index_filtered;from_pathaccepts a splitmodel_type: mellum_mtpdirectory. Refusenum_nextn_predict_layers != 1and a hidden or vocab size that differs from the target, naming the field.src/models/mellum_mtp_target.rs(new):MellumMtpTargetAdapterimplementingMtpTargetoverMellumWrapper's per-sequence state, returning the post-norm hidden, with a block-sized rollback buffer on the rotating caches following the Gemma 4 adapter. Batch 1; tree rounds refuse by name.src/models/mellum.rs: dropmtp.*insanitize; add the*_for_sequenceverify and rollback hooks the adapter calls.- Dispatch: in the #2400 dispatch, route a base
model_type: mellumdirectory withmtp.*tensors to the binary-crate loader insrc/models/drafter_loader.rs(coreload_drafterreturnsBinaryCrateDrafterfor it), and addmellum_mtptodrafter_kind_by_model_type()asMtp. AddLoadedModel::Mellumtomtp_target_family_supportedand to the adapter dispatch inspeculative_burst.rs,scheduler.rs,src/commands/generate.rs(run_offline_mtp) andsrc/bin/speculative_bench.rs.
Acceptance criteria
-
src/models/mellum_mtp_drafter_tests.rsloads_only_mtp_tensors_and_stacks_experts: a fixture with target tensors plus a two-expertmtp.*head builds the drafter withswitch_mlpplanes and never reads target-only tensors. - Same file,
norms_are_not_shifted: apre_fc_norm_hidden.weightof ones yields unit scaling (a+1shift would double it). - Same file,
refuses_two_prediction_layers. -
src/models/mellum_tests.rssanitize_drops_mtp_tensorsandsliding_rollback_after_verify_matches_shorter_forward: withsliding_window 4and a 3-token verify past the window, rolling back ton = 0..=3gives the same caches as a plain forward overntokens. -
src/server/batch/speculative_burst_tests.rs: the family gate admitsMellum. - Real checkpoint, integrated:
mlxcel generate -m models/Mellum2.1-12B-A2.5B-Thinking-MTP --draft-model models/Mellum2.1-12B-A2.5B-Thinking-MTP -p "Write a Python function that adds two integers." -n 256 --temp 0reports a non-zero acceptance rate and its output is byte-identical to the run without--draft-model; a prompt longer than 1024 tokens (past the sliding window) also matches. The same pairing works onmlxcel-server --model-draft.
Validation
JetBrains/Mellum2.1-12B-A2.5B-Thinking-MTP is 25.2 GB in BF16 (Hub API, 2026-11-23), so it fits a 128 GB machine. The non-MTP release (JetBrains/Mellum2.1-12B-A2.5B-Thinking) and mlx-community/Mellum2.1-12B-A2.5B-Thinking-6bit carry no mtp.* tensors.
make verify-test
cargo test --profile test-fast mellum
cargo clippy --workspace --all-targets -- -D warnings
cargo fmt --check
python3 scripts/ci/check_cross_repo_refs.py
./target/release/mlxcel download JetBrains/Mellum2.1-12B-A2.5B-Thinking-MTP
Related
#2400 (blocker: native MTP detection and bundled-drafter dispatch; it also carries the Qwen text-only aliases from the same upstream PR), #2917 (target-checkpoint MTP pattern), #1201 (MTP byte-identity).
- Lingua principale
- Rust
- Stelle
- 505
- Fork
- 81
- Merge medio
- 14h 2m
- PR unite (30g)
- 448
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lablup/mlxcel
-
area:core priority:high status:ready type:security
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
priority:medium status:ready type:security
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
area:models modeltype:text priority:medium status:in-progress type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
I maintainer di solito rispondono entro 1 giorno
-
area:models priority:low status:ready type:test
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
area:models modeltype:omni priority:medium status:ready type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di lablup/mlxcel
Issue simili
-
area:ui effort:medium enhancement P7 source:agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
marketing
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Read a requested CodeRabbit PR review's findings with `coderabbit pullrequest --show-threads`Apertadocumentation priority: low tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
nledford/Ladderback#1823 ·
I maintainer di solito rispondono entro 1 giorno
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)Forse già presa @ealwanlee l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
psmux/psmux-plugins#47 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 87/100
I maintainer di solito rispondono entro 1 giorno