Pushing MTP to the limit with --spec-draft-p-min (15% faster) #25198
Replies: 4 comments 1 reply
|
My results Gemma4-31B-MTP
|
|
So I spend a couple of days running Gemma 4 31B in these two configuration while logging the output with
And here are the results from the short program I used to analyze the logs.
You'll notice that Avg Acceptance is lower for the Benchmark (58% vs 72%). Usually, lower acceptance means the draft model is failing more often, which should slow things down. But the Benchmark is actually ~15% faster: because the Benchmark is allowed to guess up to 16 tokens, when it is right, it gets a huge head start. This is reflected in the Avg Draft Len (5.8 vs 3.8). That said, the Benchmark avoids the biggest pitfall of speculative decoding: guessing 16 tokens of complete nonsense. If the draft model is confused, it stops early and lets the main model take over. So it sounds like it works not just in synthetic benchmarks but in real-life workloads. |
|
Interesting findings. I've always run |
|
Confirmed |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The guides for draft model MTP often call for a single knob: n-max or number of tokens to draft for speculative decoding.
If we increase just the n-max, eventually the generation speed starts to fade.
But there's also an important knob to increase the minimum speculative decoding probability. It stop the drafting head earlier, once it starts getting unsure:
In other words, with this knob the drafting head does less work when it isn't sure; say, on novel work when a draft head is essentially guessing, this limit stops the head from generating too many tokens.
How can we use it?
But there's a flip side: if an output is fully encoded in the context, the drafting head can output a lot of tokens with a very high probability.
So if we increase the p-min from the default 0.0 to say 0.8, and bump the n-max to a higher number, say 16, we could get the best of both worlds: a sensible speedup on novel workloads without waste, and a major speedup for common code generation and refactoring tasks that usually include significant unchanged chunks of the existing code.
I tried the exact combo on a pair of dense models on a synthetic yet realistic agentic coding benchmark: refactor a function and emit the result.
And it did not disappoint:
n_max=1n_max=4n_max=16, p_min=0.8I also tried this combo with a code recital benchmark (cite a function from a large file):
n_max=1n_max=4n_max=16, p_min=0.8Feel free to try this for yourself.
Hardware used: 5090 power limited to 400W.
All reactions