Background
llama.cpp's --spec-draft-p-min (default 0.75) is the minimum acceptance probability for a drafted token. Today sharpi's MTP path uses pure greedy verification: a draft is accepted iff `argmax(target_logits) == draft` (probability threshold = 1.0 on argmax). This means we reject more drafts than necessary on close calls where the draft is a plausible alternative.
llama.cpp accepts a draft whenever `softmax(target_logits)[draft] >= p_min` — i.e. as long as the draft is a reasonably probable continuation. This raises the acceptance rate at the cost of slight output divergence vs the no-MTP baseline.
Scope
- Add `SamplingParams.SpecDraftPMin` (default 1.0 = current behavior, exact argmax match).
- Add `--spec-draft-p-min ` to `src/SharpInference.Cli/RunCommand.cs`.
- In `MtpDecoder.Decode`, swap the current `argmax` comparison for a softmax + threshold check:
- Compute `p_draft = softmax(target_logits)[draft]`.
- Accept iff `p_draft >= sp.SpecDraftPMin`; reject otherwise and re-emit `argmax(target_logits)` as the correction.
- Document the parity trade-off: `p_min < 1.0` means sharpi will not match the greedy MTP-disabled baseline token-for-token. This is the same divergence llama.cpp accepts in exchange for higher decode throughput.
Notes
- Requires a partial softmax (only the verifier value at `draft` is needed; can short-circuit by computing `exp(logits[draft]) / sum(exp(logits))` with the standard log-sum-exp trick — or just normalize the top-K). Per-step cost is tiny (`O(V)` reductions; vocab fits in cache).
- Sensible default in llama.cpp is 0.75. Sharpi should keep the default at 1.0 so existing test parity (MtpDecoder_GreedyParity, etc.) holds; users opt into the looser threshold explicitly.
- File: `src/SharpInference.Engine/Sampler.cs` (SamplingParams), `src/SharpInference.Cli/RunCommand.cs` (CLI flag), `src/SharpInference.Engine/MtpDecoder.cs` (acceptance check).
Acceptance
Related
Background
llama.cpp's
--spec-draft-p-min(default 0.75) is the minimum acceptance probability for a drafted token. Today sharpi's MTP path uses pure greedy verification: a draft is accepted iff `argmax(target_logits) == draft` (probability threshold = 1.0 on argmax). This means we reject more drafts than necessary on close calls where the draft is a plausible alternative.llama.cpp accepts a draft whenever `softmax(target_logits)[draft] >= p_min` — i.e. as long as the draft is a reasonably probable continuation. This raises the acceptance rate at the cost of slight output divergence vs the no-MTP baseline.
Scope
Notes
Acceptance
Related