Skip to content

[Quantization][Feature] Add AWQ quantization in vllm-ascend.#4316

Open
menogrey wants to merge 15 commits intovllm-project:mainfrom
menogrey:add_awq_quant2
Open

[Quantization][Feature] Add AWQ quantization in vllm-ascend.#4316
menogrey wants to merge 15 commits intovllm-project:mainfrom
menogrey:add_awq_quant2

Conversation

@menogrey
Copy link
Copy Markdown
Collaborator

@menogrey menogrey commented Nov 20, 2025

What this PR does / why we need it?

Add AWQ quantization in vllm-ascend. Most of the code refer to existing implement , and new quantization adaptation refer to compressed tensor: #4036 .
Known issue:

  • Use export VLLM_ASCEND_ENABLE_NZ=0 to avoid error when processing weights.
  • expert parallel is not supported now.
  • Some models have accuracy issue, Qwen3-235B-A22B-Instruct-AWQ Qwen3-VL-235B-A22B-Instruct-AWQ and Qwen2.5-VL-32B-Instruct-AWQ. More infomation at [Feature]: Add AWQ quantization support for vllm-ascend #4378

Does this PR introduce any user-facing change?

How was this patch tested?

@menogrey menogrey marked this pull request as draft November 20, 2025 13:12
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for AWQ quantization in vllm-ascend. The changes are well-structured, adding the necessary configurations and Ascend-specific implementations for AWQ, including linear and MoE layers. A key improvement is the added robustness in AscendRMSNorm to handle different quantization configurations without crashing. My review has identified a couple of redundant function calls within the new npu_fused_experts function that should be removed to improve performance.

Comment thread vllm_ascend/quantization/awq/awq.py Outdated
# gmm1: gate_up_proj
hidden_states, pertoken_scale = torch_npu.npu_dynamic_quant(hidden_states)
if not use_wna16:
hidden_states, pertoken_scale = torch_npu.npu_dynamic_quant(hidden_states)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The call to torch_npu.npu_dynamic_quant() on this line is redundant, as it's already been called unconditionally on line 79. This duplicate call is unnecessary and negatively impacts performance. It should be removed. A similar issue is present on line 108.

Comment thread vllm_ascend/quantization/awq/awq.py Outdated
hidden_states = torch_npu.npu_swiglu(hidden_states)
hidden_states, pertoken_scale = torch_npu.npu_dynamic_quant(hidden_states)
if not use_wna16:
hidden_states, pertoken_scale = torch_npu.npu_dynamic_quant(hidden_states)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Similar to the issue on line 81, this call to torch_npu.npu_dynamic_quant() is redundant because it was already called on line 106. Please remove this unnecessary duplicate call to avoid performance degradation.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@MengqingCao
Copy link
Copy Markdown
Collaborator

@paulyu12 this pr implement AWQ quantization, and now it is under testing, just at you to take a look

@menogrey
Copy link
Copy Markdown
Collaborator Author

Validation on this issue #4378

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@wangxiyuan
Copy link
Copy Markdown
Collaborator

Please rebase to main now.

@menogrey menogrey force-pushed the add_awq_quant2 branch 2 times, most recently from 7251f58 to ce953d2 Compare November 29, 2025 03:17
@menogrey menogrey marked this pull request as ready for review December 1, 2025 11:05
@menogrey menogrey changed the title [Draft][Quantization][Feature] Add AWQ quantization in vllm-ascend. [Quantization][Feature] Add AWQ quantization in vllm-ascend. Dec 1, 2025
def __init__(self, quant_config: AWQQuantConfig):
self.quant_config = quant_config

def process_weights_after_loading(self, layer: torch.nn.Module) -> None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a solid solution for unifying weight formats.
By preprocessing the weights during the loading phase, you effectively resolve the packing layout discrepancy between GPU and NPU, which is critical for compatibility.

Optimization Suggestions:
However, for larger models, the current for loop might introduce noticeable latency due to repeated kernel launches. Additionally, bitwise shift operations (>>, <<) can be less efficient than arithmetic operations on NPU hardware.

I suggest refactoring this implementation to vectorize the logic (eliminating the loop) and replace the bitwise shifts with equivalent multiplication and integer division. This should significantly improve the loading performance.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for your suggestions. I try to remove the for loop but an OOM problem occurred, and the fact is if you want to execute the unpack operation, you have to alloc a big tensor (8x times memory for one tensor), and need more temporary variable if not using a in-place operation (like the bitwise operation). I think it is a trade-off between the memory usage and execution efficiency, but for a quantization, the memory usage is more important, so i won't change it, unless you have some better suggestions. @SlightwindSec

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fair point. I agree that avoiding OOM is the top priority here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 5, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Signed-off-by: menogrey <1299267905@qq.com>
DeepSeek-V3.1-AWQ.

Signed-off-by: menogrey <1299267905@qq.com>
Signed-off-by: menogrey <1299267905@qq.com>
Signed-off-by: menogrey <1299267905@qq.com>
Signed-off-by: menogrey <1299267905@qq.com>
Signed-off-by: menogrey <1299267905@qq.com>
Signed-off-by: menogrey <1299267905@qq.com>
Signed-off-by: menogrey <1299267905@qq.com>
Signed-off-by: menogrey <1299267905@qq.com>
Signed-off-by: menogrey <1299267905@qq.com>
Signed-off-by: menogrey <1299267905@qq.com>
@menogrey menogrey added ready read for review ready-for-test start test by label for PR labels Dec 12, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@wangxiyuan wangxiyuan mentioned this pull request Jan 4, 2026
22 tasks
@wangxiyuan wangxiyuan added the guide guide note label Jan 5, 2026
@ZhongsJie
Copy link
Copy Markdown

Any progress on this?

@menogrey
Copy link
Copy Markdown
Collaborator Author

Any progress on this?

@ZhongsJie I will resume work on this PR following the completion of the quantization module refactoring.

@ZhongsJie
Copy link
Copy Markdown

Any progress on this?

@ZhongsJie I will resume work on this PR following the completion of the quantization module refactoring.

@menogrey I’m reworking this part in #7672 — if you have time, could you take a look?

@menogrey
Copy link
Copy Markdown
Collaborator Author

Any progress on this?

@ZhongsJie I will resume work on this PR following the completion of the quantization module refactoring.

@menogrey I’m reworking this part in #7672 — if you have time, could you take a look?

That's great! In addition there are two reason that this work is pending

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants