Skip to content

Speculative decoding (MTP)

Speculative decoding lets a smaller assistant propose future tokens while the target model verifies them in parallel. mistral.rs exposes this through the MTP (Multi-Token Prediction) API: attach an assistant checkpoint and the engine drafts several tokens per target step.

Output stays exact: every accepted token is verified by the target model before it is emitted.

Terminal window
mistralrs run -m google/gemma-4-E4B-it --quant 8 \
--mtp-model google/gemma-4-E4B-it-assistant \
--mtp-n-predict 6

--mtp-model accepts a Hugging Face id or a local path. The same flags work with mistralrs serve. See run and serve flag references.

--mtp-n-predict controls how many assistant tokens are proposed per step. If it is omitted, mistral.rs reads num_assistant_tokens from the assistant's generation_config.json and falls back to 6.

| Mode | Target models | Assistant model | Status | |---|---|---|---| | MTP | Gemma 4 | Gemma 4 assistant checkpoints | Supported with paged attention |

Legacy target/draft speculative decoding has been removed. New speculative decoding features use the MTP proposer/target path.

Gemma 4 assistant checkpoints are MTP drafters for Gemma 4 target models. See the google/gemma-4-E4B-it-assistant model card for the upstream checkpoint. A downloaded checkout works too:

Terminal window
mistralrs run -m google/gemma-4-E4B-it --quant 8 \
--mtp-model ./gemma-4-E4B-it-assistant \
--mtp-n-predict 6

Non-paged KV-cache MTP is intentionally disabled for now, which is why paged attention is required (see the note at the top).

The target and assistant configs must match where the implementation requires it, including vocabulary size and target hidden size. Mismatches fail at load, before generation starts.

MTP remains exact: accepted output is verified by the target model before it is emitted. Throughput gain depends on how many proposed tokens the target accepts and on the cost of the target verification pass.

MTP supports batched generation and constrained decoding.

MTP is configured at launch time only (CLI flags, Runner(...), or the model builder). There is no per-request HTTP field to toggle it; load the server with the assistant attached and every request uses it.