Support fp4 fp8 non gated moe (#13794)

Co-authored-by: Roi Koren <roik@nvidia.com>
Co-authored-by: Tomer Natan <tbarnatan@computelab-frontend-8.nvidia.com>
This commit is contained in:
TomerBN-Nvidia
2025-12-01 15:26:28 -08:00
committed by GitHub
co-authored by Roi Koren Tomer Natan
parent eb5008846a
commit 02af51e4fc
3 changed files with 199 additions and 38 deletions
@@ -281,7 +281,10 @@ class FusedMoE(torch.nn.Module):
# We have to keep the weight scales of w1 and w3 because
# we need to re-quantize w1/w3 weights after weight loading.
idx = 0 if shard_id == "w1" else 1
param_data[expert_id][idx] = loaded_weight
if self.moe_runner_config.is_gated:
param_data[expert_id][idx] = loaded_weight
else:
param_data[expert_id] = loaded_weight
# If we are in the row parallel case (down_proj)
elif shard_id == "w2":
param_data[expert_id] = loaded_weight
@@ -345,7 +348,6 @@ class FusedMoE(torch.nn.Module):
tp_rank: int,
is_bias: bool = False,
):
# Index the loaded weight for tp sharding.
# gate_up_proj: "MergedColumnParallel", so tp sharding on output_dim
assert shard_id in {"w1", "w3", "w13"}
@@ -481,7 +483,6 @@ class FusedMoE(torch.nn.Module):
loaded_weight: torch.Tensor,
tp_rank: int,
):
if shard_id == "w2":
self._load_w2(
shard_id=shard_id,
@@ -518,7 +519,6 @@ class FusedMoE(torch.nn.Module):
shard_id: str,
expert_id: Optional[int],
) -> None:
# if expert_id is None, then
# all the experts are loaded at the same time
if (
@@ -612,7 +612,6 @@ class FusedMoE(torch.nn.Module):
shard_id: str,
expert_id: int,
) -> None:
tp_rank = self.moe_tp_rank
# compressed-tensors checkpoints with packed weights are stored flipped
@@ -925,7 +924,6 @@ class FusedMoE(torch.nn.Module):
ckpt_up_proj_name: str,
num_experts: int,
) -> List[Tuple[str, str, int, str]]:
return [
# (param_name, weight_name, expert_id, shard_id)
(