GroupedLinear. Attention, embeddings, routers, shared
experts, dense MLPs, and the LM head remain in their configured precision.
Component roles
The
W4 in W4A16 describes the stored SGLang expert weights. On the trainer,
INT4 is simulated in the forward pass; the underlying Megatron parameters stay
in the configured training dtype. A16 means the expert GEMM uses BF16 or FP16
activations rather than quantized activations.
Weight lifecycle
- SGLang loads the compressed Hugging Face checkpoint from
--hf-checkpoint. - Megatron initializes the actor in its training dtype. Kimi-K2.5 can load the packed checkpoint directly through Megatron Bridge; the maintained Qwen3 raw-mode recipe initializes from a higher-precision Megatron checkpoint.
- During training, Megatron fake-quantizes every routed-expert
GroupedLinearweight immediately before the forward GEMM. Backward uses a straight-through estimator (STE), so the optimizer updates the original trainable weight. - At a weight-update boundary, Megatron Bridge or the miles raw-mode exporter exports Hugging Face-named tensors. The Kimi-K2.5 Bridge returns routed experts already packed as INT4; the generic miles path packs them from the checkpoint quantization config.
- SGLang opens a weight-update session and loads the new packed tensors. On the CUDA/Marlin WNA16 path used by the registered H200 tests, the session restores the checkpoint-facing tensor shapes before loading and rebuilds the Marlin layout before rollout resumes.
w, fake quantization is:
Quantization settings
The rollout checkpoint and live exporter use the compressed-tensors storage contract:- Format: compressed-tensors
pack-quantizedwithnum_bits: 4,strategy: group, no activation quantization, andsymmetric: true. - Tensor scope: to match the current Megatron hook, pack the routed expert
projections handled by
GroupedLinearand keep other modules in their checkpoint dtype. - Shape: the generic miles packer and direct converter require the final dimension of each packed matrix to be divisible by the group size.
OPEN_TRAINING_INT4_GROUP_SIZE. Set it to the checkpoint’s group_size when
the training forward should use the same grouping as rollout. The two paths are
separate implementations, so matching this value does not by itself establish
bitwise-identical train and rollout weights.
Changing the environment variable does not convert a checkpoint. Changing only
the checkpoint config does not change the fake-quantization grid used by
Megatron.
Kimi-K2.5
Kimi-K2.5 publishes routed expert weights as symmetric group-size-32 INT4 tensors. The maintained Kimi launcher exercises this Bridge path. With--megatron-to-hf-mode bridge, the Kimi Bridge handles both directions:
- On Hugging Face to Megatron load, it unpacks the INT4 expert tensors and maps them to the Megatron parameter dtype, BF16 in the maintained recipe.
- On Megatron to Hugging Face export, it repacks the updated routed experts to
group-size-32 INT4 and returns
weight_packed,weight_scale, andweight_shapetensors for SGLang.
--load checkpoint and no --ref-load, miles
falls back to --hf-checkpoint for Bridge initialization. The current
scripts/run_kimi_k25.py launcher also materializes a BF16 copy and passes it
through --ref-load; that is how the launcher is written today, not a
requirement of the Kimi Bridge.
Run the CI-sized two-layer recipe on one 4-GPU H200 node:
Prepare another MoE checkpoint
The miles direct converter creates a symmetric, group-wise INT4 checkpoint without a calibration dataset:lm_head, norm, embed, self_attn, shared_experts,
mlp.(gate|up|gate_up|down)_proj, and mlp.gate, plus names beginning with
vision_tower or mm_projector. Compare those patterns with a new model’s
actual Hugging Face tensor names before conversion. The converter requires
CUDA and the fake_int4_quant_cuda extension installed by the miles image.
The converter defaults to group size 32. The current
scripts/run_qwen3_30b_a3b.py --rollout-int4 path uses that default for the
rollout checkpoint and sets Megatron fake QAT to group size 128. The path is
therefore an example where the rollout storage group and training fake-QAT
group are configured independently; it does not simulate the same grouping on
both sides.
In raw mode, use the INT4 checkpoint for SGLang and a higher-precision
torch_dist checkpoint to initialize Megatron:
Enable fake QAT
Set both variables in the Ray runtime environment used by every Megatron worker:U.execute_train, using
group size 32. If the selected Megatron model does not build its routed experts
with Transformer Engine GroupedLinear, the environment variables do not
enable QAT for that model.
Validate the setup
Inspect the checkpoint config before launch. The expression handles both a top-level quantization config and Kimi-K2.5’s nested text config:formatispack-quantizedandquant_methodiscompressed-tensors.num_bitsis4,strategyisgroup, andsymmetricistrue.group_sizematchesOPEN_TRAINING_INT4_GROUP_SIZEif train and rollout should use the same grouping.- The safetensors index has
weight_packed,weight_scale, andweight_shapeentries for the intended routed expert projections, and that other modules remain unpacked.
Hardware and test coverage
The direct converter and generic miles INT4 packer use the CUDAfake_int4_quant_cuda extension. SGLang’s CUDA WNA16 MoE path requires NVIDIA
compute capability 8.0 or newer. SGLang also contains a ROCm WNA16 MoE
implementation. The repository registers two INT4 end-to-end tests, the
Kimi-K2.5 two-layer Bridge recipe and the Qwen3-30B-A3B raw-mode recipe, both on
4-GPU H200. It does not register an INT4 QAT end-to-end test on ROCm.
INT4 reduces storage and weight-update traffic for the packed routed experts.
The whole-model reduction is smaller because scales, metadata, and unquantized
tensors remain. Rollout throughput depends on the model, batch shape, expert
parallelism, and the W4A16 backend SGLang selects.

