Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5a329b8
Quantize fused experts under grouped_mm by intercepting _grouped_linear
shengliangxu Oct 27, 2026
54b50f5
Leave fused experts stored transposed unquantized
shengliangxu Oct 27, 2026
2d287cf
Keep a disabled weight quantizer's pre-quant scale and rotation on th…
shengliangxu Oct 28, 2026
144db5a
Pin the grouped forward's fake-quantized output and gradients against…
shengliangxu Oct 28, 2026
9122ae1
Unregister the grouped test experts in a finally, as the class's othe…
shengliangxu Oct 28, 2026
6372ed9
Leave the torch_a2a test fixtures to the PR whose tests drive them
shengliangxu Oct 28, 2026
7c83909
Fake-quantize the grouped forward's experts in one launch where the f…
shengliangxu Oct 28, 2026
8c84ef9
Let the eager-keyed weight-input captures skip the grouped forward's …
shengliangxu Oct 28, 2026
c7fb068
Take the stacked fake-quant kernel on the grouped forward without aut…
shengliangxu Oct 28, 2026
123e5f7
Name expert parallelism in the eager-only wrapper's grouped-forward r…
shengliangxu Oct 28, 2026
fb41c9e
Say the grouped forward's weight-input captures skip its batch
shengliangxu Oct 28, 2026
4b5bc94
Pin that a disabled weight quantizer's rotation applies on the groupe…
shengliangxu Oct 28, 2026
791ce88
Drop a comment that repeats the docstring, and a move of a helper
shengliangxu Oct 28, 2026
b68e15d
Say in the changelog that an old modelopt_state for such experts no l…
shengliangxu Oct 28, 2026
d0c695d
Import transformers' moe module in the GPU test as the plugin does
shengliangxu Oct 28, 2026
814f60c
Fake-quantize the grouped weight's slices in strict step with its qua…
shengliangxu Oct 28, 2026
57e12d7
Keep the quantizers' dtype in the grouped forward without autograd
shengliangxu Oct 28, 2026
4f1b64a
Pin the export refusal and the restore break for transposed experts
shengliangxu Oct 28, 2026
f85148d
File the restore break under Backward Breaking Changes
shengliangxu Oct 28, 2026
77c6f7c
Promote the grouped weight's buffer as the stack does when experts di…
shengliangxu Oct 28, 2026
30d5750
Say the grouped_mm fallback does not call F.linear
shengliangxu Oct 28, 2026
5f9739a
Say why calibration is still forced onto eager now that grouped_mm is…
shengliangxu Oct 28, 2026
689d372
Say what keeps the FP8 experts wrapper on eager
shengliangxu Oct 28, 2026
1274887
Say the transposed check sees only a declared non-gated layout
shengliangxu Oct 28, 2026
3cfe6e0
Count the FSDP2 ownership scans themselves, not fully_shard.state calls
shengliangxu Oct 28, 2026
75265cb
Say why transposed experts stay in the eager scan and that their expo…
shengliangxu Oct 28, 2026
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
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Changelog
- Diffusion HF exports now omit attention quantizer buffers by default, except for FLUX.1, which retains enabled Q/K/V ``_amax`` keys for runtime compatibility; other consumers of those keys can opt in with ``export_attention_quantizers=True`` (CLI: ``--extra-param export_attention_quantizers=true``). Disabled attention quantizers remain excluded, and diffusion components, including LTX-2, no longer emit KV-cache quantization metadata.
- ``hf_quant_config.json`` of an INT4 or W4A8 AWQ checkpoint now sets ``pre_quant_scale`` per layer, only for layers that have the tensor. A model whose fused-MoE experts have none (AWQ never applies to them) is now exported as ``MIXED_PRECISION`` with per-layer entries instead of a uniform algorithm.
- The Windows FVD example rejects I3D checkpoints requiring unrestricted pickle loading. Custom TorchScript archives now require ``--weights-sha256`` with a trusted checksum; tensor state dictionaries continue to load directly.
- A ``modelopt_state`` saved by an earlier release for a Hugging Face model whose fused MoE experts are stored transposed without a quantized wrapper of their own (for example Aria's) no longer restores, since those experts are now left unquantized. The checkpoints such a state exported had wrong expert weights, so there is nothing to migrate.

- Layerwise-calibration resume (``checkpoint_dir``) now loads checkpoint files with ``weights_only=True``. A checkpoint directory written by an earlier release whose layer inputs hold objects other than tensors, plain containers or Hugging Face dynamic caches can no longer be resumed; recalibrate in a fresh directory, or disable checkpointing.

Expand All @@ -61,6 +62,7 @@ Changelog
**Bug Fixes**

- ``hf_quant_config.json`` now declares ``pre_quant_scale`` only for INT4 / W4A8 layers that have the tensor; loading INT4 / W4A8 fused-MoE checkpoints in TensorRT-LLM also needs a release whose MoE loader treats it as optional. AWQ, SmoothQuant and SVDQuant now warn when they skip quantized fused-MoE experts.
- Hugging Face fused MoE experts stored transposed, ``(num_experts, in_dim, out_dim)``, without a quantized wrapper of their own (for example Aria's) are now left unquantized with a warning. They were quantized with gate and up split along the wrong axis, so their exported weights were wrong; the Hugging Face export now refuses such a model's MoE block instead.
- Calibrating a Megatron-Core MLA model now gives ``linear_q_down_proj`` and ``linear_kv_down_proj`` one per-tensor input and weight range, as vLLM and TensorRT-LLM fuse them into one GEMM with one scale per tensor. Re-calibrate existing MLA checkpoints to get the shared ranges.
- ``export_mcore_gpt_to_hf`` and ``capture_kv_cache_export_state`` now write NVFP4 KV-cache ``k_scale`` / ``v_scale`` as amax / 448, like the HF exporter and as vLLM and TensorRT-LLM expect. They wrote amax / (6 * 448), which overflows in the attention kernels. Re-export Megatron checkpoints with an NVFP4 KV cache.
- Preserve accumulated histogram counts when computing an entropy calibration threshold with NumPy histograms.
Expand Down
2 changes: 1 addition & 1 deletion modelopt/torch/models/step3p5/modeling_ptq.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _is_expert_indexed_moe_linear(module: nn.Module) -> bool:
``weight`` of shape ``[num_experts, out_features, in_features]``, whose
``forward(x, expert_id)`` runs ``F.linear`` against the selected expert's slice. The
weights therefore live on the projection submodule rather than on the expert container,
which is what :func:`_fused_experts_wrapper_class` looks for, and the module is not an
which is what :func:`_fused_experts_wrapper` looks for, and the module is not an
``nn.Linear``, so neither the fused-experts path nor the plain linear path claims it.

Detection is structural rather than keyed on class names so new Step revisions are picked
Expand Down
6 changes: 4 additions & 2 deletions modelopt/torch/quantization/model_calib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,10 @@ def _fused_expert_projections(module: nn.Module):
"""Yield ``(weight_name, weight, weight_quantizers, input_quantizer)`` per fused-experts projection.

``weight`` is the 3-D ``(num_experts, out, in)`` parameter, ``weight_quantizers`` holds one
quantizer per expert, and ``input_quantizer`` is shared by the experts and runs once per expert
forward with ``module._current_expert_idx`` already set to that expert.
quantizer per expert, and ``input_quantizer`` is shared by the experts. Under eager it runs once
per expert forward with ``module._current_expert_idx`` set to that expert; under grouped_mm once
per projection, on every expert's rows, with the index cleared (``None``), so a capture keyed on
it skips that batch.
"""
first_proj_attr = getattr(module, "_first_proj_attr", "gate_up_proj")
for weight_name, quantizers_name, input_q_name in (
Expand Down
Loading
Loading