Repository navigation
Description
Follow-up to #154. MTP speculative decoding now works correctly and fast for the Gemma 4 Unified target, but the speedup is gated behind an env var by default. This issue tracks making it default-on where it is measurably beneficial.
Background (measured in #154)
With the quantized-drafter fix from #154, the gemma-4-12b-it-4bit target + gemma-4-12B-it-assistant-4bit (4-bit) drafter delivers, at temperature 0:
- ~1.87× decode speedup (≈39 → ≈74 tok/s), output byte-identical to classic decode (exactness-preserving).
…but only with MLXCEL_ENABLE_MTP_B1=1. By default the scheduler declines the singleton (B=1) MTP burst:
src/server/batch/scheduler.rs (~line 1858)
if window.len() == 1 && matches!(dispatch, Mtp { .. }) && !mtp_b1_burst_enabled() {
// "singleton B=1 window is slower than classic Gemma 4 decode on real 31B
// measurements; set MLXCEL_ENABLE_MTP_B1=1 to force..."
return Some(seq); // declined → classic decode
}
Gemma4UnifiedModel::supports_batching() is false (kept off for vision-prefill correctness), so this target is always B=1 → the burst is always declined → no speedup out of the box.
Problem
The B=1 decline guard is global and was calibrated on the 31B bf16 assistant, where B=1 MTP was slower than classic decode. For the 12B + 4-bit assistant the opposite holds (1.87× faster), so declining by default leaves a large, free, exactness-preserving speedup switched off unless the operator knows the undocumented env var.
Goal
Engage B=1 MTP by default for target/drafter pairs where it is beneficial (starting with gemma4_unified + its 4-bit assistant), without regressing the 31B path the guard was protecting.
Possible approaches
- Target-aware guard: allow B=1 MTP by default for
gemma4_unified(and other measured-beneficial families), keep declining for the 31B until re-measured. - Cost-based heuristic: decide from the target/drafter cost ratio (backbone size, drafter layers/bits) instead of a hard-coded model assumption.
- Per-model / config opt-in: a drafter- or target-config flag that flips the default, with
MLXCEL_ENABLE_MTP_B1kept as an override.
Acceptance criteria
mlxcel serve -m mlx-community/gemma-4-12b-it-4bit --draft-model mlx-community/gemma-4-12B-it-assistant-4bit --draft-kind mtp(no env var) engages the MTP burst and shows the ~1.87× speedup.- The 31B path is either unchanged or re-measured and adjusted intentionally (no silent regression).
temperature 0output stays byte-identical to classic decode for the affected targets.MLXCEL_ENABLE_MTP_B1remains available as an explicit override.- A short note in the docs explains when B=1 MTP is enabled by default.
Touchpoints
src/server/batch/scheduler.rs— the singleton-window decline guard (~line 1858).src/server/batch/speculative_burst.rs—mtp_b1_burst_enabled()/ burst entry.docs/— document the default behavior.
Activity
docs: clarify MLXCEL_ENABLE_MTP_B1 is required for 12B unified MTP sp…
perf: run B=1 MTP by default for non-batching targets (gemma4_unified)
feat: Gemma 4 Unified MTP speculative drafter (gemma4_unified_assista…