Skip to content

Drop version checks for long-unsupported dependency releases - #3093

Merged
kevalmorabia97 merged 3 commits into
mainfrom
kmorabia/drop-dead-version-checks
Oct 29, 2026
Merged

kevalmorabia97 merged 3 commits into
mainfrom
kmorabia/drop-dead-version-checks

Conversation

@kevalmorabia97

@kevalmorabia97 kevalmorabia97 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Type of change: Cleanup (drops Transformer Engine 1.x support)

Removes version checks for dependency releases that no supported install or CI container can have anymore. No install metadata changes.

Dependency Removed Why it is dead
onnxruntime 4 onnxruntime<1.21 test skips in test_nodeclassifier.py; the >=1.21 DDS-op check in ort_utils.update_trt_ep_support Every platform pin in the [onnx] extra is >= 1.22
Transformer Engine <2.0 branches in _QuantLayerNormLinearFunc, and the two helpers that only dispatched on it TE 2.0 shipped in early 2025; nemo:26.08 has TE 2.17
megatron-core mcore_version_higher_than("0.9.0") around packed_seq_params in EAGLE megatron-core 0.9 is from 2024; nemo:26.08 has 0.19
vLLM <=0.11 FlexibleArgumentParser import branches in examples/vllm_serve vLLM 0.11 is from Oct 2025; CI uses 0.30

The vLLM >= 0.15 check in the sparse-attention plugin and the lm_eval>=0.4.12 checks in examples/llm_eval stay: they are real errors that match their requirement floors. So does the TensorRT-LLM <1.1.0rc2 context-logits / stop-words gate in modelopt/deploy/llm/generate.py: TensorRT-LLM 1.0 (the install guide's floor) still imports that module.

TE and megatron-core are not in pyproject.toml; ModelOpt's Megatron-Bridge / Megatron-LM features require nemo:26.08 (CHANGELOG), which ships TE 2.17 and megatron-core 0.19. For standalone TE quantization, the install guide now lists Transformer Engine >=2.0 and CHANGELOG.rst notes that TE 1.x is no longer supported (its last release, 1.13, is from Dec 2024).

Usage

N/A

Testing

  • tests/unit/onnx (incl. the previously gated test_nodeclassifier.py tests): 498 passed.
  • In nvcr.io/nvidia/nemo:26.08 (TE 2.17.1, megatron-core 0.19): tests/gpu_megatron/torch/quantization/plugins/test_transformer_engine.py passes (21 passed, 4 skipped), RotaryEmbedding.get_rotary_seq_len accepts packed_seq_params, and the EAGLE Megatron plugin imports.

Before your PR is "Ready for review"

Make sure you read and follow Contributor guidelines and your commits are signed (git commit -s -S).

Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded trust_remote_code=True, torch.load(..., weights_only=False), pickle, etc.).

  • Is this change backward compatible?: ❌ Transformer Engine 1.x is no longer supported; the other removed paths are for releases that cannot be installed alongside ModelOpt's supported stack.
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A
  • Did you write any new necessary tests?: N/A
  • Did you update Changelog?: ✅
  • Did you get Claude approval on this PR?: ❌

Additional Information

Companion to #3091 (torch 2.10 floor) and #3092 (transformers / diffusers floors).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Simplified compatibility handling for model serving, quantization, and speculative decoding integrations.
    • ONNX operations and tests are no longer conditionally excluded based on the ONNX Runtime version.
  • Breaking Changes
    • Transformer Engine 2.0 or later is required for module quantization; Transformer Engine 1.x is no longer supported.
  • Documentation
    • Updated Linux installation requirements to list Transformer Engine 2.0 or later as an optional dependency.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 359bcc7 and c8867eb.

Files selected for processing: 1
  • CHANGELOG.rst

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

Walkthrough

The changes remove dependency-version checks and alternative code paths in vLLM examples, ONNX Runtime DDS handling and tests, Transformer Engine quantization, and Megatron rotary calls. The changelog and Linux requirements state that Transformer Engine 2.0 or later is required for quantization.

Changes: Dependency-version gate removals

Layer / File(s) Summary
vLLM parser imports
examples/vllm_serve/vllm_serve_fakequant.py, examples/vllm_serve/vllm_serve_sparse_attn.py
Both examples import FlexibleArgumentParser from vllm.utils.argparse_utils without selecting the import by vLLM version.
ONNX Runtime gates
modelopt/onnx/quantization/ort_utils.py, tests/unit/onnx/autocast/test_nodeclassifier.py
The DDS path no longer removes "trt" based on the ONNX Runtime version. Four node-classifier tests no longer skip when the version is below 1.21.0.
Transformer Engine GEMM selection and support
modelopt/torch/quantization/plugins/transformer_engine.py, CHANGELOG.rst, docs/source/getting_started/_installation_for_Linux.rst
LayerNormLinear forward and backward quantization capture and patch te_layernorm_linear.general_gemm directly. The changelog and Linux requirements state that Transformer Engine 2.0 or later is required.
Megatron rotary calls
modelopt/torch/speculative/plugins/megatron_eagle.py
The Megatron-Core version helper was removed. RoPE and YaRN rotary-sequence-length calls now always pass packed_seq_params=None.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: cjluo-nv, chenhanyu, kinjalpatel27

Merge Risk: Minimal · up to c8867

The dependency-gate removals are consistent with the supported versions, with no identified merge-blocking behavior change.

Pre-merge checks: Passed 5 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 5 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 describes the main change: removing compatibility checks for unsupported dependency versions.
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 PR adds no torch.load(..., weights_only=False), numpy.load(..., allow_pickle=True), hardcoded trust_remote_code=True, eval()/exec(), or # nosec comments. It also changes no `pypr…
Full details: Security Anti-Patterns

Explanation

PASS. The PR adds no torch.load(..., weights_only=False), numpy.load(..., allow_pickle=True), hardcoded trust_remote_code=True, eval()/exec(), or # nosec comments. It also changes no pyproject.toml or requirements file. The Python diff only removes dependency-version compatibility branches and updates related documentation/tests.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 4 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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.

@kevalmorabia97

Copy link
Copy Markdown
Collaborator Author

/claude review

Comment thread modelopt/deploy/llm/generate.py Resolved
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-29 17:20 UTC

@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 (gpt-6.1-sol) — DM the bot to share feedback.

Nudge: CI versions do not establish that the optional-backend compatibility branches are unreachable in supported local installations.

Needs action:

  • Explain why deleting TE/Megatron guards is safe for supported local installs rather than retaining guards or enforcing minimums; pyproject.toml constrains neither dependency. Cite existing exclusions, or make the support change explicit.
  • Verify the TensorRT-LLM import boundary in modelopt/deploy/llm/generate.py: cite the API excluding <1.1.0rc2 or test that boundary before removing the capability gate. Reconcile the installation guide’s advertised >=1.0 support.

No action needed:

  • The ONNX test edits are justified by the supported-platform ORT dependency floors; all assertions remain intact.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude review — Drop version checks for long-unsupported dependency releases

Scope: full review (trigger comment carried no scoping instructions). All 7 changed files reviewed — 6 source (modelopt/ ×4, examples/ ×2) and 1 test. Nothing deliberately skipped.

Findings

Severity Count
CRITICAL 0
IMPORTANT 0
SUGGESTION 2

Both SUGGESTIONs are dead-abstraction cleanups left behind by the version branches this PR removes, and neither blocks merge:

  • transformer_engine.py:316-322 — _get_original_gemm / _gemm_replace_args are now constant indirection; inlining them at the four call sites removes the abstraction whose only purpose was version dispatch.
  • generate.py:169 — gather_context_logits is a constant-True property with no in-repo reader. Either delete it or document that it is retained for backward compatibility.

What I verified

Each of the five removals is behavior-preserving within the supported stack, and the dead-code claims in the description hold up:

  • onnxruntime >=1.21 — every onnxruntime* pin in the [onnx] extra is >=1.22 (pyproject.toml:67-76: 1.29, ~1.24.2, 1.22.0, ~1.26.0), so the assert could never fire. Removing it also drops a latent bug: the second calibration_eps.remove("trt") sat inside the same if "trt" in calibration_eps guard after the TRT-10.6 branch could already have removed "trt", so a host with both TRT <10.6 and ORT <1.21 would have raised ValueError: list.remove(x): x not in list. The real guard, _check_for_tensorrt(min_version="10.6"), is untouched.
  • TensorRT-LLM 1.1.0rc2 — confirmed the module already hard-fails below that floor: the try: from tensorrt_llm.llmapi import CudaGraphConfig ... block at generate.py:27-34 ends in print("Please upgrade tensorrt-llm to 1.1.0rc2 or later"); raise. So _support_context_logits_and_stop_words was True in every importable environment — dropping the stop_words = None reset in _generate and the assert in generate_context_logits changes nothing. The _enable_kv_cache_reuse assert, which guards the genuinely incorrect case, is preserved.
  • Transformer Engine <2.0 — the two _patched_general_gemm closures are forward-vs-backward (dgrad/wgrad call-order counter), not version variants, so collapsing to general_gemm leaves the GEMM argument order and the STE backward path intact.
  • megatron-core >0.9.0 — both surviving get_rotary_seq_len call sites (megatron_eagle.py:939 rope, :948 yarn) now pass packed_seq_params=None as a keyword, which matches mcore's signature on RotaryEmbedding and the Yarn subclass. No extra_kwargs reference survives. Also checked that dropping import megatron.core is safe: every remaining megatron.core occurrence in the file is a from ... import, a registry string, or a docstring — no bare attribute access that would NameError.
  • vLLM <=0.11 — vllm.utils.argparse_utils exists for everything above 0.11, and the stack is far above it (README installs 0.30; the sparse-attention runtime hard-errors below 0.15 at vllm_runtime.py:173). The retained make_arg_parser try/except for pre-0.29 is consistent with that, not contradicted by it. No leftover vllm / version references in either example after the import removals.
  • No orphaned references — mcore_version_higher_than, _support_context_logits_and_stop_words, and _TE_VERSION have zero remaining uses repo-wide; ort, Version, te, and the tensorrt_llm-scoped imports are all still needed where they were kept, so no unused imports were introduced.
  • Test change — the four unskipped test_nodeclassifier.py tests are CPU-only and now always run, matching the >=1.22 floor; the description reports tests/unit/onnx at 498 passed.

One thing worth a sanity check before merge, not a finding: mcore_version_higher_than was a module-level name without a leading underscore and the module declares no __all__, so it was nominally importable by downstream code (e.g. Megatron-LM's examples/post_training/modelopt scripts). There are no in-repo users, and the body was a one-line version compare that a downstream caller can trivially restate, so I do not think this needs a deprecation shim — just confirming you have ruled out an external importer.

Risk assessment

Low. This is a subtractive cleanup with no install-metadata changes, no modelopt_state schema or mode-registration impact, and no change to quantization math, export layout, or collective ordering. Every removed branch is unreachable given the declared pins or the module's own import-time guard, and the one behavior change that is reachable — the ORT/TRT double-remove path — is a fix rather than a regression. Residual exposure is limited to users on a TE 1.x install, who would now hit a cryptic AttributeError on general_gemm instead of a working path; given TE 2.0 shipped in early 2025 and nemo:26.08 carries 2.17, that is an acceptable trade and consistent with the rest of the PR.

Approving.

@kevalmorabia97

Copy link
Copy Markdown
Collaborator Author

@cjluo-nv re the bot review: ModelOpt's Megatron-Bridge / Megatron-LM features already require nemo:26.08 (CHANGELOG), which ships TE 2.17 and megatron-core 0.19, so TE <2.0 and megatron-core <=0.9 are well outside the supported stack. The TensorRT-LLM gate is restored in a982a32: 1.0 still imports this module, as the install guide's >=1.0 says.

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.78%. Comparing base (4bf3d00) to head (c8867eb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3093      +/-   ##
==========================================
+ Coverage   78.09%   79.78%   +1.69%     
==========================================
  Files         662      662              
  Lines       76116    76094      -22     
==========================================
+ Hits        59439    60710    +1271     
+ Misses      16677    15384    -1293     
Flag Coverage Δ
examples-diffusers 19.95% <0.00%> (+0.02%) ⬆️
examples-gpt-oss 13.48% <0.00%> (+0.01%) ⬆️
examples-hf_ptq 23.48% <0.00%> (-0.02%) ⬇️
examples-llm_distill 13.56% <0.00%> (+<0.01%) ⬆️
examples-llm_eval 17.25% <0.00%> (+0.01%) ⬆️
examples-llm_qat 17.41% <0.00%> (-0.03%) ⬇️
examples-llm_sparsity 16.75% <0.00%> (+0.01%) ⬆️
examples-megatron_bridge 26.51% <100.00%> (-0.25%) ⬇️
examples-specdec_bench 13.26% <0.00%> (+0.01%) ⬆️
examples-speculative_decoding 17.49% <0.00%> (-0.05%) ⬇️
examples-torch_onnx 21.22% <0.00%> (-0.01%) ⬇️
examples-torch_trt 15.23% <0.00%> (+0.01%) ⬆️
examples-vllm_serve 17.47% <0.00%> (+<0.01%) ⬆️
gpu 59.23% <100.00%> (+6.31%) ⬆️
regression 15.05% <0.00%> (+<0.01%) ⬆️
unit 61.97% <0.00%> (+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.

@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 (gpt-6.1-sol) — DM the bot to share feedback.

Nudge: the TensorRT-LLM concern is resolved, but the Megatron container requirement does not establish a support floor for standalone TE quantization.

Needs action:

  • 💬 Author cites nemo:26.08 for Megatron — clarify standalone te.pytorch.LayerNormLinear support in the PR body; cite an existing TE>=2.0 requirement, retain the fallback, or document the support change in installation docs and CHANGELOG.rst.

No action needed:

  • ✔️ Resolved since the last review: TensorRT-LLM gate restoration, TE helper inlining, and the Megatron support-floor rationale.
  • The ONNX skip removals are justified by the [onnx] dependency pins; all assertions remain intact.

@kevalmorabia97
kevalmorabia97 force-pushed the kmorabia/drop-dead-version-checks branch from a982a32 to 359bcc7 Compare October 29, 2026 07:27
@kevalmorabia97

Copy link
Copy Markdown
Collaborator Author

@cjluo-nv re standalone TE quantization: made the support change explicit in 359bcc7. The install guide now lists Transformer Engine >=2.0 (optional), and CHANGELOG.rst notes that TE 1.x is no longer supported. TE 1.x's last release (1.13) is from Dec 2024, a year before the torch 2.10 floor, and every supported container ships TE 2.x.

@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 (gpt-6.1-sol) — DM the bot to share feedback.

LGTM: prior compatibility concerns are resolved; human sign-off remains required for the justified ONNX test edits.

Needs action:

  • Review and sign off on tests/unit/onnx/autocast/test_nodeclassifier.py: the removed skips match supported ORT dependency floors, and every assertion remains intact.

No action needed:

  • ✔️ 4 previous concerns addressed, including standalone TE support documentation and TensorRT-LLM gate restoration.

kevalmorabia97 and others added 3 commits October 29, 2026 02:15
Remove branches for onnxruntime<1.21, Transformer Engine<2.0, megatron-core<=0.9,
TensorRT-LLM<1.1.0rc2 and vLLM<=0.11. Every supported install or CI container is
well past these versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
TensorRT-LLM 1.0 still imports this module (CudaGraphConfig exists there), so the
<1.1.0rc2 context-logits/stop-words gate is not dead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
@kevalmorabia97
kevalmorabia97 force-pushed the kmorabia/drop-dead-version-checks branch from 359bcc7 to c8867eb Compare October 29, 2026 09:16

@ChenhanYu ChenhanYu 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.

Pensieve nudge review using chenhany's profile (revision 8).

Nudge: prior compatibility concerns are resolved, but vLLM launcher validation and current-head test results remain unverified.

Needs action:

  • Confirm current-head ONNX/TE GPU results and record vLLM launcher validation in Testing: run the existing fakequant example tests and a sparse-launcher import smoke check. Execution and CI logs are unavailable here.
  • Confirm human sign-off on tests/unit/onnx/autocast/test_nodeclassifier.py, continuing review 5694264690; removing skips matches supported ORT floors and preserves every assertion.

No action needed:

  • ✔️ Resolved since earlier reviews: standalone TE support documentation, TensorRT-LLM gate restoration, TE helper inlining, and the Megatron support-floor rationale.
  • The surviving TE2 and Megatron paths preserve the base behavior; existing TE tests exercise quantization, backward, and restore. ONNX test coverage expands rather than shrinks.
  • No new defects or licensing changes identified. Duplicate checking covers the supplied bounded history only; reported test passes were not independently executed.

Review context was incomplete.

Review run: 5e883ebf2b194e1b8635d27791968e19

@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 (gpt-6.1-sol) — DM the bot to share feedback.

LGTM: prior compatibility concerns are resolved; only human sign-off on the justified ONNX skip removals remains.

Needs action:

  • Review and sign off on tests/unit/onnx/autocast/test_nodeclassifier.py: all four removed skips match supported ORT dependency floors, and every assertion is preserved.

No action needed:

  • ✔️ 4 previous concerns addressed, including standalone TE support documentation and TensorRT-LLM gate restoration.

@kevalmorabia97
kevalmorabia97 merged commit cfd4ace into main Oct 29, 2026
53 checks passed
@kevalmorabia97
kevalmorabia97 deleted the kmorabia/drop-dead-version-checks branch October 29, 2026 17:19
shengliangxu added a commit that referenced this pull request Oct 30, 2026
…on each rank's own experts (#3122)

> [!NOTE]
> **[1/2] of #3074's split.** A reviewer asked on #3074 for its
expert-parallel correctness fix to land on its own, with a Bug Fixes
changelog entry, apart from #3074's two backward-breaking changes
(calibration on `grouped_mm` by default, and the new `calibrate()`
error). This PR is that fix. #3074, now [2/2], sits on it and keeps the
rest.
>
> **Base:** `main` (`2b900c8fa41`).

### What does this PR do?

Type of change: Bug fix

Under the expert parallelism of transformers 5.16 and later (the
`grouped_gemm` plan style), a fused experts module keeps each expert
weight as a DTensor sharded over the experts (`Shard(0)`) and sets
`num_experts` to the rank's count. Its forward runs on local tensors,
but ModelOpt also reads the expert weights outside the forward, by local
expert index:

- max calibration's weight pass and `fold_weight`, through
`get_expert_weight`;
- the weight-input hooks of local Hessian and imatrix (`on_weight` at
registration, and the eager per-expert capture);
- GPTQ's per-expert helpers;
- the native FP8 wrapper's dequantization, which also indexes
`*_scale_inv`.

An index into the DTensor names a global expert, and each such read
all-gathers every expert. (Before 5.16, transformers kept each rank's
slice as a plain tensor, which these reads indexed correctly.) On two
ranks with a 4-expert Qwen3-MoE experts module under weight-only INT8,
main calibrates rank 1's two weight quantizers on rank 0's experts 0 and
1 instead of its own experts 2 and 3. `fold_weight` folds into the
gathered copies, so no rank's own experts get folded, rank 0's included.

`_QuantFusedExperts._local_experts` hands those readers the rank's own
shard, in quantizer order. A DTensor holding every expert (FSDP2) is
indexed as before. Two layouts are refused instead of read wrong:

- a DTensor whose local shard does not hold the module's experts (one
replicated over the ranks, say), which would otherwise be indexed as
global experts;
- native FP8 expert weights sharded over the experts, in
`unpack_weight`, which would otherwise unpack into a buffer for every
expert from this rank's experts. Both projections are checked before
either is unpacked.

### Usage

No API change.

### Testing

- New tests in
`tests/unit/torch/quantization/plugins/test_fused_experts.py` run on CPU
over two gloo ranks, with experts sharded as transformers shards them.
All six cases fail on main and pass here:
- weight calibration and `fold_weight` use each rank's own experts:
plain, and with the dense part FSDP2-sharded, on named and unnamed
meshes;
- a replicated expert DTensor, and native FP8 experts sharded over the
experts, are refused;
- registering the weight-input hooks hands `on_weight` each rank's first
local expert, and runs no collective;
  - GPTQ builds its expert helpers from each rank's own experts.
- `tests/unit/torch/quantization` on CPU (torch 2.14, transformers
5.18): the six new cases pass, and every other result matches main's.
- pre-commit, mypy included, passes against main.
- Review suggestion (Claude), 2026-10-29: `unpack_weight` checks both
projections before unpacking either, so a refusal leaves the module
unchanged; the refusal test shards `down_proj` alone and checks that
`gate_up_proj` is still FP8, which fails with the per-projection check.
The changelog entry and `_local_experts`' docstring name transformers
5.16, where expert-parallel weights became DTensors. pre-commit passes
against main.
- Rebased on 2026-10-30 onto main `99c3834f62c` (after #3093, #3108,
#3101, #2737, #3099 and #2750 merged), with its own diff unchanged and
no conflicts. pre-commit, now with main's ruff 0.17 and mypy 2.4 hooks,
passes.

### Before your PR is "*Ready for review*"

Make sure you read and follow [Contributor
guidelines](https://github.com/NVIDIA/Model-Optimizer/blob/main/CONTRIBUTING.md)
and your commits are signed (`git commit -s -S`).

Make sure you read and follow the [Security Best
Practices](https://github.com/NVIDIA/Model-Optimizer/blob/main/SECURITY.md#security-coding-practices-for-contributors)
(e.g. avoiding hardcoded `trust_remote_code=True`, `torch.load(...,
weights_only=False)`, `pickle`, etc.).

- Is this change backward compatible?: ✅ <!--- A weight layout the
quantizers cannot index now raises instead of calibrating the wrong
experts. -->
- If you copied code from any other sources or added a new PIP
dependency, did you follow guidance in `CONTRIBUTING.md`: N/A
- Did you write any new necessary tests?: ✅
- Did you update
[Changelog](https://github.com/NVIDIA/Model-Optimizer/blob/main/CHANGELOG.rst)?:
✅ (Bug Fixes)
- Did you get Claude approval on this PR?: ❌ <!--- Requested. The same
code was reviewed and approved as part of #3074. -->

### Additional Information

Split out of #3074 at a reviewer's request. Jira: OMNIML-6073.



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

## Summary by CodeRabbit

* **Bug Fixes**
* Fixed weight calibration, GPTQ quantization, and weight folding for
Hugging Face fused MoE models split across expert-parallel ranks. Each
rank now uses its local experts’ weights.
* Unsupported expert-sharding layouts now return a clear error when
weights cannot be safely indexed or unpacked.
* **Improvements**
* Preserved native scaled FP8 expert weights through quantization and
export, with exported weights checked against reconstructed BF16
references.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Shengliang Xu <shengliangx@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants