Quantization for MoE Models
local graph
Chapter 9 — Quantization for MoE Models
Section titled “Chapter 9 — Quantization for MoE Models”Post-Training Quantization for MoE
Section titled “Post-Training Quantization for MoE”Post-training quantization (PTQ) applied to MoE models follows the same principles as for dense models but with additional considerations arising from the heterogeneous structure of MoE layers. In PTQ, the model weights are compressed from their training precision (typically bfloat16 or float16) to a lower precision representation (typically 4-bit integer or 8-bit integer) after training is complete, without any additional gradient-based optimization. For MoE models, the per-expert weight distribution must be analyzed independently for each expert rather than aggregating statistics across the entire model, because different experts may have very different weight magnitude distributions that require different quantization scales.
GPTQ (Generative Pre-Training Quantization) is the most widely used PTQ algorithm for LLMs and has been applied successfully to Mixtral and other MoE models. GPTQ uses the Hessian of the quantization error with respect to the input activations to determine the optimal quantization parameters for each weight matrix, computing the second-order information from a small calibration dataset. For MoE models, GPTQ must be applied separately to each expert weight matrix, requiring access to representative activations for each expert - which means the calibration dataset must include examples that activate each expert with sufficient frequency to provide reliable Hessian estimates. Expert-specific calibration sampling, where the calibration is stratified across experts rather than sampled uniformly, improves quantization quality for low-frequency experts.
AWQ (Activation-aware Weight Quantization) uses a different approach to PTQ that protects the small fraction of weights that have high impact on model quality by identifying and preserving the weights corresponding to large activation magnitudes. For MoE models, AWQ’s activation-importance analysis must be performed per-expert, as the activation magnitudes in different experts may be very different due to their different specializations. Experiments on Mixtral 8x7B with AWQ quantization show that the per-expert activation analysis is essential for maintaining quality - applying uniform quantization scales across all experts produces significantly lower quality than expert-specific scales derived from the routing-conditioned activation statistics.
Router weight quantization deserves special attention because errors in the gating scores can cause tokens to route to wrong experts, producing quality degradation that is qualitatively different from and potentially worse than the smooth quality degradation caused by expert weight quantization errors. The gating weight matrix W_g is typically small relative to the expert weights - for a model with d_model=4096 and E=8 experts, W_g has 4096 * 8 = 32,768 parameters, compared to hundreds of millions in the expert weights - and keeping it in higher precision (bfloat16 or even float32) while quantizing expert weights to 4-bit has negligible memory cost and preserves routing quality. This asymmetric quantization approach is recommended as a standard practice for MoE PTQ.
Quantization sensitivity analysis for MoE models reveals significant variation in the quantization tolerance of different experts. Experts that process common token types (high-frequency experts) tend to be more robust to quantization because their weights are well-calibrated from processing many training examples. Experts that process rare token types (low-frequency experts) tend to be more sensitive to quantization because their weights may have high variance that is poorly captured by symmetric or asymmetric quantization formats. Applying mixed-precision quantization - using higher bit-width for sensitive experts and lower bit-width for robust ones - can improve the quality-memory trade-off significantly compared to uniform quantization across all experts.

Mixtral 8x7B Quantization Comparison: MMLU accuracy (%) and memory footprint (GB) against quantization bit-width for Uniform, Expert-Aware and Mixed-Precision quantization, with the Pareto-optimal configuration marked.
QAT and Mixed-Precision Training for MoE
Section titled “QAT and Mixed-Precision Training for MoE”Quantization-aware training (QAT) incorporates the quantization operation into the training forward pass using straight-through estimators for the quantization gradient, allowing the model to adapt its weights to be more robust to quantization error during training rather than post-hoc. For MoE models, QAT presents additional challenges because the routing decisions interact with quantization: the routing network must work correctly with the quantized expert representations, and quantization noise in the expert outputs can affect the gating scores in subsequent layers if routing uses expert-processed representations as input. Careful initialization of QAT from a well-trained full-precision MoE model and gradual reduction of the straight-through estimator noise during training can address these challenges.
Mixed-precision training for MoE models uses different numerical precision for different components based on their sensitivity to precision loss. The standard approach used in large-scale MoE training uses bf16 for forward pass computations (including expert computations) and fp32 for the gating score computation, the auxiliary loss computation, and the optimizer state. This mixed-precision strategy balances the memory efficiency of bf16 with the numerical stability required for the routing computation. Some implementations also use fp32 for the first and last layers of the model, which are often more precision-sensitive than the middle layers, and for the attention softmax computation.
FP8 training for MoE models is an emerging area following the introduction of FP8 support in NVIDIA H100 GPUs and the corresponding software support in Transformer Engine. FP8 (using the E4M3 and E5M2 formats) provides approximately 2x the memory efficiency of bfloat16 with minimal quality degradation when appropriate scaling factors are applied. For MoE models, FP8 training must handle the challenge that different experts may have very different activation magnitude ranges, requiring per-expert scaling factors that add complexity relative to the layer-level or tensor-level scaling used in dense model FP8 training. DeepSeek’s training infrastructure for V3 used FP8 training with careful per-expert scaling calibration, achieving significant training cost reduction relative to bfloat16 baselines.
Gradient quantization and communication compression are complementary techniques that reduce the communication overhead of gradient all-reduce operations in expert-parallel training. Quantizing gradients from fp32 to fp16 or bf16 before the all-reduce, and decompressing after aggregation, reduces the communication volume by 2x with typically minimal impact on convergence quality. More aggressive gradient compression using techniques such as PowerSGD or 1-bit Adam can reduce communication volume by 10-100x, but requires careful validation that the convergence behavior is not significantly affected by the compression noise, which can interact with the MoE routing dynamics in subtle ways.
Deployment quantization strategy for MoE inference must balance model quality, memory footprint, and compute efficiency simultaneously. The recommended configuration for most MoE deployment scenarios is: expert weights in 4-bit with per-group asymmetric quantization (128 parameters per group), attention weight matrices in 4-bit or 8-bit depending on quality sensitivity, gating weights in bfloat16, and layer norms in float32. This configuration achieves approximately 4x memory reduction relative to full bfloat16 with quality degradation of typically less than 1 percent on standard benchmarks. The specific quantization configuration should be validated on a representative evaluation set before deployment, as quality impact varies across models and tasks.

Memory Breakdown: 47B MoE Model Quantization — stacked memory bars (expert weights, attention weights, gating weights, other parameters) with a quality score bar, for BF16, INT8, INT4 and two mixed-precision configurations.
Hardware Acceleration for Quantized MoE
Section titled “Hardware Acceleration for Quantized MoE”Hardware acceleration for quantized MoE models requires optimized kernels that can perform the routing, dispatch, expert compute, and gather operations efficiently using the quantized weight formats. For 4-bit integer expert weights, the key operation is a W4A16 matrix multiplication (4-bit weights, 16-bit activations), which has been heavily optimized in libraries such as GPTQ-CUDA, ExLlamaV2, and CUTLASS’s mixed-input GEMM implementations. These kernels typically achieve 60-80 percent of the peak compute throughput of the underlying hardware for representative matrix sizes, with the remainder lost to quantization dequantization overhead and memory access latency.
Triton custom kernels for MoE operations enable hardware-specific optimization of the routing-and-dispatch pipeline that is not possible with standard deep learning framework operators. Megablocks, a Triton-based MoE implementation, represents the expert computation as a large sparse matrix operation where the expert weight matrices are tiled and the token-expert assignments define a sparse structure. This formulation allows the entire expert layer to be executed as a single large matrix multiplication with a structured sparsity pattern, enabling better hardware utilization than the standard approach of launching separate GEMM kernels for each expert. Megablocks-style implementations show 2-4x throughput improvements over naive per-expert GEMM approaches on representative MoE layer benchmarks.
Neuromorphic and dataflow architectures offer longer-term opportunities for efficient MoE inference by physically mapping different experts to different processing elements and routing activations accordingly. In conventional GPU computing, expert routing requires explicit communication between shared memory and compute units, introducing overhead that is a fundamental property of the shared-memory architecture. In dataflow architectures such as Cerebras or Groq, each expert can be compiled to a dedicated region of the chip, and routing between experts is implemented as on-chip data routing with near-zero overhead. This architectural match between the MoE computational pattern and the dataflow hardware structure is one reason that such architectures show particular promise for efficient MoE inference at scale.
Profiling and benchmarking MoE quantized inference is essential for validating that quantization configurations meet latency and throughput requirements in the target serving environment. Standard LLM benchmarking tools such as LM-Evaluation-Harness and MT-Bench provide quality metrics, while serving benchmarks such as vLLM’s benchmark_serving.py measure throughput and latency under realistic load conditions. For MoE models, benchmarking must cover a range of batch sizes, sequence lengths, and domain distributions to capture the variability in expert utilization that affects performance. Reporting benchmark results only for single-domain workloads can significantly overestimate the performance achievable on diverse production traffic.

MLBench: kernel throughput (TFLOP/s), quantized vs. full-precision compute, and memory bandwidth utilization (%) for Triton MoE vs. PyTorch MoE across batch size / expert count.