Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NVIDIA] Fix an issue to use current stream for the nvfp4 quant #13632

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

kaixih
Copy link
Contributor

@kaixih kaixih commented Feb 20, 2025

This uses the current stream (as a common practice for other cuda ops).

Signed-off-by: kaixih <kaixih@nvidia.com>
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@kaixih
Copy link
Contributor Author

kaixih commented Feb 20, 2025

cc. @trevor-m

@trevor-m
Copy link

cc. @trevor-m

Thanks @kaixih!

@kaixih
Copy link
Contributor Author

kaixih commented Feb 20, 2025

Adding @mgoin @LucasWilkinson who reviewed the original PR. Some context, we noticed that we should have use the current stream instead of from a pool when setting the cuda stream. This PR fixes it. PTAL.

auto stream = at::cuda::getStreamFromPool(false, input.get_device());
if (stream == nullptr) {
std::cerr << "Warning: Null CUDA stream" << std::endl;
}
auto stream = at::cuda::getCurrentCUDAStream(input.get_device());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me as it's more inline with other uses. What was the issue that popped up because of this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getStreamFromPool was giving a different stream for this kernel, so ops later on which are running on the main/current stream might try to access the result tensors before this kernel is finished. This was causing incorrect results and NaNs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We got some NaN values when the fp4 quant is issued to the wrong stream. I guess when we test e2e model. @trevor-m can provide more info.

@tlrmchlsmth tlrmchlsmth added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 20, 2025
@tlrmchlsmth tlrmchlsmth enabled auto-merge (squash) February 20, 2025 21:48
@simon-mo simon-mo merged commit 27a09dc into vllm-project:main Feb 21, 2025
77 of 85 checks passed
michaelrglass pushed a commit to michaelrglass/vllm that referenced this pull request Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants