[Feature][MRV2][310P] Add temperature / top-k / top-p sampling for MRV2 on the 310P - #16503
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Ascend 310P MRV2 sampler by aligning its sampling capabilities with MRV1. It introduces support for temperature, top-k, and top-p sampling, ensuring that these parameters are correctly processed and applied during inference. The changes include refactoring the sampler to maintain compatibility with MTP draft requirements and adding robust handling for various sampling configurations, while maintaining a fast path for standard greedy decoding. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. Tip 💡 Consider Linking a Related Issue or RFCYour PR title contains the [Feature] tag, indicating a bug fix or new feature. Linking a related issue or RFC in the PR description is strongly encouraged — it gives reviewers helpful context and speeds up the review. You can use any of these keywords:
🙏 Thanks for helping us keep the project well-organized! |
…d with MRV1 on the 310P Signed-off-by: Thiagor2002 <13476117628@163.com>
There was a problem hiding this comment.
Code Review
This pull request implements a Triton-free MRV2 sampler for Ascend 310P, aligning temperature, top-k, and top-p post-processing with MRV1's AscendSampler310 while keeping the MRV2 sampling_states surface. The review feedback highlights a potential division-by-zero issue on Ascend NPUs when mixing greedy and random sampling, and a bug where an explicit top_k = 1 can be overwritten during late-binding of the vocabulary size. It is recommended to initialize unset top_k values to -1 instead of 1 to distinguish them, and to add a regression test. Additionally, the PR title and description should be updated to follow the repository style guide.\n\nSuggested PR Title:\n\nmarkdown\n[Ops][Feature] Add temperature / top-k / top-p sampling aligned with MRV1 on the 310P\n\n\nSuggested PR Summary:\n\nmarkdown\n### What this PR does / why we need it?\n\nThis PR implements a Triton-free MRV2 sampler for Ascend 310P. It aligns temperature, top-k, and top-p post-processing with MRV1's `AscendSampler310` (inverse-CDF random sampling) while keeping the MRV2 `sampling_states` surface required by MTP draft `propose()`.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo.\n\n### How was this patch tested?\n\nTested with unit tests in `tests/ut/_310p/test_model_runner_v2_310p.py` including:\n- `test_sampler_accepts_temperature_and_rejects_penalties`\n- `test_sampler_temperature_scales_logits_before_argmax`\n- `test_sampler_greedy_call_returns_argmax`\n
Signed-off-by: Thiagor2002 <13476117628@163.com>
Signed-off-by: Thiagor2002 <13476117628@163.com>
Signed-off-by: Thiagor2002 <13476117628@163.com>
linfeng-yuan
left a comment
There was a problem hiding this comment.
Please add e2e test for sampling.
Signed-off-by: Thiagor2002 <13476117628@163.com>
|
/rerun Rerun (failed jobs only):
|
i have added e2e test in the newest commit. |
Preserve upstream temperature/top-k/top-p sampling tests and the existing unsupported-parameter coverage. Drop only the obsolete top-k/top-p rejection cases now supported by upstream vllm-project#16503, and adjust their comment. Signed-off-by: UniversePeak <UniversePeak@users.noreply.github.com>
What this PR does / why we need it?
Enable temperature / top-k / top-p sampling on Ascend 310P Model Runner V2.
Ascend310PSampleronly supported greedy (argmax) and rejected non-zero temperature.exponential_/ large RNG can hang under ACLGraph (same issue fixed in MRV1)._random_sample_310p: CPU uniform per request → NPUsoftmax+cumsum+searchsorted), while keeping the MRV2sampling_statessurface required by MTP draftpropose().Refs: MRV1 post-sampling fixes (#8017 / #8077), CDF optimization (#12966).
RFC: #15577
Does this PR introduce any user-facing change?
No. On 310P with
VLLM_USE_V2_MODEL_RUNNER=1, requests may now usetemperature,top_k, andtop_p(previously raisedNotImplementedError). Default greedy behavior is unchanged.How was this patch tested?
UT:
tests/ut/_310p/test_model_runner_v2_310p.py(temperature accept / scale / greedy; still rejects penalties)vLLM main: vllm-project/vllm@84030bb