Skip to content

Align the MXFP4 kernels version message with the version actually enforced - #47565

Closed
guptaishaan wants to merge 3 commits into
huggingface:mainfrom
guptaishaan:fix/47455-kernels-version-check
Closed

guptaishaan wants to merge 3 commits into
huggingface:mainfrom
guptaishaan:fix/47455-kernels-version-check

Conversation

@guptaishaan

@guptaishaan guptaishaan commented Jul 27, 2026 •

Copy link
Copy Markdown

CI

Fixes #47455

Problem. With kernels==0.16.0 installed, MXFP4 warns MXFP4 quantization requires the `kernels` package: `pip install kernels>=0.12.0` — but 0.16.0 is greater than 0.12.0, so the warning reads as a false positive.

Cause. The gate is is_kernels_available(), which enforces KERNELS_MIN_VERSION <= version < KERNELS_MAX_VERSION, i.e. 0.15.2 <= v < 0.16.0 (src/transformers/utils/import_utils.py:144-145, matching the kernels>=0.15.2,<0.16 pin in setup.py). So 0.16.0 is genuinely unsupported and the check is right — only the message is wrong. The 0.12.0 literal at src/transformers/quantizers/quantizer_mxfp4.py:131 and :147 went stale when the pin was bumped in #46039.

Fix. Both messages now derive from KERNELS_MIN_VERSION/KERNELS_MAX_VERSION and state both bounds, matching the wording already used in hub_kernels.py, deepgemm.py, finegrained_fp8.py and modeling_utils.py — quantizer_mxfp4.py was the only straggler. The pin itself is unchanged, per @vasqu's comment on the issue.

No string-comparison bug here: is_kernels_available (and is_triton_available) parse with packaging.version on both sides. Added a guard test anyway, since "0.9.0" >= "0.15.2" holds as a string comparison.

Tests. Bounds — below floor / at floor / at ceiling (the reported case) — plus the double-digit-minor case in tests/utils/test_import_utils.py; message-matches-check in tests/quantization/mxfp4/test_mxfp4.py, asserting on the constants rather than copied literals. The latter fails if the source change is reverted.

cc @vasqu @MekkCyber

Out of scope, noting it only: KERNELS_{MIN,MAX}_VERSION are still a hand-maintained copy of the setup.py pin, which drifted once before (#43753).

guptaishaan and others added 3 commits July 26, 2026 17:34
The MXFP4 warning and error hardcoded `pip install kernels>=0.12.0`, but the
gate is `is_kernels_available()`, which enforces
`KERNELS_MIN_VERSION <= version < KERNELS_MAX_VERSION` (0.15.2 / 0.16.0). The
literal went stale when the pin was bumped and told users a version the check
rejects is acceptable.

Derive both messages from the same constants the check uses, matching the
wording already used in `hub_kernels.py`, `deepgemm.py`, `finegrained_fp8.py`
and `modeling_utils.py`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… them

- `is_kernels_available` at, below and above the pinned bounds.
- A double-digit-minor case pinned to explicit bounds: `"0.9.0" >= "0.15.2"`
  holds as a string comparison but not as a version comparison.
- The MXFP4 warning and error quote `KERNELS_MIN_VERSION`/`KERNELS_MAX_VERSION`
  themselves, so the message cannot drift from the check again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: mxfp4

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 30247561441:2
Result: success | Jobs: 16 | Tests: 165,334 | Failures: 0 | Duration: 16h 3m

@Rocketknight1

Copy link
Copy Markdown
Member

No code agent PRs from first time contributors!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The kernel's version doesn't properly check.

2 participants