Skip to content

[OMNIML-3853] Fix the GLM-5.1 alias: it is not the input_scale1 recipe - #2711

Merged
shengliangxu merged 1 commit into
mainfrom
shengliangx/fix-glm-5-1-alias
Oct 9, 2026
Merged

shengliangxu merged 1 commit into
mainfrom
shengliangx/fix-glm-5-1-alias

Conversation

@shengliangxu

@shengliangxu shengliangxu commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Type of change: Bug fix (checkpoint alias pointed at the wrong recipe)

models/zai-org/GLM-5.1/ aliases general/ptq/nvfp4_experts_only_input_scale1-kv_fp8_cast. It should alias the plain general/ptq/nvfp4_experts_only-kv_fp8_cast.

The input_scale1 recipe pins the expert activation amax to a constant 2688.0 (E2M1_MAX * E4M3_MAX), so every exported expert input_scale is exactly 1.0 and no activation statistics are collected. That is a visible property of the published checkpoint, and GLM-5.1 does not have it:

Release Expert input_scale, 8 randomly sampled
nvidia/GLM-5.2-NVFP4 8 of 8 exactly 1.0 matches input_scale1
nvidia/GLM-5.1-NVFP4 0 of 8 equal to 1.0, spanning 3.4e-4 … 1.3e-2 ordinary calibration

So GLM-5.1 used ordinary activation calibration and takes the plain experts-only recipe. GLM-5.2 is correct and is not touched.

Scope and KV mode were re-checked against the release and are unchanged — routed experts only, FP8 KV cache in cast mode. Only the activation handling was wrong. Verified after the change that the alias now resolves identically to its base, that the pinned 2688.0 amax is gone from the resolved config, and that GLM-5.2 still carries it.

How this happened

The recipes were collected by asking the engineer behind each release. GLM-5.1 and GLM-5.2 were answered together in one line naming input_scale1. That was recorded for both without checking the one property the recipe is named for. #2643 merged it.

One thing left open

Max versus MSE is not recoverable from a checkpoint — calibration leaves no trace in the exported tensors, which is why the sampling above can settle input_scale1 but not this. The max variant here reflects the general default, not a confirmed fact. If GLM-5.1 used MSE, the follow-up is a one-line change of the import to general/ptq/nvfp4_experts_only_mse-kv_fp8_cast; scope, KV mode and activation handling all stay as they are in this PR.

This PR is still strictly closer to the release than what is on main today, which misstates activation handling outright.

Usage

python examples/hf_ptq/hf_ptq.py \
    --pyt_ckpt_path zai-org/GLM-5.1 \
    --recipe models/zai-org/GLM-5.1/ptq/nvfp4_experts_only-kv_fp8_cast \
    --export_path <output>

Testing

  • tests/unit/recipe/ — 461 passed.
  • Verified the new path resolves to a config identical to general/ptq/nvfp4_experts_only-kv_fp8_cast, that constant_amax: 2688.0 no longer appears in it, that the old path now raises ValueError, and that GLM-5.2 still resolves with the pinned amax.
  • pre-commit passes on both changed files.
  • The 14 failures in the local run are pre-existing and environment-only — a broken transformer_engine .so in the dev venv; they reproduce identically on unmodified main.

