Skip to content

Bump transformers dependency to >=4.57,<5.15 - #2050

Merged
kevalmorabia97 merged 2 commits into
mainfrom
kmorabia/transformers-bump-4.57
Aug 3, 2026
Merged

kevalmorabia97 merged 2 commits into
mainfrom
kmorabia/transformers-bump-4.57

Conversation

@kevalmorabia97

@kevalmorabia97 kevalmorabia97 commented Aug 3, 2026 •

Copy link
Copy Markdown
Collaborator

Transformers Dependency bump - Drop 4.56 (still support 4.57 with deprecation note) and extend to 5.14 (nemo:26.08 ships with this version)

  • CI tests now use transformers 5.14
  • Manually ran tests/{gpu_megatron,examples/megatron_bridge} in nemo:26.08.rc3

Summary by CodeRabbit

Compatibility

  • Updated supported Transformers versions to 4.57 through 5.14.
  • Qwen3-VL models are now available without version-based restrictions.

Documentation

  • Updated the changelog to reflect the new minimum Transformers version and upcoming removal of Transformers 4.x support.

Testing

  • Updated validation and test configurations for the supported Transformers versions.

Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The update raises the minimum supported Transformers version to 4.57, extends the upper bound to below 5.15, updates test pins, and removes Qwen3-VL version guards and lazy imports.

Changes

Transformers compatibility

Layer / File(s) Summary
Transformers version policy
CHANGELOG.rst, pyproject.toml, noxfile.py, modelopt/torch/__init__.py
The supported Transformers range changes to 4.57 through 5.14. Runtime warnings, optional dependencies, test pins, and changelog entries use the new range.
Qwen3-VL loading and tests
modelopt/torch/puzzletron/anymodel/models/__init__.py, tests/_test_utils/torch/transformers_models.py, tests/gpu/torch/puzzletron/test_puzzletron.py
Qwen3-VL registration and configuration imports are unconditional. The obsolete Transformers version skip is removed from the GPU test.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: chenhanyu, shengliangxu

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 The PR adds only version/import changes; no new unsafe load, pickle, remote-code, eval/exec, or # nosec patterns were found, and the dependency edit only changes Transformers bounds.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the Transformers dependency update that is the main purpose of the pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kmorabia/transformers-bump-4.57

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

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

🧹 Nitpick comments (1)
modelopt/torch/puzzletron/anymodel/models/__init__.py (1)

27-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the dead version imports.

This change removes the only use of _Version and _transformers_version in this module. Delete those imports so the module does not retain dead code.

As per coding guidelines, remove dead code, including unused imports.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modelopt/torch/puzzletron/anymodel/models/__init__.py` at line 27, Remove the
now-unused _Version and _transformers_version imports from the module containing
the qwen3_vl wildcard import, while preserving the qwen3_vl export.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@modelopt/torch/puzzletron/anymodel/models/__init__.py`:
- Line 27: Remove the now-unused _Version and _transformers_version imports from
the module containing the qwen3_vl wildcard import, while preserving the
qwen3_vl export.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d6f4e7f8-1841-4431-b400-d9bebbb2fe89

📥 Commits

Reviewing files that changed from the base of the PR and between 2f6e77f and 363ad66.

📒 Files selected for processing (7)
  • CHANGELOG.rst
  • modelopt/torch/__init__.py
  • modelopt/torch/puzzletron/anymodel/models/__init__.py
  • noxfile.py
  • pyproject.toml
  • tests/_test_utils/torch/transformers_models.py
  • tests/gpu/torch/puzzletron/test_puzzletron.py
💤 Files with no reviewable changes (1)
  • tests/gpu/torch/puzzletron/test_puzzletron.py

@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-03 20:13 UTC

@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.92%. Comparing base (2f6e77f) to head (9da38d1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2050       +/-   ##
===========================================
+ Coverage   66.94%   77.92%   +10.97%     
===========================================
  Files         519      519               
  Lines       59401    59400        -1     
===========================================
+ Hits        39767    46287     +6520     
+ Misses      19634    13113     -6521     
Flag Coverage Δ
examples 43.10% <100.00%> (-0.20%) ⬇️
gpu 58.75% <100.00%> (+37.80%) ⬆️
regression 15.00% <50.00%> (+0.06%) ⬆️
unit 55.15% <100.00%> (-0.02%) ⬇️

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.

Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
@shengliangxu

Copy link
Copy Markdown
Collaborator

what is the standard/process of bumping the version?

@kevalmorabia97

Copy link
Copy Markdown
Collaborator Author

what is the standard/process of bumping the version?

We bump transformers to latest every release. Since we're already at 5.15, I also removed 4.56 as some models require optional imports till 4.57 to clean up. We might drop 4.x at some point too

@shengliangxu

Copy link
Copy Markdown
Collaborator

OK, so 4.57 seems the last version of v4? Looking forward to just drop v4 sometime in the future.

@kevalmorabia97
kevalmorabia97 merged commit 3882635 into main Aug 3, 2026
55 checks passed
@kevalmorabia97
kevalmorabia97 deleted the kmorabia/transformers-bump-4.57 branch August 3, 2026 20:13
@kevalmorabia97 kevalmorabia97 added the cherry-pick-done Added by bot once PR is cherry-picked to the release branch label Aug 4, 2026
kevalmorabia97 added a commit that referenced this pull request Aug 4, 2026
#2041 #2031 #2061 #1983 #1628 (#2062)

## Cherry-picked PRs

- #2022
- #2026
- #2032
- #1981
- #2010
- #2043
- #2042
- #2038
- #2050
- #2041
- #2031
- #2061
- #1983
- #1628

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

## Summary by CodeRabbit

* **New Features**
* Added recipe-driven ONNX quantization and export for embedding and
reranking models.
* Added launcher support for inline commands, package requirements, and
configurable Docker users.
* Added QAD workflows, Nemotron data recipes, pruning, quantization, and
evaluation examples.
  * Added evaluation accuracy and pruning score thresholds.

* **Bug Fixes**
* Improved ONNX control-flow conversion, compressed NVFP4 export,
dataset loading, and multi-GPU DiffusionGemma handling.

* **Documentation**
* Updated CUDA 12/13 installation guidance and vLLM Blackwell deployment
instructions.

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

---------

Signed-off-by: vipandya <vipandya@nvidia.com>
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
Signed-off-by: Fridah-nv <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: weimingc <17592131+meenchen@users.noreply.github.com>
Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Signed-off-by: Meng Xin <mxin@nvidia.com>
Signed-off-by: Chenjie Luo <chenjiel@nvidia.com>
Signed-off-by: Chenjie Luo <108829653+cjluo-nv@users.noreply.github.com>
Signed-off-by: Juhi Mittal <juhim@nvidia.com>
Signed-off-by: Gwena Cunha <4861122+gcunhase@users.noreply.github.com>
Signed-off-by: Gwenaelle Cunha Sergio <gcunhasergio@nvidia.com>
Co-authored-by: vishalpandya1990 <vishalpandya1990@gmail.com>
Co-authored-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Wei-Ming Chen <17592131+meenchen@users.noreply.github.com>
Co-authored-by: Ajinkya Rasane <131806219+ajrasane@users.noreply.github.com>
Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: mxinO <164952785+mxinO@users.noreply.github.com>
Co-authored-by: Chenjie Luo <108829653+cjluo-nv@users.noreply.github.com>
Co-authored-by: Juhi Mittal <39641197+juhi10071998@users.noreply.github.com>
Co-authored-by: Gwena Cunha <4861122+gcunhase@users.noreply.github.com>
kevalmorabia97 added a commit that referenced this pull request Oct 6, 2026
### What does this PR do?

Type of change: new feature (dependency bump), bug fix, backward
breaking (DBRX removal)

Extends the supported transformers range to `>=4.57,<5.19` and moves
CI's `tf_latest` to 5.18 (the latest release). It also fixes everything
in 5.15–5.18 that breaks ModelOpt; each fix keeps 4.57–5.14 working.
Separately, it removes DBRX support, and the customized-model
quantization guide now uses Llama 4 as its example. Among other things,
the HF side can now load `glm5_next` (GLM-5.3-Flash, native since
5.16.1).

- **Pins:** the `pyproject.toml` `hf` extra, the "not tested" warning in
`modelopt/torch/__init__.py`, and `noxfile.py` `tf_latest` (`~=5.14.0` →
`~=5.18.0`).
- **HF tensor-parallel quantization (5.16 rewrote TP on DTensors,
#47579):**
- 5.16 removed the module-level `_hf_tp_plan` that ModelOpt used to
recognize TP-sharded linears. A model loaded with `tp_plan="auto"` was
therefore quantized as if unsharded: its forward failed on mixed
`Tensor`/`DTensor` inputs.
- Sharded linears are now recognized by a DTensor weight on the model's
TP mesh (`model._device_mesh`): `Shard(0)` is colwise and `Shard(1)` is
rowwise. Matching the mesh (by `==`) keeps FSDP2 shards out. The mesh is
found on any submodule, so a model held by a trainer, PEFT or a wrapper
still works, and ModelOpt warns if a TP mesh exists but no linear
matched.
- HF now installs its TP input/output transforms as an instance
`forward`, which `DynamicModule.convert` keeps as `_forward_pre_dm`.
`HFParallelLinear.forward` routes through it, and sets HF's
`_hf_quantized_needs_local_tp` so the quantized linear runs on this
rank's plain weight shard, in training as well.
- The weight-access dispatch in `core_utils.py` now keys on the layer's
own `enable_weight_access_and_writeback` instead of `_hf_tp_plan`.
- **DBRX support removed (internally agreed):** the DBRX quantization
plugin, its model spec, its unified-export preparation handler, the
TRT-LLM export branches, and the AutoQuantize rules for its rewritten
experts. This also drops the 5.0–5.14 vs 5.15+ expert-layout split that
5.15 would otherwise have needed. The customized-model quantization
guide now uses the shipped `Llama4TextExperts` plugin (fused `torch.bmm`
experts) as its example instead of DBRX. There is a Deprecations entry
in the changelog.
- **`TrainingArguments.warmup_ratio` removed (5.15, #46917):**
- `ModelOptArgParser` now accepts either spelling in YAML configs and
translates to whichever the installed transformers supports.
`warmup_ratio` becomes `warmup_steps` on 5.15+, where a value below 1 is
a ratio. A fractional `warmup_steps` becomes `warmup_ratio` on 4.x,
where `warmup_steps` is an int.
- The `llm_qat` train configs now use `warmup_steps`. They failed to
parse on 5.15+.
  - `examples/alpamayo/qad.py` picks the supported key.
- **Puzzletron Qwen3-VL (5.17, #48105):**
`Qwen3VLMoeVisionRotaryEmbedding` now takes the vision config instead of
`dim`, so the descriptor builds it from the config there. The old call
raised `AttributeError: 'int' object has no attribute
'rope_parameters'`.
- **Alpamayo:** the prompt cache is cropped with a negative count, since
positive absolute-size `crop()` calls are deprecated (#47720).
- **Liger eval in ModelOpt's trainers:** 5.15+ adds `skip_logits=True`
to eval inputs when `use_liger_kernel` is set.
- ModelOpt computes the fused (KD) loss itself from hidden states, and
its `compute_loss_func` makes the Trainer pop `labels`. So the student's
and the teacher's Liger forwards raised `skip_logits is True, but labels
and shift_labels are None`.
- This failed `llm_qat` QAT, QAD and QLoRA in CI. The flag is now
dropped in both paths.

**Checked, no change needed:**
- **T5 (#47014):** T5 now dispatches through `ALL_ATTENTION_FUNCTIONS`,
so it registers with the generic `_QuantAttention`. FP8 KV-cache scales
calibrate on 5.18, and `_T5QuantAttention` stays for 4.57–5.14.
- **Indexer layer types (#48974):** remapped to `indexed_attention`.
ModelOpt never compares these strings.
- **`min_pixels` / `max_pixels` (#49021):** ModelOpt passes them only to
`from_pretrained`, which is still supported.
- **No ModelOpt usage:** the removed mask functions,
`update_candidate_strategy`, and `use_mamba_kernels`.

### Usage

```bash
pip install -U "nvidia-modelopt[hf]"   # now resolves transformers 5.18
```

### Testing

All on this host (Python 3.13, torch 2.14). The 3.12 nox session can't
start here because the system Python has a libffi/`_ctypes` mismatch,
which is unrelated.
- **`nox -s "unit-3.13(torch_214, tf_latest)"` on 5.18, before the
fixes:** 4532 passed, 1 failed (`test_dbrx`, whose model is now
removed).
- With the fixes, `tests/unit/torch/quantization` +
`tests/unit/torch/opt` on 5.18: 1414 passed, 8 skipped.
- `tests/unit/torch/quantization/plugins/test_huggingface.py`: passes on
5.14.1 and 5.18.0.
- **`tests/gpu/torch/quantization/plugins/test_transformers_tp.py` (2
GPUs):** passes on 5.14.1, 5.16.1 and 5.18.0.
- It now also asserts that every sharded decoder linear is quantized as
a TP-aware layer.
- Without the fix it fails on 5.18 with `aten.mm.default got mixed
torch.Tensor and DTensor`.
- **`tests/examples/llm_qat/test_llm_qat.py` on 5.18 (2 GPUs):** QAT on
DDP, QAD on FSDP2, and QLoRA pass.
- QAT and QAD ran with `attn_implementation: sdpa` locally, because
`flash-attn` doesn't build on this host.
- Without the `skip_logits` fix, QAD on FSDP2 reproduces the CI error on
both ranks.
- **`test_transformers_tp` wrapped-model case:** fails with the old
top-level mesh lookup and passes with the fix, on 5.14.1 and 5.18.0.
- **After removing DBRX:** `tests/unit/torch` on 5.18: 3355 passed, 15
skipped. The `test_dbrx` cases are gone, the spec tests that used DBRX
now use `qwen3_5_moe`, and the DBRX cases in the export-registry test
are dropped.
- **Guide snippet:** on 5.18, with ModelOpt's own Llama4 plugin
unregistered, the guide's `_QuantLlama4TextExperts` inserts the same 4
quantizers on a tiny `Llama4TextExperts` and matches the shipped
plugin's FP8 output exactly.
- **Warmup keys:**
- New `test_yaml_warmup_spelling_follows_transformers` covers both
translation directions.
- Parsing `llm_qat/configs/train/qat_nvfp4.yaml` and a legacy
`warmup_ratio: 0.05` YAML through `llm_qat`'s `TrainingArguments` on
5.18 gives `warmup_steps 0.05` for both.
- `ARGUMENTS.md` regenerates unchanged. Its pre-commit hook couldn't run
on this host because the hook's `uv` env has no torch, so I generated it
manually and diffed.
- **Puzzletron:** on a tiny Qwen3-VL-MoE, `init_rotary_embedding`
reproduces the model's own vision `inv_freq` on both 5.14.1 and 5.18.0.
- **Alpamayo crop:** keeps exactly the prefill tokens on both 5.14.1 and
5.18.0.
- **Not run locally:** the full GPU and example suites, including the
Puzzletron GPU test. CI covers them with the new `tf_latest` pin.

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

- Is this change backward compatible?: ❌ DBRX is no longer supported.
Otherwise, behavior on transformers 4.57–5.14 is unchanged and 5.15–5.18
are newly supported. `llm_qat` configs move from `warmup_ratio` to
`warmup_steps`, but `ModelOptArgParser` still accepts `warmup_ratio` on
every version.
- 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?: ✅ Warmup-key translation, and
the TP test now asserts TP-aware conversion (also for a wrapped model).
- Did you update
[Changelog](https://github.com/NVIDIA/Model-Optimizer/blob/main/CHANGELOG.rst)?:
✅ A Deprecations entry for the DBRX removal. The upper-bound bump itself
gets none, as in #2050.
- Did you get Claude approval on this PR?: ❌

### Additional Information

`uv.lock` is left to the weekly relock job. Example-specific pins
(`examples/speculative_decoding`, `examples/puzzletron`,
`examples/windows/*`) are left as they are; they pin for their own
reasons.

Follow-up opportunities from the new releases, not in this PR:
- Real tiny `glm5_next` / `step3p7` models in the recipe tests, which
would need a skip on the 4.57 CI leg.
- HF-side KDA quantization (KimiLinear is native since 5.17).
- NemotronH Omni support in `hf_ptq`.
- Measuring `hf_ptq` calibration speed now that linear-attention kernels
are opt-in (#47630).

🤖 Generated with [Claude Code](https://claude.com/claude-code)


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

* **Compatibility**
  * Expanded supported Hugging Face Transformers versions to 4.57–5.18.
* Added compatibility with newer Transformers tensor-parallel layers and
Qwen3-VL vision embedding APIs.
* Improved compatibility with Liger fused-loss evaluation during
training and distillation.
* **Bug Fixes**
  * Improved handling of warmup settings across Transformers versions.
  * Corrected sequence cropping during Alpamayo quantization.
* **Breaking Changes**
* Removed built-in DBRX quantization and TensorRT-LLM export support.
DBRX quantization remains available in ModelOpt 0.47; custom plugin
support can be added.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants