From 4346db5fafee11513799ebb57ec3e6ad5d95f6e9 Mon Sep 17 00:00:00 2001 From: b8zhong Date: Wed, 14 Jan 2026 16:57:14 -0800 Subject: [PATCH] [Fix] Remove assertion for padding for NVFP4 weight scales to fix GLM 4.5 NVFP4 (#12497) --- .../sglang/srt/layers/quantization/modelopt_quant.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/sglang/srt/layers/quantization/modelopt_quant.py b/python/sglang/srt/layers/quantization/modelopt_quant.py index b1092aec6..c14c19817 100755 --- a/python/sglang/srt/layers/quantization/modelopt_quant.py +++ b/python/sglang/srt/layers/quantization/modelopt_quant.py @@ -1510,10 +1510,13 @@ class ModelOptNvFp4FusedMoEMethod(FusedMoEMethodBase): weight_scale.shape[-1] == expected_blocks[name] ), f"Expected {name}_weight_scale.dim(2) == {expected_blocks[name]}, got {weight_scale.shape[-1]}" else: - # For other backends, ensure the per-input block dimension is aligned to 16. - assert ( - weight_scale.shape[assert_dim] % block_size == 0 - ), f"Expected {name}_weight_scale.dim({assert_dim}) to be divisible by {block_size}" + if weight_scale.shape[assert_dim] % 4 != 0: + logger.warning( + "NVFP4 %s_weight_scale K' not multiple of 4: shape=%s, group_size=%s", + name, + tuple(weight_scale.shape), + getattr(self.quant_config, "group_size", None), + ) assert ( weight_scale.dtype == torch.float8_e4m3fn ), f"{name} Weight Blockscale must be represented as FP8-E4M3"