Fix block FP8 MTP in ModelOpt mixed checkpoints (#55513)
Signed-off-by: Shiyang Chen <shiychen@nvidia.com> Signed-off-by: Isotr0py <Isotr0py@outlook.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
co-authored by
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Isotr0py
parent
28a2ccee78
commit
60ad959b6f
@@ -25,6 +25,7 @@ from vllm.model_executor.kernels.linear import (
|
||||
MarlinNvFp4LinearKernel,
|
||||
)
|
||||
from vllm.model_executor.layers.attention import Attention
|
||||
from vllm.model_executor.layers.fused_moe import RoutedExperts
|
||||
from vllm.model_executor.layers.linear import UnquantizedLinearMethod
|
||||
from vllm.model_executor.layers.quantization.modelopt import (
|
||||
LINEAR_ALGOS,
|
||||
@@ -224,6 +225,37 @@ def test_modelopt_mixed_precision_dispatches_every_linear_algo(algo):
|
||||
assert isinstance(method, ModelOptLinearMethod), (algo, type(method).__name__)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("algo", ["FP8_PB_WO", "FP8_BLOCK_SCALES"])
|
||||
def test_modelopt_mixed_precision_dispatches_block_fp8_moe(algo):
|
||||
config = ModelOptMixedPrecisionConfig.from_config(
|
||||
{
|
||||
"quantization": {
|
||||
"quant_algo": "MIXED_PRECISION",
|
||||
"quantized_layers": {
|
||||
"mtp.layers.48.mlp.experts": {
|
||||
"quant_algo": algo,
|
||||
"group_size": 128,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
)
|
||||
layer = MagicMock(spec=RoutedExperts)
|
||||
expected = object()
|
||||
|
||||
with patch(
|
||||
"vllm.model_executor.layers.quantization.modelopt.Fp8MoEMethod",
|
||||
return_value=expected,
|
||||
) as method_cls:
|
||||
method = config.get_quant_method(layer, "mtp.layers.48.mlp.experts")
|
||||
|
||||
assert method is expected
|
||||
fp8_config, called_layer = method_cls.call_args.args
|
||||
assert called_layer is layer
|
||||
assert fp8_config.weight_block_size == [128, 128]
|
||||
assert fp8_config.activation_scheme == "dynamic"
|
||||
|
||||
|
||||
def test_modelopt_nvfp4_leaves_excluded_parallel_lm_head_unquantized():
|
||||
config = ModelOptNvFp4Config(
|
||||
is_checkpoint_nvfp4_serialized=True,
|
||||
|
||||
Reference in New Issue
Block a user