Skip to content

Reland PR #4040: Support Qwix quantization on NNX with cross-environment import compatibility#4198

Merged
copybara-service[bot] merged 1 commit into
mainfrom
fix/fp8_qwix
Jun 18, 2026
Merged

Reland PR #4040: Support Qwix quantization on NNX with cross-environment import compatibility#4198
copybara-service[bot] merged 1 commit into
mainfrom
fix/fp8_qwix

Conversation

@RexBearIU

@RexBearIU RexBearIU commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR relands the changes from PR #4040 ("Support Qwix quantization on NNX") which was previously merged and reverted.

To prevent import failures across different environments, this PR introduces a dual-compatible fallback import block for flax_util in src/maxtext/layers/quantizations.py.

Context & Why:

The original PR used from qwix._src import flax_util.
Due to a packaging layout discrepancy, different builds/distributions of the Qwix package even within the exact same version identifier (e.g., 0.1.6) present different internal path structures (some placing flax_util directly in qwix._src and others placing it under qwix._src.utils).

Using a single hardcoded path caused immediate compile/import errors depending on the specific package layout present in the target environment.

Solution:

We introduce a try-except fallback block:

# Support different packaging structures across environments even within the same Qwix version identifier (imports from _src.utils vs _src).
try:
  from qwix._src.utils import flax_util
except ImportError:
  from qwix._src import flax_util

This allows the codebase to compile and run correctly across environments with different packaging layouts of the Qwix package.

FIXES: #4040

Tests

The changes were verified by running the unit test suite in the local environment:

python3 -m pytest tests/unit/quantizations_test.py

Output: 8 passed, 16 skipped in 2.90s (0 failures).

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.56757% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/layers/nnx_wrappers.py 33.33% 10 Missing and 6 partials ⚠️
src/maxtext/layers/quantizations.py 83.33% 4 Missing and 2 partials ⚠️
src/maxtext/layers/nnx_decoders.py 50.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

Thank you Jacky!

@copybara-service copybara-service Bot merged commit 1432864 into main Jun 18, 2026
53 checks passed
@copybara-service copybara-service Bot deleted the fix/fp8_qwix branch June 18, 2026 17:31
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.

5 participants