Fix/nemotron mtp quantaized (#19433)

This commit is contained in:
Shaun Kotek
2026-03-03 11:07:46 +02:00
committed by GitHub
parent af0d35b224
commit 4c95953b77
5 changed files with 73 additions and 3 deletions

View File

@@ -665,7 +665,10 @@ class ModelConfig:
quant_cfg = quant_cfg.to_dict()
if quant_cfg is not None:
# Identify modelopt quantization
if "quant_method" not in quant_cfg:
if (
"quant_method" not in quant_cfg
or quant_cfg["quant_method"] == "modelopt"
):
parsed_cfg = self._parse_modelopt_quant_config(
{"quantization": quant_cfg}
)

View File

@@ -418,7 +418,9 @@ class FusedMoE(torch.nn.Module):
# w3, up_proj: Load into second logical weight of w13.
# trtllm cutlass kernel assumes differently
switch_w13 = getattr(self.quant_method, "load_up_proj_weight_first", False)
if (switch_w13 and shard_id == "w1") or (not switch_w13 and shard_id == "w3"):
if (
(switch_w13 and shard_id == "w1") or (not switch_w13 and shard_id == "w3")
) and self.moe_runner_config.is_gated:
start = shard_size
else:
start = 0

View File

@@ -58,6 +58,7 @@ if _is_npu:
try:
from flashinfer.fused_moe import cutlass_fused_moe as flashinfer_cutlass_fused_moe
from flashinfer.fused_moe.core import ActivationType
except ImportError:
flashinfer_cutlass_fused_moe = None
@@ -384,6 +385,11 @@ class UnquantizedFusedMoEMethod(FusedMoEMethodBase, MultiPlatformOp):
tp_size=layer.moe_tp_size,
tp_rank=layer.moe_tp_rank,
tune_max_num_tokens=next_power_of_2(x.shape[0]),
activation_type=(
ActivationType.Relu2
if moe_runner_config.activation == "relu2"
else ActivationType.Swiglu
),
)[0]
return StandardCombineInput(hidden_states=output)
elif self.use_flashinfer_trtllm_moe:

View File

@@ -297,7 +297,7 @@ class NemotronHForCausalLMMTP(NemotronHForCausalLM):
self.model = NemotronHMultiTokenPredictor(
config=config,
quant_config=quant_config,
prefix=add_prefix("model", prefix),
prefix=add_prefix("mtp", prefix),
)
self.lm_head = ParallelLMHead(