Repository navigation
[ROCm][MoE] Split AiterExperts by weight-quantization key #60322
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
Changes from 4 commits
4c92efb
5486aa2
70fc5c5
04f4d2c
85897ff
f4a451d
c97dbdf
1b6ae65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -482,29 +482,6 @@ def _supports_current_device() -> bool: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _supports_no_act_and_mul() -> bool: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return False | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @staticmethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _supports_quant_scheme( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| weight_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activation_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> bool: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SUPPORTED_W_A = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (None, None), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (kFp8Static128BlockSym, kFp8Dynamic128Sym), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (kFp8StaticTensorSym, kFp8StaticTensorSym), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (kFp8StaticTensorSym, kFp8DynamicTensorSym), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (kFp8StaticChannelSym, kFp8DynamicTokenSym), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (kMxfp4Static, None), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (kMxfp4Static, kMxfp4Dynamic), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (weight_key, activation_key) not in SUPPORTED_W_A: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return False | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if weight_key == kMxfp4Static: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from vllm.platforms.rocm import on_gfx950, on_gfx1250 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not on_gfx950() or on_gfx1250(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return False | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @staticmethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _supports_activation(activation: MoEActivation) -> bool: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return activation in [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -597,3 +574,77 @@ def apply( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output.set_(result) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output.copy_(result) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class AiterUnquantizedExperts(AiterExperts): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any other logic that is weight quant key-specific from the parent class that could be ported in the children? Let me know if it makes sense or not / this could also be left as is or done later. things like:
vllm/vllm/model_executor/layers/fused_moe/experts/rocm_aiter_moe.py Lines 322 to 339 in d9503dc
vllm/vllm/model_executor/layers/fused_moe/experts/rocm_aiter_moe.py Lines 391 to 406 in d9503dc
this is simply with the goal of making
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also if there is, any restriction on weight quant key / activation quant key / activation / gate_mode combination.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding, porting it down to the children: Yeah, that can be moved down, mainly the quant_method derivation. It is basically the same split we just did for _supports_quant_scheme(). We can keep the scope narrow in this PR since apply() didn't strictly need to change for the split to be correct, but I'm happy to push this as a follow-up. The gate_mode logic is a bit more tangled since it checks activation == SITU before weight quant key, so it doesn't split as cleanly per class. I'd lean toward leaving that one in the shared function.
divakar-amd marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Unquantized (bf16/fp16) weights and activations.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @staticmethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _supports_quant_scheme( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| weight_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activation_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> bool: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SUPPORTED_W_A = [(None, None)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return (weight_key, activation_key) in SUPPORTED_W_A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class AiterFp8BlockExperts(AiterExperts): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """128x128 block-quantized weight scale, 128-grouped dynamic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activation scale.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @staticmethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _supports_quant_scheme( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| weight_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activation_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> bool: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SUPPORTED_W_A = [(kFp8Static128BlockSym, kFp8Dynamic128Sym)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return (weight_key, activation_key) in SUPPORTED_W_A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class AiterFp8TensorExperts(AiterExperts): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Per-tensor static weight scale, either per-tensor static or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| per-tensor dynamic activation scale.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @staticmethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _supports_quant_scheme( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| weight_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activation_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> bool: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SUPPORTED_W_A = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (kFp8StaticTensorSym, kFp8StaticTensorSym), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (kFp8StaticTensorSym, kFp8DynamicTensorSym), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return (weight_key, activation_key) in SUPPORTED_W_A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class AiterFp8ChannelExperts(AiterExperts): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Per-output-channel static weight scale, per-token dynamic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activation scale.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @staticmethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _supports_quant_scheme( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| weight_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activation_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> bool: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SUPPORTED_W_A = [(kFp8StaticChannelSym, kFp8DynamicTokenSym)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return (weight_key, activation_key) in SUPPORTED_W_A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class AiterMxfp4Experts(AiterExperts): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """MXFP4-quantized weights, with either unquantized (bf16/fp16) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MXFP4-quantized dynamic activations. gfx950-only (not gfx1250).""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @staticmethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _supports_quant_scheme( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| weight_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activation_key: QuantKey | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> bool: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SUPPORTED_W_A = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (kMxfp4Static, None), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (kMxfp4Static, kMxfp4Dynamic), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (weight_key, activation_key) not in SUPPORTED_W_A: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return False | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from vllm.platforms.rocm import on_gfx950, on_gfx1250 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return on_gfx950() and not on_gfx1250() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.