Skip to content

Bump up torchao to 0.16.0#20338

Draft
DefTruth wants to merge 10 commits intosgl-project:mainfrom
xlite-dev:upgrade-torchao
Draft

Bump up torchao to 0.16.0#20338
DefTruth wants to merge 10 commits intosgl-project:mainfrom
xlite-dev:upgrade-torchao

Conversation

@DefTruth
Copy link
Copy Markdown
Contributor

@DefTruth DefTruth commented Mar 11, 2026

Bump up torchao to 0.16.0. After v0.15.0, torchao removed config functions like 'int4_weight_only'. We have to use the config class directly, e.g, 'Int4WeightOnlyConfig'. Reference: https://github.com/pytorch/ao/releases/tag/v0.15.0

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

cc @BBuf @mickqian @RubiaCx

@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Mar 11, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the torchao dependency to version 0.16.0. This update necessitated changes to the torchao_utils.py file to accommodate breaking API changes introduced in torchao v0.15.0, where quantization configuration functions were replaced by direct config classes. The code now includes a try-except block to maintain compatibility with both older and newer torchao versions, ensuring the application continues to function correctly with the updated library.

Highlights

  • Dependency Update: The torchao dependency has been updated from version 0.9.0 to 0.16.0 in pyproject.toml.
  • API Adaptation for torchao: Modified torchao_utils.py to handle breaking API changes in torchao versions 0.15.0 and later, specifically the removal of direct config functions in favor of config classes, by implementing a try-except block for imports.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • python/pyproject.toml
    • Updated torchao dependency from 0.9.0 to 0.16.0.
  • python/sglang/srt/layers/torchao_utils.py
    • Implemented a try-except block to import torchao quantization config functions or classes based on the installed torchao version.
    • Adapted import statements to use Float8DynamicActivationFloat8WeightConfig, Float8WeightOnlyConfig, Int4WeightOnlyConfig, and Int8DynamicActivationInt8WeightConfig as aliases for the older function names when torchao version is 0.15.0 or newer.
Activity
  • The pull request was created by DefTruth.
  • No specific review comments or further activity have been recorded yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request bumps the torchao dependency to version 0.16.0 and adapts the code to a breaking change in the torchao API. The change correctly uses a try-except block to handle different torchao versions. However, since the dependency is now pinned to 0.16.0, this backward compatibility is no longer needed and the code can be simplified. I've left a comment with a suggestion to remove the now-unnecessary compatibility code.

Comment thread python/sglang/srt/layers/torchao_utils.py Outdated
@mickqian
Copy link
Copy Markdown
Collaborator

cc @Fridge003 @AniZpZ for this

@mickqian
Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@mickqian
Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

@DefTruth DefTruth marked this pull request as draft March 19, 2026 13:24
@DefTruth
Copy link
Copy Markdown
Contributor Author

@mickqian Convert to draft pr. Because CI fails due to torchao dependence on mslk-cuda>=1.0.0, and mslk-cuda requires torch >=2.10, sglang currently relies on torch 2.9.1. Therefore, you need to wait for sglang to upgrade torch to 2.10 and above before upgrading torchao.

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

Labels

dependencies Pull requests that update a dependency file run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants