[Feature]: support serving nvfp4 W4A16 moe models uisng Marlin - #30906
[Feature]: support serving nvfp4 W4A16 moe models uisng Marlin#30906EdalatiAli wants to merge 6 commits into
Conversation
…ed MoE models with Marlin Signed-off-by: EdalatiAli <aliedalati@cohere.com>
Signed-off-by: EdalatiAli <aliedalati@cohere.com>
Signed-off-by: EdalatiAli <aliedalati@cohere.com>
|
Hi @EdalatiAli, the pre-commit checks have failed. Please run: uv pip install pre-commit
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, Tip Is
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for serving nvfp4 W4A16 quantized Mixture-of-Experts (MoE) models using the Marlin kernel by adding the CompressedTensorsW4A16Nvfp4MoeMethod. The changes look good overall, but I've identified a potential issue in how device capabilities are checked. The check is hardcoded to device 0, which could be problematic in multi-GPU environments. My review includes suggestions to make this more robust by using the layer's device for the capability check.
| "be used leveraging the Marlin kernel. This may degrade " | ||
| "performance for compute-heavy workloads." | ||
| ) | ||
| if current_platform.get_device_capability(0).major < 10: |
There was a problem hiding this comment.
The device capability check is hardcoded to device 0. This might be incorrect in a multi-GPU setup where the layer is on a different device. It's better to get the device from the layer object to ensure the check is performed for the correct GPU.
| if current_platform.get_device_capability(0).major < 10: | |
| if current_platform.get_device_capability(layer.weight.device.index).major < 10: |
| "be used leveraging the Marlin kernel. This may degrade " | ||
| "performance for compute-heavy workloads." | ||
| ) | ||
| if current_platform.get_device_capability(0).major < 10: |
There was a problem hiding this comment.
Similar to the issue in prepare_fp4_layer_for_marlin, the device capability check is hardcoded to device 0. This should be based on the layer's actual device to handle multi-GPU scenarios correctly.
| if current_platform.get_device_capability(0).major < 10: | |
| if current_platform.get_device_capability(layer.w13_weight.device.index).major < 10: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if self.use_marlin: | ||
| return fused_marlin_moe( | ||
| x, | ||
| layer.w13_weight, | ||
| layer.w2_weight, |
There was a problem hiding this comment.
Add post-load handling for nvfp4 W4A16 MoE weights
The new CompressedTensorsW4A16Nvfp4MoeMethod calls fused_marlin_moe with layer.w13_weight/layer.w2_weight here, but create_weights only registers w13_weight_packed/w2_weight_packed and this class never overrides process_weights_after_loading (the base implementation is a no-op, unlike the W4A4 MoE method). After loading a checkpoint those attributes are never created, so the first inference request using this quantization path will raise AttributeError before any computation runs. A post-load hook is needed to unpack or alias the packed weights before apply.
Useful? React with 👍 / 👎.
Signed-off-by: EdalatiAli <aliedalati@cohere.com>
|
Hi @EdalatiAli, the pre-commit checks have failed. Please run: uv pip install pre-commit
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, Tip Is
|
Signed-off-by: EdalatiAli <aliedalati@cohere.com>
|
FYI - #30881 This PR enables the NVFP4A16 pathway using the existing class which I think is preferable |
Purpose
This PR enables serving nvfp4 W4A16 compressed-tensors quantized MoE models by adding
CompressedTensorsW4A16Nvfp4MoeMethod.Weight-only nvfp4 quantization improves the quality at the expense of higher latency at large concurrencies.
As the provided results show, nvfp4 W4A16 quantized version of
Qwen/Qwen3-30B-A3Bsingificantly outperforms the nvfp4 W4A4 variant.Test Plan
Running e2e quality test on Qwen3-30B-A3B
Qwen/Qwen3-30B-A3BRedHatAI/Qwen3-30B-A3B-NVFP4AliEdalati97/Qwen3-30B-A3B-NVFP4-W4A16To run evalaution:
mmlu_prousinglm-eval[api]==0.4.9.1Test Result
Here are the results for
Qwen/Qwen3-30B-A3BRedHatAI/Qwen3-30B-A3B-NVFP4AliEdalati97/Qwen3-30B-A3B-NVFP4-W4A16Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.