Skip to content

[None][fix] compare library versions with packaging.version, not strings#16263

Open
lonexreb wants to merge 1 commit into
NVIDIA:mainfrom
lonexreb:fix/version-string-compare
Open

[None][fix] compare library versions with packaging.version, not strings#16263
lonexreb wants to merge 1 commit into
NVIDIA:mainfrom
lonexreb:fix/version-string-compare

Conversation

@lonexreb

@lonexreb lonexreb commented Jul 10, 2026

Copy link
Copy Markdown

Description

Three version gates compared __version__ strings with >=, which is lexicographic, not numeric:

  • tensorrt_llm/_torch/models/__init__.pytransformers.__version__ >= "4.45.1" (gates MllamaForConditionalGeneration registration)
  • tensorrt_llm/tools/multimodal_builder.pytransformers.__version__ >= '4.53.0'
  • tensorrt_llm/_torch/speculative/interface.pyflashinfer.__version__ >= "0.6.4"

Lexicographic comparison is wrong at version boundaries, e.g. "4.9.0" >= "4.45.1" is True (should be False) and "4.100.0" >= "4.53.0" is False (should be True).

Change

Use packaging.version.parse(...) for numeric comparison — the same pattern already used in _torch/modules/mamba/softplus.py and _torch/modules/fla/utils.py. Behavior is unchanged for currently-supported versions; this only corrects the edge cases.

Test

No dedicated test: these are import-time gates and the change is a standard packaging.version substitution with no behavior change for supported versions.

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility checks for Transformers and FlashInfer versions.
    • Ensured version comparisons correctly follow semantic versioning, including multi-digit releases.
    • Improved selection of multimodal attention behavior across supported Transformers versions.

transformers.__version__ / flashinfer.__version__ were compared with >=
against version strings, which is lexicographic (e.g. '4.9.0' >= '4.45.1'
is wrongly True, '4.100.0' >= '4.53.0' wrongly False). Use
packaging.version.parse for correct numeric comparison, matching the
pattern already used elsewhere in the repo.

Signed-off-by: lonexreb <reach2shubhankar@gmail.com>
@lonexreb lonexreb requested review from a team as code owners July 10, 2026 23:50
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c103299c-35b9-423b-8f3d-40938c173d34

📥 Commits

Reviewing files that changed from the base of the PR and between b4e7808 and 3742e58.

📒 Files selected for processing (3)
  • tensorrt_llm/_torch/models/__init__.py
  • tensorrt_llm/_torch/speculative/interface.py
  • tensorrt_llm/tools/multimodal_builder.py

📝 Walkthrough

Walkthrough

The pull request replaces direct string comparisons with packaging.version.parse() for Transformers and FlashInfer compatibility checks in model exports, speculative decoding, and multimodal builder initialization.

Changes

Semantic version gates

Layer / File(s) Summary
Parsed compatibility checks
tensorrt_llm/_torch/models/__init__.py, tensorrt_llm/_torch/speculative/interface.py, tensorrt_llm/tools/multimodal_builder.py
Version checks against Transformers 4.45.1, FlashInfer 0.6.4, and Transformers 4.53.0 now use semantic version parsing while preserving the existing conditional behavior.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the PR’s main change and uses the repository’s required [None][fix] format.
Description check ✅ Passed The description explains the bug, the fix, and test coverage; only the checklist section is not explicitly completed.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix/version-string-compare

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

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.

1 participant