-
-
Notifications
You must be signed in to change notification settings - Fork 22.8k
[AMD][OCP MX][CI] Fix tests to not dispatch on UNFUSED_TRITON backend on MI300, improve w_mxfp4_a_fp8 emulation support
#46142
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 all commits
0b53047
f8d1298
28bc8ba
fedb533
adbf365
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 | ||
|---|---|---|---|---|
|
|
@@ -674,6 +674,8 @@ def convert_gpt_oss_weight_to_mxfp4_moe_kernel_format( | |||
| w2_weight_scale: torch.Tensor, | ||||
| w13_bias: torch.Tensor | None = None, | ||||
| w2_bias: torch.Tensor | None = None, | ||||
| w13_input_scale: torch.Tensor | None = None, | ||||
| w2_input_scale: torch.Tensor | None = None, | ||||
| _cache_permute_indices: dict[torch.Size, torch.Tensor] | None = None, | ||||
| ) -> tuple[ | ||||
| torch.Tensor, | ||||
|
|
@@ -1191,8 +1193,29 @@ def swap_every_two_rows(x, axis=-1): | |||
| w2_bias, | ||||
| ) | ||||
| elif mxfp4_backend == Mxfp4MoeBackend.EMULATION: | ||||
| # No additional transformation needed for emulation backend, | ||||
| # weights are dequantized on the fly in the experts class. | ||||
| w13_has_per_expert_scale = ( | ||||
| w13_input_scale is not None | ||||
| and w13_input_scale.ndim == 1 | ||||
| and not all_close_1d(w13_input_scale) | ||||
| ) | ||||
| w2_has_per_expert_scale = ( | ||||
| w2_input_scale is not None | ||||
| and w2_input_scale.ndim == 1 | ||||
| and not all_close_1d(w2_input_scale) | ||||
| ) | ||||
| if w13_has_per_expert_scale or w2_has_per_expert_scale: | ||||
| logger.warning_once( | ||||
| "Found input_scales that are not equal for OCP MX MoE " | ||||
| "emulation. Using the maximum across experts for each layer." | ||||
| ) | ||||
| if w13_input_scale is not None: | ||||
| layer.w13_input_scale = torch.nn.Parameter( | ||||
| w13_input_scale.max().to(torch.float32), requires_grad=False | ||||
| ) | ||||
| if w2_input_scale is not None: | ||||
| layer.w2_input_scale = torch.nn.Parameter( | ||||
| w2_input_scale.max().to(torch.float32), requires_grad=False | ||||
| ) | ||||
|
Comment on lines
+1211
to
+1218
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 this not handled in quark quant method class already?
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. This method See:
|
||||
| return ( | ||||
| w13_weight, | ||||
| w2_weight, | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1211,6 +1211,8 @@ def _setup_kernel(self, layer: RoutedExperts): | |
| w2_weight_scale=layer.w2_weight_scale, | ||
| w13_bias=w13_bias, | ||
| w2_bias=w2_bias, | ||
| w13_input_scale=layer.w13_input_scale, | ||
| w2_input_scale=layer.w2_input_scale, | ||
|
Comment on lines
+1214
to
+1215
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. we had eval test coverage for w4a8 actually btw we should add emulation backend to these eval tests too, can be separate PRs |
||
| ) | ||
| ) | ||
|
|
||
|
|
||
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.
Could we put this logic into the oracle for a single source of truth?
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.
Well, this used to be the case (automatic selection in the oracle on Instinct), but @BowenBao made this backend an opt-in https://github.com/vllm-project/vllm/pull/41436/changes#r3237495909 - with the motivation being that these backend are not super well optimized (e.g. unfused weight dequant / compute), so it really be a last resort. cc @BowenBao would it make sense to add this default back, as the last priority?
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.
Based on the number of recent changes towards this direction, I'm not strongly against it. If we are to change it let's put out an explicit warning.