Skip to content

Conversation

jinzhen-lin
Copy link
Contributor

@jinzhen-lin jinzhen-lin commented Apr 2, 2025

#14138 optimized the marlin kernel and introbuted a new parameter use_atomic_add and new env var VLLM_MARLIN_USE_ATOMIC_ADD. However, when using it with V1 engine, we would got an error like

File "/root/miniconda3/lib/python3.10/site-packages/torch/_inductor/codecache.py", line 644, in dumps
    self.dump(obj)
TypeError: cannot pickle 'PyCapsule' object

To reproduce

VLLM_MARLIN_USE_ATOMIC_ADD=1 vllm serve Qwen/Qwen2-1.5B-Instruct-GPTQ-Int4

I don't sure the actual reason, but I found that if I don't use m (input_size) as a part of the condition indicated whether we use atomic add or not, the error is gone.

This PR fix this problem by moving the condition of m to c++ code. This would also improve kernel performance of some special case, since marlin may launch several kernels with different m size in single gptq_marlin_gemm.

Copy link

github-actions bot commented Apr 2, 2025

👋 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.

🚀

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.

Interesting.. if we can do the logic in the c++ then why not move it all there? I'm sure we have the information on n and k at that level. cc @bnellnm @ProExpertProg that might know why this specific operation fails compilation

@ProExpertProg
Copy link
Collaborator

If I had to guess, looking at m in python is traced by Dynamo, and because m is dynamic and used in a max expression, the compilation gets specialized for m and then we potentially recompile when m is different.

I'll look at the repro to make sure there aren't other footguns here. And we should add this case to compilation tests.

@mgoin mgoin added the ready ONLY add when PR is ready to merge/full CI is needed label Apr 5, 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.

Okay feel free to add as a test case Luka, for now we can land

@mgoin
Copy link
Member

mgoin commented Apr 5, 2025

BTW @jinzhen-lin it would be great if you could join the developer slack to participate in discussions (https://slack.vllm.ai/). We've been refactoring fused moe recently.

Unrelated to this PR, but could you consider adding support for channelwise scales for moe_wna16? There are several places that assume that group_size != -1 (example 1, example 2) and it would be good to support channelwise quantization in the triton implementation.

@jinzhen-lin
Copy link
Contributor Author

BTW @jinzhen-lin it would be great if you could join the developer slack to participate in discussions (https://slack.vllm.ai/). We've been refactoring fused moe recently.

Unrelated to this PR, but could you consider adding support for channelwise scales for moe_wna16? There are several places that assume that group_size != -1 (example 1, example 2) and it would be good to support channelwise quantization in the triton implementation.

I would develop the channelwise quantization if I have time. BTW, #14447 support channelwise quantization and have better performance than triton/cuda version.

@vllm-bot vllm-bot merged commit 2fa66ef into vllm-project:main Apr 6, 2025
78 of 81 checks passed
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
lengrongfu pushed a commit to lengrongfu/vllm that referenced this pull request Apr 7, 2025
@ProExpertProg
Copy link
Collaborator

Btw, I wasn't able to reproduce this (I made sure I used a commit before this one was merged), but ping me if similar issues occur

yangw-dev pushed a commit to yangw-dev/vllm that referenced this pull request Apr 21, 2025
lk-chen pushed a commit to lk-chen/vllm that referenced this pull request Apr 29, 2025
RichardoMrMu pushed a commit to RichardoMrMu/vllm that referenced this pull request May 12, 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.

4 participants