[NPU] Enable non-greedy MTP sampling - #32495
sglang-npu-bot merged 8 commits into
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
| npu_mtp_non_greedy_sample, | ||
| ) | ||
|
|
||
| predict, accept_index, num_correct_drafts = npu_mtp_non_greedy_sample( |
There was a problem hiding this comment.
Is there too much isolation here? Are there too many duplicate codes in the newly added files?
There was a problem hiding this comment.
Updated. NPU now shares the existing non-greedy sampling flow, with only backend-specific operator selection and tensor preparation kept in the NPU branch. The duplicated implementation have been removed.
| sampling_info.top_ps, verify_input.draft_token_num, dim=0 | ||
| ), | ||
| ) | ||
| maybe_detect_nan( |
| chain_speculative_sampling_triton | ||
| if use_rejection_sampling | ||
| else tree_speculative_sampling_target_only | ||
| ) |
There was a problem hiding this comment.
Run the import as command to normalize the names of the methods invoked by the NPU and GPU. That is, you can write the names only once.
sampling_fn = (
chain_speculative_sampling_triton
if use_rejection_sampling
else tree_speculative_sampling_target_only
There was a problem hiding this comment.
Updated. Changes here have been minimized.
26ce82a to
36d0350
Compare
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
|
/rerun-failed-ci |
3 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
Motivation
NPU MTP verification currently uses greedy argmax for non-greedy requests.
Consequently,
temperature,top_k, andtop_pdo not take effect duringspeculative verification.
With GLM-4.7-Flash on GPQA, enabling non-greedy MTP reduced the observed
accuracy from approximately ~70% to ~50%. This PR enables
probability-based non-greedy MTP sampling on NPU.
Modifications
eagle_sample.srt/hardware_backend/npu/speculative/mtp_sampling.py.renormalization.
sampling for
tree_topk=1chains.non-greedy configurations.
Sampling algorithm and kernel unit tests are covered in
sgl-kernel-npu; noduplicate SGLang-local test is added.
Accuracy Tests
Model:
GLM-4.7-FlashDataset:
GPQAtemperature=1,top_p=0.95temperature=1,top_p=0.95temperature=0,top_p=1The non-greedy MTP accuracy recovered to the expected range, while existing

non-MTP and greedy behavior remained unchanged.
before:
after:

Speed Tests and Profiling
Checklist
CI States
Latest PR Test (Base): ❌ Run #33240931809
Latest PR Test (Extra): ❌ Run #33240931714
Latest PR Test (AMD ROCm 7.2): ❌ Run #33240931803