Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/chop/nn/quantized/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,22 @@

from .qwen3_moe import (
Qwen3MoeAttentionMXFP,
Qwen3MoeAttentionMXFPRotate,
Qwen3MoeAttentionMXInt,
Qwen3MoeAttentionMXIntRotate,
Qwen3MoeMLPMXFP,
Qwen3MoeMLPMXInt,
Qwen3MoeExpertsMXFP,
Qwen3MoeExpertsMXInt,
Qwen3MoeSparseMoeBlockBF16Router,
Qwen3MoeSparseMoeBlockMinifloat,
Qwen3MoeTopKRouterBF16,
Qwen3MoeTopKRouterMX,
Qwen3MoeTopKRouterMXInt8,
Qwen3MoeTopKRouterE4M3,
Qwen3MoeTopKRouterE5M2,
Qwen3MoeRMSNormMinifloat,
Qwen3MoeDecoderLayerMinifloat,
)

from .glm4_moe import (
Expand Down Expand Up @@ -399,11 +411,23 @@
}

quantized_qwen3_moe_module_map = {
"qwen3_moe_decoder_layer_minifloat": Qwen3MoeDecoderLayerMinifloat,
"qwen3_moe_self_attention_mxfp": Qwen3MoeAttentionMXFP,
"qwen3_moe_self_attention_mxfp_rotate": Qwen3MoeAttentionMXFPRotate,
"qwen3_moe_self_attention_mxint": Qwen3MoeAttentionMXInt,
"qwen3_moe_self_attention_mxint_rotate": Qwen3MoeAttentionMXIntRotate,
"qwen3_moe_mlp_mxfp": Qwen3MoeMLPMXFP,
"qwen3_moe_mlp_mxint": Qwen3MoeMLPMXInt,
"qwen3_moe_experts_mxfp": Qwen3MoeExpertsMXFP,
"qwen3_moe_experts_mxint": Qwen3MoeExpertsMXInt,
"qwen3_moe_sparse_block_bf16_router": Qwen3MoeSparseMoeBlockBF16Router,
"qwen3_moe_sparse_block_minifloat": Qwen3MoeSparseMoeBlockMinifloat,
"qwen3_moe_router_bf16": Qwen3MoeTopKRouterBF16,
"qwen3_moe_router_mx": Qwen3MoeTopKRouterMX,
"qwen3_moe_router_mxint8": Qwen3MoeTopKRouterMXInt8,
"qwen3_moe_router_e4m3": Qwen3MoeTopKRouterE4M3,
"qwen3_moe_router_e5m2": Qwen3MoeTopKRouterE5M2,
"qwen3_moe_rms_norm_minifloat": Qwen3MoeRMSNormMinifloat,
}

quantized_glm4_moe_module_map = {
Expand Down
8 changes: 8 additions & 0 deletions src/chop/nn/quantized/modules/phase_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
DECODE_FP_WEIGHT_ATTR = "_mase_decode_weight_fp"
DECODE_FP_BIAS_ATTR = "_mase_decode_bias_fp"

# Qwen3-MoE stores all routed experts in two fused Parameters rather than
# child Linear modules. These attributes mirror the linear handoff contract
# for the fused gate/up and down tensors.
GPTQ_DECODE_EXPERT_GATE_UP_ATTR = "_mase_gptq_gate_up_proj_decode"
GPTQ_DECODE_EXPERT_DOWN_ATTR = "_mase_gptq_down_proj_decode"
DECODE_FP_EXPERT_GATE_UP_ATTR = "_mase_decode_gate_up_proj_fp"
DECODE_FP_EXPERT_DOWN_ATTR = "_mase_decode_down_proj_fp"

_VALID_DECODE_POLICIES = ("fp_only", "quantized")
_VALID_KV_HANDOFFS = ("decode_format", "fp")

Expand Down
20 changes: 20 additions & 0 deletions src/chop/nn/quantized/modules/qwen3_moe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
from .compat import SUPPORTED_TRANSFORMERS_VERSION, require_qwen3_moe_fused_abi
from .attention import (
Qwen3MoeAttentionMXFP,
Qwen3MoeAttentionMXFPRotate,
Qwen3MoeAttentionMXInt,
Qwen3MoeAttentionMXIntRotate,
)
from .mlp import Qwen3MoeMLPMXFP, Qwen3MoeMLPMXInt
from .experts import Qwen3MoeExpertsMXFP, Qwen3MoeExpertsMXInt
from .router import (
Qwen3MoeSparseMoeBlockBF16Router,
Qwen3MoeSparseMoeBlockMinifloat,
Qwen3MoeTopKRouterBF16,
)
from .router_precision import (
Qwen3MoeTopKRouterE4M3,
Qwen3MoeTopKRouterE5M2,
Qwen3MoeTopKRouterMX,
Qwen3MoeTopKRouterMXInt8,
ROUTER_MX_FORMATS,
ROUTER_PRECISION_SCHEMA,
router_decode_config,
router_phase_config,
)
from .rms_norm import Qwen3MoeRMSNormMinifloat
from .decoder_layer import Qwen3MoeDecoderLayerMinifloat
Loading