Skip to content

Feature Request: MTP (Multi-Token Prediction) Speculative Decoding for Gemma 4 #1086

Description

@vduke

Feature Request: MTP (Multi-Token Prediction) Speculative Decoding for Gemma 4

Summary

Google recently released official MTP (Multi-Token Prediction) draft models for Gemma 4, enabling 2x decode speedup with zero quality loss. Currently, oMLX strips MTP weights during quantization (_should_skip_tensor in oq.py) rather than using them for inference.

Context

Google's Gemma 4 architecture includes optional MTP heads that predict multiple tokens per forward pass. These are shipped as separate "assistant" models:

  • google/gemma-4-26B-A4B-it-assistant — MTP drafter for 26B-A4B MoE
  • google/gemma-4-31B-it-assistant — MTP drafter for 31B dense

vLLM already has a PR implementing MTP speculative decoding: vllm-project/vllm#41745 (submitted by a Google engineer).

Current Behavior

In omlx/oq.py, MTP tensors are explicitly excluded:

def _should_skip_tensor(name: str) -> bool:
    if ".mtp." in name or name.startswith("mtp."):
        return True
    return False

MTP weights are treated as bloat to be stripped, not a feature to be leveraged.

Proposed Behavior

  1. Preserve MTP weights during model loading (don't strip them)
  2. Add an mtp_enabled model setting (similar to specprefill_enabled)
  3. When MTP is enabled, use the built-in MTP heads for speculative decoding during generate:
    • Forward pass produces N candidate tokens from MTP head
    • Full model verifies candidates in parallel
    • Accepted tokens are emitted, rejected tokens trigger single-token fallback
  4. Support loading the separate assistant model as the MTP drafter

Expected Performance

  • 2x decode speedup with zero quality loss (per Google's benchmarks)
  • Particularly impactful for longer generation sequences
  • Works alongside existing SpecPrefill (prefill speedup) for combined gains

Implementation Reference

Environment

  • oMLX: 0.3.8
  • macOS: Darwin 25.4.0 (arm64)
  • Hardware: Apple M3 Ultra, 256GB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions