-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Feature: Support Relu2 in FusedMoE fp8 cutlass path #27261
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
Draft
amirkl94
wants to merge
2
commits into
vllm-project:main
Choose a base branch
from
amirkl94:feat/relu2-cutlass
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+51
−23
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -354,11 +354,7 @@ def __init__( | |
|
|
||
| self.cutlass_fp8_supported = cutlass_fp8_supported() | ||
| self.flashinfer_moe_backend: FlashinferMoeBackend | None = None | ||
| if ( | ||
| envs.VLLM_USE_FLASHINFER_MOE_FP8 | ||
| and has_flashinfer_moe() | ||
| and self.moe.is_act_and_mul | ||
| ): | ||
| if envs.VLLM_USE_FLASHINFER_MOE_FP8 and has_flashinfer_moe(): | ||
| self.flashinfer_moe_backend = get_flashinfer_moe_backend() | ||
| logger.info_once( | ||
| f"Using FlashInfer {self.flashinfer_moe_backend.value} kernels" | ||
|
|
@@ -557,7 +553,8 @@ def process_weights_after_loading(self, layer: torch.nn.Module) -> None: | |
| ) | ||
|
|
||
| if self.flashinfer_moe_backend is not None: | ||
| layer.w13_weight.data = swap_w13_to_w31(layer.w13_weight.data) | ||
| if self.moe.is_act_and_mul: | ||
| layer.w13_weight.data = swap_w13_to_w31(layer.w13_weight.data) | ||
| register_moe_scaling_factors(layer) | ||
| if self.flashinfer_moe_backend == FlashinferMoeBackend.TENSORRT_LLM: | ||
| rotate_flashinfer_fp8_moe_weights(layer.w13_weight, layer.w2_weight) | ||
|
|
@@ -570,9 +567,21 @@ def get_fused_moe_quant_config( | |
|
|
||
| return fp8_w8a8_moe_quant_config( | ||
| w1_scale=layer.w13_weight_scale, | ||
| g1_alphas=layer.output1_scales_gate_scalar.squeeze() | ||
| if self.flashinfer_moe_backend == FlashinferMoeBackend.CUTLASS | ||
| else None, | ||
| w2_scale=layer.w2_weight_scale, | ||
| g2_alphas=layer.output2_scales_scalar.squeeze() | ||
| if self.flashinfer_moe_backend == FlashinferMoeBackend.CUTLASS | ||
| else None, | ||
| a1_scale=layer.w13_input_scale, | ||
| a1_gscale=layer.w13_input_scale | ||
| if self.flashinfer_moe_backend == FlashinferMoeBackend.CUTLASS | ||
| else None, | ||
| a2_scale=layer.w2_input_scale, | ||
| a2_gscale=layer.w2_input_scale_inv | ||
| if self.flashinfer_moe_backend == FlashinferMoeBackend.CUTLASS | ||
| else None, | ||
| per_act_token_quant=False, | ||
| ) | ||
|
|
||
|
|
@@ -656,10 +665,6 @@ def apply( | |
| apply_router_weight_on_input=apply_router_weight_on_input, | ||
| ) | ||
| elif self.flashinfer_moe_backend == FlashinferMoeBackend.CUTLASS: | ||
| assert not renormalize | ||
|
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.
|
||
| assert activation == "silu", ( | ||
| f"Expected 'silu' activation but got {activation}" | ||
| ) | ||
| return flashinfer_cutlass_moe_fp8( | ||
| x, | ||
| layer, | ||
|
|
@@ -1159,8 +1164,8 @@ def __init__( | |
| moe: FusedMoEConfig, | ||
| layer: torch.nn.Module, | ||
| ) -> None: | ||
| from vllm.model_executor.layers.quantization.utils.nvfp4_moe_support import ( # noqa: E501 | ||
| detect_nvfp4_moe_support, | ||
| from vllm.model_executor.layers.quantization.utils.nvfp4_moe_support import ( | ||
| detect_nvfp4_moe_support, # noqa: E501 | ||
| ) | ||
|
|
||
| super().__init__(moe) | ||
|
|
@@ -1773,8 +1778,8 @@ def apply( | |
| self.allow_flashinfer | ||
| and self.flashinfer_moe_backend == FlashinferMoeBackend.CUTLASS | ||
| ): | ||
| from vllm.model_executor.layers.fused_moe.flashinfer_cutlass_moe import ( # noqa: E501 | ||
| flashinfer_cutlass_moe_fp4, | ||
| from vllm.model_executor.layers.fused_moe.flashinfer_cutlass_moe import ( | ||
| flashinfer_cutlass_moe_fp4, # noqa: E501 | ||
| ) | ||
|
|
||
| assert self.moe_quant_config is not None | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe worth asserting that activation is one of the keys in
activation_str_to_value_map?