Before your PR is "Ready for review"

  • Is this change backward compatible?: ⚠️ — --recipe models/zai-org/GLM-5.1/ptq/nvfp4_experts_only_input_scale1-kv_fp8_cast stops resolving and becomes .../nvfp4_experts_only-kv_fp8_cast. That is the fix: the old path named a recipe that does not produce this release.
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: ✅ — no new dependencies, no source changes.
  • Did you write any new necessary tests?: ✅ — covered by the shipped-recipe sweep in tests/unit/recipe/test_loader.py.
  • Did you update Changelog?: ❌ — corrects an alias added in the same unreleased cycle ([OMNIML-3853] Backfill checkpoint aliases for nine published NVFP4 releases #2643), which CONTRIBUTING.md says to skip. Happy to add one if you would rather it be recorded.
  • Did you get Claude approval on this PR?: ❌ — not yet run.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified that GLM-5.1 uses calibrated expert activation scales, while GLM-5.2 pins them to 1.0.
    • Updated the GLM-5.1 recipe description to note max calibration and an FP8 KV cache in cast mode.

@copy-pr-bot

copy-pr-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/Model-Optimizer/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 25f140b1-cb5b-4a07-b384-d891ff3ced75

📥 Commits

Reviewing files that changed from the base of the PR and between af07754 and f442120.


📒 Files selected for processing (2)
  • modelopt_recipes/models/zai-org/GLM-5.1/ptq/nvfp4_experts_only-kv_fp8_cast.yaml
  • modelopt_recipes/ptq.md

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.



📝 Walkthrough

Walkthrough

The GLM-5.1 recipe now uses the general expert-only NVFP4 recipe with max calibration and an FP8 KV cache in cast mode. The checkpoint alias catalog distinguishes GLM-5.1’s calibrated expert activation scales from GLM-5.2’s pinned scale.

Changes

GLM Recipe Aliases

Layer / File(s) Summary
Update recipe and release aliases
modelopt_recipes/models/zai-org/GLM-5.1/ptq/nvfp4_experts_only-kv_fp8_cast.yaml, modelopt_recipes/ptq.md
The GLM-5.1 recipe imports the general expert-only NVFP4 recipe and describes max calibration. The alias catalog assigns the input_scale1 recipe to GLM-5.2 and the calibrated-activation recipe to GLM-5.1.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix


Merge Risk: ⚪ Minimal · up to f4421

The recipe change is mergeable with minimal risk, though release calibration details remain undocumented.

Pre-merge checks | Passed 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: correcting the GLM-5.1 alias because it does not use the input_scale1 recipe.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns Passed PASS. The pull request changes only one YAML recipe alias and modelopt_recipes/ptq.md; it adds no Python code or dependency-file changes. The added diff contains no `torch.load(..., weights_only=Fal…


✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.17%. Comparing base (24d6964) to head (f442120).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2711      +/-   ##
==========================================
+ Coverage   71.67%   78.17%   +6.49%     
==========================================
  Files         644      644              
  Lines       71470    71470              
==========================================
+ Hits        51225    55870    +4645     
+ Misses      20245    15600    -4645     
Flag Coverage Δ
examples-diffusers 20.24% <ø> (-0.02%) ⬇️
examples-gpt-oss 13.47% <ø> (+<0.01%) ⬆️
examples-hf_ptq 23.37% <ø> (-0.02%) ⬇️
examples-llm_distill 13.55% <ø> (+0.02%) ⬆️
examples-llm_eval 17.31% <ø> (+<0.01%) ⬆️
examples-llm_qat 17.55% <ø> (+0.02%) ⬆️
examples-llm_sparsity 15.84% <ø> (-0.01%) ⬇️
examples-megatron_bridge 26.45% <ø> (-0.17%) ⬇️
examples-specdec_bench 13.25% <ø> (+<0.01%) ⬆️
examples-speculative_decoding 17.60% <ø> (-0.06%) ⬇️
examples-torch_onnx 21.60% <ø> (-0.01%) ⬇️
examples-torch_trt 15.24% <ø> (+0.01%) ⬆️
examples-vllm_serve 13.92% <ø> (+0.02%) ⬆️
gpu 59.11% <ø> (+25.57%) ⬆️
unit 59.85% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

zai-org/GLM-5.1 was recorded as using
general/ptq/nvfp4_experts_only_input_scale1-kv_fp8_cast, alongside GLM-5.2. That
recipe pins the expert activation amax to a constant 2688.0 (E2M1_MAX *
E4M3_MAX), so every exported expert input_scale comes out exactly 1.0. GLM-5.2's
do -- 8 of 8 sampled. GLM-5.1's do not: 0 of 8 randomly sampled expert
input_scale tensors equal 1.0, and they span 3.4e-4 to 1.3e-2, i.e. ordinary
activation calibration.

So GLM-5.1 takes the plain experts-only recipe. Scope and KV mode are unchanged
and were verified against the release: routed experts only, FP8 KV cache in cast
mode. Only the activation handling was wrong.

The two models were given one answer covering both when the recipes were
collected, and that answer was recorded without checking the single property the
input_scale1 recipe is named for. GLM-5.2 stays as it is.

One caveat: max versus MSE is not recoverable from a checkpoint, so the `max`
variant here reflects the general default rather than a confirmed fact. If the
release used MSE, the fix is to switch the import to
general/ptq/nvfp4_experts_only_mse-kv_fp8_cast; everything else stays.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Shengliang Xu <[email protected]>
@shengliangxu
shengliangxu force-pushed the shengliangx/fix-glm-5-1-alias branch from ea6470a to f442120 Compare October 9, 2026 21:19
@shengliangxu
shengliangxu marked this pull request as ready for review October 9, 2026 21:22
@shengliangxu
shengliangxu requested a review from a team as a code owner October 9, 2026 21:22
@shengliangxu
shengliangxu requested a review from cjluo-nv October 9, 2026 21:22

@cjluo-nv cjluo-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bot review (bedrock-claude-opus-5-5) — DM the bot to share feedback.

Approving: this is a small, correct alias fix. GLM-5.1 now imports the plain general/ptq/nvfp4_experts_only-kv_fp8_cast recipe, which matches the calibrated input_scale tensors in the published checkpoint.

No action needed.

  • I searched the repo for other references to the old path GLM-5.1/ptq/nvfp4_experts_only_input_scale1-kv_fp8_cast. The only one is the ptq.md entry this PR rewrites. The CHANGELOG.rst entry names zai-org/GLM-5.1 without a recipe path, so it is still accurate.
  • I checked the base recipe this alias now points to. It exists, uses method: max, and has no constant_amax, so the new comment and description are accurate. The GLM-5.2 alias is unchanged.
  • The rename keeps the existing NVIDIA Apache header, so there is no licensing concern. The shipped-recipe sweep in tests/unit/recipe/test_loader.py covers the new file.
  • Removing the old path is a deliberate breaking change inside the unreleased cycle that added it (#2643). Skipping a changelog entry is consistent with CONTRIBUTING.md.
  • Still open, as the PR body says: we can't tell from the checkpoint whether max or MSE calibration was used. If it turns out to be MSE, switching the import is a one-line follow-up.

@shengliangxu
shengliangxu merged commit 784f16d into main Oct 9, 2026
58 checks passed
@shengliangxu
shengliangxu deleted the shengliangx/fix-glm-5-1-alias branch October 9, 2026 22:38
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-09 22:38 UTC

@shengliangxu shengliangxu changed the title Fix the GLM-5.1 alias: it is not the input_scale1 recipe [OMNIML-3853] Fix the GLM-5.1 alias: it is not the input_scale1 recipe Oct 9, 2026
@rohansjoshi rohansjoshi added the cherry-pick-done Added by bot once PR is cherry-picked to the release branch label Oct 16, 2026
rohansjoshi added a commit that referenced this pull request Oct 17, 2026
#2769 #2770 #2719 #2796 #2801 #2794 #2787 #2682 #2793 #2791 #2792 #2766 #2823 #2777 #2773 #2813 #2832 #2795 #2684 #2822 #2838 #2807 #2772 #2837 #2820 (#2843)

## Cherry-picked PRs

- #2647
- #2700
- #2718
- #2578
- #2580
- #2711
- #2731
- #2726
- #2697
- #2769
- #2770
- #2719
- #2796
- #2801
- #2794
- #2787
- #2682
- #2793
- #2791
- #2792
- #2766
- #2823
- #2777
- #2773
- #2813
- #2832
- #2795
- #2684
- #2822
- #2838
- #2807
- #2772
- #2837
- #2820

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Expanded quantized model export support for MXFP4, MXFP8, FP8, and
additional block-quantization formats.
* Added quantization support for GPT-OSS and Step-family models, plus
export support for native FP8 experts.
* Added chat JSONL data preparation for Megatron workflows and an option
to freeze the student MTP head during distillation.
* Added model recipes for Kimi, Gemma, DiffusionGemma, and GLM variants.
* **Bug Fixes**
* Improved ONNX quantization and export compatibility, distributed
calibration consistency, and handling of packed attention caches.
  * Improved safe model loading and low-precision quantization accuracy.
* **Documentation**
* Updated the 0.48.0 changelog and guidance for data preparation and
quantization recipes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Also includes a partial backport of #2656 (only the
`_validate_fold_weight` hook and the `mtq.fold_weight` pre-check), which
#2820 depends on.

---------

Signed-off-by: Shengliang Xu <[email protected]>
Signed-off-by: Rohan Joshi <[email protected]>
Signed-off-by: Juhi Mittal <[email protected]>
Signed-off-by: Fridah-nv <[email protected]>
Signed-off-by: Chenjie Luo <[email protected]>
Signed-off-by: yingguo-trt <[email protected]>
Signed-off-by: weimingc <[email protected]>
Signed-off-by: Yue <[email protected]>
Signed-off-by: joe-nv <[email protected]>
Signed-off-by: ajrasane <[email protected]>
Signed-off-by: Ajinkya Rasane <[email protected]>
Signed-off-by: ColinM-sys <[email protected]>
Signed-off-by: Keval Morabia <[email protected]>
Signed-off-by: Meng Xin <[email protected]>
Signed-off-by: gcunhase <[email protected]>
Signed-off-by: Chad Voegele <[email protected]>
Co-authored-by: Shengliang Xu <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Juhi Mittal <[email protected]>
Co-authored-by: Frida Hou <[email protected]>
Co-authored-by: Chenjie Luo <[email protected]>
Co-authored-by: yingguo-trt <[email protected]>
Co-authored-by: Wei-Ming Chen <[email protected]>
Co-authored-by: yueshen2016 <[email protected]>
Co-authored-by: joe <[email protected]>
Co-authored-by: Ajinkya Rasane <[email protected]>
Co-authored-by: Colin McDonough <[email protected]>
Co-authored-by: Keval Morabia <[email protected]>
Co-authored-by: mxinO <[email protected]>
Co-authored-by: Gwena Cunha <[email protected]>
Co-authored-by: Chad Voegele <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-0.48.0 cherry-pick-done Added by bot once PR is cherry-picked to the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants