[Bugfix] Enforce contiguous input for dynamic_per_token FP8/INT8 quant#19452
Conversation
Signed-off-by: mgoin <mgoin64@gmail.com>
|
👋 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 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 🚀 |
There was a problem hiding this comment.
Summary of Changes
Hello @mgoin, 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 resolves an issue where the dynamic per-token FP8 and dynamic INT8 quantization kernels would fail if their input tensors were not contiguous in memory. The change ensures that the input is made contiguous before being passed to the underlying kernels, fixing the RuntimeError and allowing models like DeepSeek V2 Lite FP8-dynamic to run correctly.
Highlights
- Fix Runtime Error: Addresses a
RuntimeErrorthat occurred when dynamic per-token FP8 or dynamic INT8 quantization kernels received non-contiguous input tensors. - Enforce Contiguity: Ensures that the input tensor passed to the
dynamic_per_token_scaled_fp8_quantanddynamic_scaled_int8_quantC++ kernels is contiguous by explicitly calling.contiguous()on the input.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request effectively resolves a RuntimeError that occurred when non-contiguous tensors were passed as input to specific FP8 and INT8 quantization kernels. The fix involves adding .contiguous() calls to the input tensors in vllm/_custom_ops.py before they are processed by the underlying C++ operations. These changes are well-targeted and directly address the issue described.
My review feedback primarily focuses on enhancing code maintainability by suggesting the addition of inline comments. These comments would explain why the .contiguous() calls are necessary (i.e., due to kernel requirements), which is helpful for future developers and aligns with existing commenting practices within the codebase (such as for the rms_norm function).
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
1 similar comment
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
LucasWilkinson
left a comment
There was a problem hiding this comment.
Can we just update the kernel to support non-contiguous data? I think this should be our default response to these kind of bugs
|
I worry about losing the vectorization for the non-contiguous case, but okay we can make the change after Wentao lands the vectorization refactor in #19233 |
|
Will address in future work, let us land fix for now |
Purpose
We require that the inputs are contiguous for both the
dynamic_per_token_scaled_fp8_quantanddynamic_scaled_int8_quantkernels. This PR enforces that as I ran into an error when evaluating a deepseek model.Test Plan
Tested using FP8-dynamic DeepSeek V2 Lite (per token and per channel)
Test Result
Before:
After: