[Feature] improve random_sample#359
Merged
Merged
Conversation
Signed-off-by: yuejun <yuejun@baidu.com>
xyDong0223
approved these changes
May 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Small performance/cleanup PR that swaps the in-place exponential sampling in random_sample to use the xspeedgate_ops.inplace_exponential custom op, removes a dead seq_start_loc computation in the Kunlun attention backend, and corrects the FLA platform mapping so xpu resolves to kunlun instead of intel.
Changes:
- Replace
q[i].exponential_(generator=...)loop withtorch.ops.xspeedgate_ops.inplace_exponentialto speed up random sampling. - Drop unused
seq_start_loc/seq_start_loc_tensorconstruction inKunlunAttentionMetadataBuilder.build. - Update
_check_platformmapping/return type soxpumaps to"kunlun"(replacing prior"intel"and dropping"musa").
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| vllm_kunlun/v1/sample/ops/topk_topp_sampler.py | Use xspeedgate inplace exponential op in the per-generator path. |
| vllm_kunlun/v1/attention/backends/kunlun_attn.py | Remove dead seq_start_loc tensor construction. |
| vllm_kunlun/ops/fla/utils.py | Map xpu → kunlun (drop intel/musa) in _check_platform. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: yuejun <yuejun@baidu.com>
liwei109
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: yuejun yuejun@baidu.com
PR Description
Checklist (Required)
Before submitting this PR, please ensure that all the following items are completed:
pre-commitchecks.git commit -s.PR Type
Please prefix the PR title with one or more of the following labels to help reviewers quickly understand the nature of the change:
[Feature]– New features or enhancements (e.g. Attention, Communicator, Kernel, Worker, etc.)[Bugfix]– Bug fixes[CI/Build]– CI, build system, or infrastructure improvements[Doc]– Documentation updates or fixes[Misc]– Other changes that do not fit the above categories (use sparingly)Detailed Checklist (Click to Expand)
Thank you for contributing to vLLM Kunlun! To help us maintain high code quality and streamline the review process, please ensure your PR meets the following requirements.
1. Code Quality
pre-commit).2. Testing
3. DCO Compliance
This project follows the Developer Certificate of Origin (DCO).
Signed-off-by:line.git commit -sto automatically add the sign-off.4. Review Expectations
During the review process, maintainers may:
We appreciate your patience and collaboration throughout the review process!