Skip to content

upgrade torchao to 0.17.0#3569

Merged
winglian merged 8 commits into
mainfrom
torchao-0170
Apr 2, 2026
Merged

upgrade torchao to 0.17.0#3569
winglian merged 8 commits into
mainfrom
torchao-0170

Conversation

@winglian
Copy link
Copy Markdown
Collaborator

@winglian winglian commented Apr 1, 2026

Summary by CodeRabbit

Release Notes

  • Chores

    • Updated dependencies: torchao to 0.17.0 and mistral-common to 1.11.0
  • Improvements

    • Enhanced quantization configuration handling for improved compatibility with the latest library versions

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 1, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b9195b60-b161-48ec-a70b-8dd878f72ac9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR updates pinned dependencies in requirements.txt (torchao 0.16.0→0.17.0, mistral-common 1.10.0→1.11.0) and adapts the codebase to the new torchao API by updating import paths, replacing deprecated quantization config types, and reflecting changes in test assertions.

Changes

Cohort / File(s) Summary
Dependency Updates
requirements.txt
Bumped torchao from 0.16.0 to 0.17.0 and mistral-common from 1.10.0 to 1.11.0.
Torchao API Updates
src/axolotl/core/builders/base.py
Updated AdamWFp8 import from torchao.prototype.low_bit_optim to torchao.optim.adam to reflect new torchao module structure.
Quantization Config Adapter
src/axolotl/utils/quantization.py
Replaced deprecated Int8DynamicActivationInt4WeightConfig with Int8DynamicActivationIntxWeightConfig; updated NVFP4InferenceConfig to NVFP4WeightOnlyConfig for torchao ≥2.8.0; refactored config construction to use kwargs with explicit weight_dtype and conditional weight_granularity.
Test Updates
tests/e2e/test_quantization.py
Updated PTQ test config imports and assertions to expect Int8DynamicActivationIntxWeightConfig instead of deprecated int4-weight variant.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • SalmanMohammadi
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'upgrade torchao to 0.17.0' directly and clearly describes the main change across all modified files, which centers on upgrading the torchao dependency and adapting code to work with the new version.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch torchao-0170

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@winglian winglian added the scheduled_release This PR is slated for the upcoming release label Apr 1, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/axolotl/utils/quantization.py (1)

103-106: Consider adding test coverage for the weight_granularity parameter.

The new code path that sets weight_granularity=PerGroup(group_size=...) when group_size is provided (Lines 104-105) is not directly validated in the tests. Per tests/e2e/test_quantization.py:63-83, the ptq_config_test_cases entry for (int4, int8) uses group_size=None, and the test at Lines 117-128 only validates the returned type via isinstance().

While ptq_test_cases does include group_size=8 for this combination, it only validates the quantized tensor class, not the config's weight_granularity attribute. Consider adding a test case that verifies the PerGroup granularity is correctly set.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/axolotl/utils/quantization.py` around lines 103 - 106, Add a unit test
that covers the code path when group_size is provided by calling the same
factory that builds the Int8DynamicActivationIntxWeightConfig (the code that
currently sets kwargs = {"weight_dtype": torch.int4} and returns
Int8DynamicActivationIntxWeightConfig(**kwargs)), pass group_size=8 (or another
value), and assert that the returned config.weight_granularity is an instance of
PerGroup and that its group_size equals the value passed; this ensures the
PerGroup(weight_granularity=...) branch is exercised and validated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/axolotl/core/builders/base.py`:
- Around line 331-335: The import for AdamWFp8 is using the wrong module path;
inside the branch that checks self.cfg.optimizer == "ao_adamw_fp8" replace the
import statement so it imports AdamWFp8 from torchao.optim (i.e., use "from
torchao.optim import AdamWFp8"), leaving the rest of the block (setting
optimizer_cls = AdamWFp8 and updating optimizer_kwargs with adam_kwargs)
unchanged so optimizer_cls and optimizer_kwargs continue to work as before.

---

Nitpick comments:
In `@src/axolotl/utils/quantization.py`:
- Around line 103-106: Add a unit test that covers the code path when group_size
is provided by calling the same factory that builds the
Int8DynamicActivationIntxWeightConfig (the code that currently sets kwargs =
{"weight_dtype": torch.int4} and returns
Int8DynamicActivationIntxWeightConfig(**kwargs)), pass group_size=8 (or another
value), and assert that the returned config.weight_granularity is an instance of
PerGroup and that its group_size equals the value passed; this ensures the
PerGroup(weight_granularity=...) branch is exercised and validated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 65fbea7f-3aad-4d12-887e-953d06c75a8f

📥 Commits

Reviewing files that changed from the base of the PR and between 96ae8bd and c9ffee1.

📒 Files selected for processing (4)
  • requirements.txt
  • src/axolotl/core/builders/base.py
  • src/axolotl/utils/quantization.py
  • tests/e2e/test_quantization.py

Comment on lines 331 to 335
elif self.cfg.optimizer == "ao_adamw_fp8":
from torchao.prototype.low_bit_optim import AdamWFp8
from torchao.optim.adam import AdamWFp8

optimizer_cls = AdamWFp8
optimizer_kwargs.update(adam_kwargs)
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

What is the import path for AdamWFp8 in torchao 0.17.0?

💡 Result:

The import path for AdamWFp8 in torchao 0.17.0 is from torchao.optim import AdamWFp8.

Citations:


Fix incorrect import path for AdamWFp8 in torchao 0.17.0.

The import path should be from torchao.optim import AdamWFp8, not from torchao.optim.adam import AdamWFp8. Update line 332 to use the correct module path.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/axolotl/core/builders/base.py` around lines 331 - 335, The import for
AdamWFp8 is using the wrong module path; inside the branch that checks
self.cfg.optimizer == "ao_adamw_fp8" replace the import statement so it imports
AdamWFp8 from torchao.optim (i.e., use "from torchao.optim import AdamWFp8"),
leaving the rest of the block (setting optimizer_cls = AdamWFp8 and updating
optimizer_kwargs with adam_kwargs) unchanged so optimizer_cls and
optimizer_kwargs continue to work as before.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 62.92135% with 33 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/axolotl/monkeypatch/torchao_optim.py 60.00% 30 Missing ⚠️
src/axolotl/utils/quantization.py 75.00% 2 Missing ⚠️
src/axolotl/core/builders/base.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@winglian winglian mentioned this pull request Apr 1, 2026
Comment thread src/axolotl/monkeypatch/torchao_optim.py Outdated
import torch
from torch.utils._python_dispatch import return_and_correct_aliasing

logger = logging.getLogger(__name__)
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.

Use the axolotl logger and not this

@winglian
Copy link
Copy Markdown
Collaborator Author

winglian commented Apr 2, 2026

The upstream fixes for the ao 8bit and 4bit optimizers are here: pytorch/ao#4216, but we've patched the aten's in axolotl for now.

@winglian winglian merged commit 573726c into main Apr 2, 2026
15 of 19 checks passed
@winglian winglian deleted the torchao-0170 branch April 2, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scheduled_release This PR is slated for the upcoming release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants