Skip to content

Generalize native MTP beyond the Qwen3.5 singleton path (model coverage registry + batched MTP) #2602

Description

@Zigfreidish

Problem

Native multi-token prediction (worker/runtime/native_mtp/) is a strong decode accelerator (~1.3–1.7× at typical accept rates per the cost model in batch_generator.py), but its current envelope is narrow:

  • Model coverage: activation is gated on the Qwen3.5 config shape (qwen35_model.py, qwen35_vlm_model.py) with MTP head weights present. DeepSeek-V3-style MTP heads and other families that ship draft heads are not recognized.
  • Batch shape: the patched GenerationBatch.next only engages MTP "when the batch holds exactly one MTP-capable sequence"; extend/filter deliberately drop MTP state when continuous batching reshapes the batch. Any concurrent load silently loses the speedup.
  • Hardware gating: the known-limitation note in batch_generator.py (compute-bound M1/M2 single-stream decode can make MTP net-negative) is documented but not enforced — there is no device-aware auto-enable/disable policy, so operators must know the caveat themselves.

Proposed scope

  • A declarative MTP capability registry (config-shape + weight-presence detection per family) instead of Qwen3.5-specific probing, starting with DeepSeek-V3-style num_nextn_predict_layers heads.
  • Batched MTP: keep per-sequence MTP state across extend/filter for sequences that remain singleton-timeline-safe, or run the verify forward batched across MTP-capable sequences.
  • Device-aware activation policy: use the existing Apple Silicon telemetry (see test_apple_silicon_telemetry.py) to auto-disable MTP where the 2-token verify forward is compute-bound, with an operator override and a receipt recording the decision.

Verification

  • Greedy-identity contract tests per newly covered family (mirroring tests/test_mlx_lm_mtp_patch.py).
  • Throughput probes on batch sizes 1/2/4 recording accept rate and net tokens/s vs baseline.
  • Receipt fields for activation decision (enabled/compatible/weights_present/reason already exist in melix.native_mtp.* metadata — extend with the device policy outcome).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions