-
-
Notifications
You must be signed in to change notification settings - Fork 14.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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ef94e83
Enable cutlass fp8 kernels
amirkl94 a928a4d
Add accuracy test
amirkl94 57634c0
Pre-commit fix
amirkl94 9ce625d
Fallback to cutlass when trying non-gated and min-latency mode
amirkl94 bb25647
Merge branch 'main' into feat/relu2-cutlass
amirkl94 43d242d
CR Fixes
amirkl94 76037a1
Small fix
amirkl94 ad29cb4
Update vllm/model_executor/layers/quantization/modelopt.py
mgoin f57cb15
Merge branch 'main' into feat/relu2-cutlass
mgoin 8b3edda
Correct condition
amirkl94 05daf09
Simplify
amirkl94 e6fd46d
Merge branch 'main' into feat/relu2-cutlass
amirkl94 67242e7
Merge branch 'main' into feat/relu2-cutlass
amirkl94 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -354,12 +354,18 @@ 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() | ||
| if ( | ||
| self.flashinfer_moe_backend == FlashinferMoeBackend.TENSORRT_LLM | ||
| and not self.moe.is_act_and_mul | ||
| ): | ||
| logger.info_once( | ||
| "Non-gated MoE is not supported for min-latency mode," | ||
| "falling back to high-throughput mode" | ||
| ) | ||
|
Comment on lines
+359
to
+366
Member
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. It seems you are missing the override of
Comment on lines
+359
to
+366
Member
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. It looks like the |
||
| self.flashinfer_moe_backend = FlashinferMoeBackend.CUTLASS | ||
|
|
||
| logger.info_once( | ||
| f"Using FlashInfer {self.flashinfer_moe_backend.value} kernels" | ||
| ) | ||
|
|
@@ -557,10 +563,11 @@ 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) | ||
| register_moe_scaling_factors(layer) | ||
| if self.moe.is_act_and_mul: | ||
| layer.w13_weight.data = swap_w13_to_w31(layer.w13_weight.data) | ||
| if self.flashinfer_moe_backend == FlashinferMoeBackend.TENSORRT_LLM: | ||
| rotate_flashinfer_fp8_moe_weights(layer.w13_weight, layer.w2_weight) | ||
| register_moe_scaling_factors(layer) | ||
|
|
||
| def get_fused_moe_quant_config( | ||
| self, layer: torch.nn.Module | ||
|
|
@@ -570,13 +577,13 @@ def get_fused_moe_quant_config( | |
|
|
||
| return fp8_w8a8_moe_quant_config( | ||
| w1_scale=layer.w13_weight_scale, | ||
| g1_alphas=(layer.w13_weight_scale * layer.w13_input_scale).squeeze(), | ||
| g1_alphas=layer.output1_scales_gate_scalar.squeeze(), | ||
| w2_scale=layer.w2_weight_scale, | ||
| g2_alphas=(layer.w2_weight_scale * layer.w2_input_scale).squeeze(), | ||
| g2_alphas=layer.output2_scales_scalar.squeeze(), | ||
| a1_scale=layer.w13_input_scale, | ||
| a1_gscale=layer.w13_input_scale, | ||
| a2_scale=layer.w2_input_scale, | ||
| a2_gscale=1.0 / layer.w2_input_scale, | ||
| a2_gscale=layer.w2_input_scale_inv, | ||
| per_act_token_quant=False, | ||
| ) | ||
|
|
||
|
|
@@ -642,9 +649,9 @@ def apply( | |
| ) | ||
|
|
||
| if self.flashinfer_moe_backend == FlashinferMoeBackend.CUTLASS: | ||
| assert not renormalize | ||
amirkl94 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert activation == "silu", ( | ||
| f"Expected 'silu' activation but got {activation}" | ||
| assert activation in ("silu", "relu2_no_mul"), ( | ||
| "Expected activation to be in ('silu', 'relu2_no_mul')," | ||
| f"but got {activation}" | ||
| ) | ||
| return flashinfer_cutlass_moe_fp8( | ||
| x, | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.