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

[Bugfix][Kernel] Fix per-token/per-channel quantization for Hopper scaled mm #12696

Merged
merged 2 commits into from
Feb 3, 2025

Conversation

tlrmchlsmth
Copy link
Collaborator

@tlrmchlsmth tlrmchlsmth commented Feb 3, 2025

This fixes the selection between grouped vs per-tensor or per-token quantization. In some cases, the linear layers will pass in transposed scales (e.g. 1 x num_tokens instead of num_tokens x 1). This simplifies and makes the dispatching to the per-token/per-channel/per-tensor case more flexible.

Fixes the error:

E       RuntimeError: Unsupported scale group shapes for CUTLASS 3.x GEMM.
E        a_scale_group_shape must be [1, 128], got: [1, 2048]
E       b_scale_group_shape must be [128, 128], got: [1, 2560]

when running for example: vllm serve nm-testing/TinyLlama-1.1B-Chat-v1.0-FP8_DYNAMIC-e2e

Signed-off-by: Tyler Michael Smith <tyler@neuralmagic.com>
Copy link

github-actions bot commented Feb 3, 2025

👋 Hi! Thank you for contributing to the vLLM project.
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 do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

Copy link

mergify bot commented Feb 3, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @tlrmchlsmth.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Feb 3, 2025
Signed-off-by: Tyler Michael Smith <tyler@neuralmagic.com>
@mergify mergify bot removed the needs-rebase label Feb 3, 2025
Comment on lines -37 to +22
if ((a_scale_group_shape == GroupShape{M, K} ||
a_scale_group_shape == GroupShape{1, K}) &&
(b_scale_group_shape == GroupShape{K, N} ||
b_scale_group_shape == GroupShape{K, 1})) {
// "standard per-tensor/per-token/per-channel" scaling
if ((a_scales.numel() == 1 || a_scales.numel() == a.size(0)) &&
(b_scales.numel() == 1 || b_scales.numel() == b.size(1))) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the main change

@tlrmchlsmth tlrmchlsmth marked this pull request as ready for review February 3, 2025 15:59
Copy link
Collaborator

@LucasWilkinson LucasWilkinson left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for fixing this!

@tlrmchlsmth tlrmchlsmth added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 3, 2025
Copy link
Member

@mgoin mgoin left a comment

Choose a reason for hiding this comment

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

LGTM

@simon-mo simon-mo mentioned this pull request Feb 3, 2025
6 tasks
@simon-mo simon-mo merged commit c11de33 into vllm-project:main Feb 3, 2025
68 of 73 checks passed
yessenzhar pushed a commit to deepinfra/vllm that referenced this pull request Feb 3, 2025
…aled mm (vllm-project#12696)

Signed-off-by: Tyler Michael Smith <tyler@neuralmagic.com>
fxmarty-amd pushed a commit to fxmarty-amd/vllm that referenced this pull request Feb 7, 2025
…aled mm (vllm-project#12696)

Signed-off-by: Tyler Michael Smith <tyler@neuralmagic.com>
Signed-off-by: Felix Marty <felmarty@amd.com>
ShangmingCai pushed a commit to ShangmingCai/vllm that referenced this pull request Feb 10, 2025
…aled mm (vllm-project#12696)

Signed-off-by: Tyler Michael Smith <tyler@neuralmagic.com>
pathorn pushed a commit to deepinfra/vllm that referenced this pull request Feb 14, 2025
…aled mm (vllm-project#12696)

Signed-off-by: Tyler Michael Smith <tyler@neuralmagic.com>
panf2333 pushed a commit to yottalabsai/vllm that referenced this pull request Feb 18, 2025
…aled mm (vllm-project#12696)

Signed-off-by: Tyler Michael Smith <tyler@neuralmagic.com>
pathorn pushed a commit to deepinfra/vllm that referenced this pull request Feb 19, 2025
…aled mm (vllm-project#12696)

Signed-off-by: Tyler Michael Smith <tyler@neuralmagic.com>
kerthcet pushed a commit to kerthcet/vllm that referenced this pull request Feb 21, 2025
…aled mm (vllm-project#12696)

Signed-off-by: Tyler Michael Smith <tyler@neuralmagic.com>
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.

5 participants