-
-
Notifications
You must be signed in to change notification settings - Fork 20.5k
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
Changes from 9 commits
ef94e83
a928a4d
57634c0
9ce625d
bb25647
43d242d
76037a1
ad29cb4
f57cb15
8b3edda
05daf09
e6fd46d
67242e7
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 |
|---|---|---|
|
|
@@ -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( | ||
|
Comment on lines
355
to
369
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.
Removing the Useful? React with 👍 / 👎. |
||
| 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.
|
||
| 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, | ||
|
|
||
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.
This doesn't seem right as it breaks test_flashinfer_per_tensor_moe_fp8_no_graph on blackwell
https://buildkite.com/vllm/ci/builds/38920/steps/canvas?jid=019a7fad-270b-4d40-8820-e3a1e75dc35e#019a7fad-270b-4d40-8820-e3a1e75dc35e/102-2387
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.
Yeah it should be
if activation == "relu2_no_mul:, I originally wrote it as a one liner but the pre-commit hook complained, and I fixed it incorrectly. Changed it back and this should be correct.