Skip to content

pip: allow torch<2.12 and add amd/huggingfacenotorch extras (fixes AMD install clobber) - #7278

Closed
danielhanchen wants to merge 6 commits into
pipfrom
fix/pip-amd-extra
Closed

danielhanchen wants to merge 6 commits into
pipfrom
fix/pip-amd-extra

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

What

Two changes to the released (pip) pyproject.toml so AMD installs work from PyPI:

  1. Bump base torch>=2.4.0,<2.11.0 to <2.12.0.
  2. Add the amd and huggingfacenotorch extras (present on main, missing on the release branch).

Why the torch bump

AMD ROCm wheels are 2.11.0+rocm7.x. The old <2.11.0 cap rejects them, so:

  • a plain pip install unsloth on an AMD box, and
  • the Studio installer's unsloth install step (which runs after ROCm torch is placed),

both re-resolve torch down to 2.10.0 from PyPI, clobbering the ROCm build. Import then fails on c10.dll init (WinError 1114) - this is unsloth#7275 on 780M/gfx1103, and would hit every AMD arch on the same install path.

Bumping to <2.12.0 lets the already-installed 2.11.0+rocm satisfy the base constraint, so it is left in place (no clobber). torch 2.11 is already exercised on ROCm; discrete CUDA/CPU users simply gain access to 2.11.x. This is a global torch-resolution change, not AMD-only - calling that out explicitly.

Why the extras

amd pulls unsloth[huggingfacenotorch] (the HF training stack without torch/torchvision, so it never drags a PyPI torch over the ROCm one) plus ROCm-era bitsandbytes>=0.49.1. Copied verbatim from main; both extras are URL-free.

Notes

The branch was rebuilt directly on top of the pip release snapshot, so the diff is exactly one file (pyproject.toml, +26/-1). Verified with tomllib: base torch <2.12.0, amd present, huggingfacenotorch present and torch-free.

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

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.

Code Review

This pull request introduces two new dependency groups, huggingfacenotorch and amd, to the pyproject.toml configuration. The huggingfacenotorch group defines a comprehensive list of machine learning and utility packages, while the amd group bundles these dependencies along with platform-specific bitsandbytes requirements. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@danielhanchen danielhanchen changed the title Add amd extra to release pyproject so unsloth[amd] installs from PyPI pip: allow torch<2.12 and add amd/huggingfacenotorch extras (fixes AMD install clobber) Jul 21, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69195bb8dc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread pyproject.toml
"pyyaml",
"nest-asyncio",
]
huggingfacenotorch = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make the no-torch extra actually no-torch

For installs that request the new unsloth[huggingfacenotorch] or unsloth[amd] path, pip still installs this package's base [project].dependencies before adding extra dependencies; in this release snapshot those hard deps still include torch, torchvision, xformers, and triton on the relevant platforms. Since extras are additive and cannot subtract hard dependencies, the new no-torch/AMD extra does not provide a torch-free ROCm-safe install path in environments that do not already have the full matching ROCm stack installed.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

A PyPI extra is additive and cannot subtract the package's base deps (torch, torchvision, xformers, triton), so huggingfacenotorch cannot be torch-free by construction. The clobber this targets is handled by the torch cap bump (a pre-installed ROCm torch 2.11 satisfies <2.12.0 so it is not reinstalled), and the Studio installer consumes this extra with --no-deps. The extra mirrors main. Not actionable in pyproject.

Comment thread pyproject.toml
"diffusers",
"transformers>=4.51.3,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3,!=4.53.0,!=4.54.0,!=4.55.0,!=4.55.1,!=4.57.0,!=4.57.4,!=4.57.5,!=5.0.0,!=5.1.0,<=5.5.0",
"trl>=0.18.2,!=0.19.0,<=0.24.0",
"sentence-transformers",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Drop torch-transitive deps from the no-torch extra

Even if the hard base deps are fixed, this extra still cannot be used as a normal pip no-torch install because sentence-transformers is installed with its own dependencies and pulls torch transitively; the repo's studio/backend/requirements/no-torch-runtime.txt:1-3 explicitly uses --no-deps to avoid transitive torch resolution from packages including sentence-transformers. As a result, pip install unsloth[huggingfacenotorch] and the new amd extra can still resolve a PyPI torch over a preinstalled ROCm torch.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct that sentence-transformers pulls torch transitively, but a pip extra cannot express --no-deps (the installer's no-torch-runtime.txt does), and torch already comes from the base deps on this branch regardless. No minimal pyproject fix; the extra mirrors main.

Comment thread pyproject.toml Outdated
Comment on lines +140 to +141
"bitsandbytes>=0.49.1 ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64' or platform_machine == 'aarch64')",
"bitsandbytes>=0.49.1 ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid the known-broken AMD bitsandbytes fallback

For direct pip install 'unsloth[amd]' users this resolves the same PyPI bitsandbytes>=0.49.1 fallback that the installer only uses after warning that 4-bit decode is broken on ROCm; studio/install_python_stack.py:365-368 documents that bnb <=0.49.2 NaNs on every AMD GPU and uses a continuous-release wheel instead. Until the extra excludes the broken PyPI range or otherwise requires a fixed release, AMD users can get an install that succeeds but corrupts 4-bit generation/training results.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Genuine footgun but not fixable here: bitsandbytes <=0.49.2 has the AMD 4-bit NaN decode bug and the fix ships only in the non-PyPI continuous-release wheel, so a bare pip install 'unsloth[amd]' resolves 0.49.2. Excluding it makes the extra uninstallable (no working bnb on PyPI) and extras cannot reference a URL wheel; the supported AMD path (Studio installer + docs) force-reinstalls the fixed wheel post-install. The extra mirrors main, so this is not a regression from this PR.

danielhanchen and others added 3 commits July 21, 2026 16:18
The released torch>=2.4.0,<2.11.0 pin excludes the AMD 2.11.0+rocm wheel, so a
follow-up pip resolve downgrades torch to 2.10.0 and breaks the ROCm install
(#7275). Raise the ceiling to <2.12.0 so the ROCm 2.11 wheel is preserved, and
add an amd extra (pulls huggingfacenotorch, no torch pin) plus a torch-free
huggingfacenotorch extra so AMD users keep their ROCm torch.

[pre-commit.ci skip]
Resolves 85 conflicted files, all of which trace to the branch's
pre-commit.ci commit 18673a5 rather than to any change this PR authored.

Why the code side takes 'pip':

At the merge base the pip branch's [tool.ruff] table had no line-length,
so ruff-format fell back to its 88 column default and the pre-commit.ci
run reformatted 682 files to 88 columns. Since then 3455b45 ("pip: track
main's packaging and tooling config") added line-length = 100 to pip,
matching main. The bot commit is therefore churn produced under a tooling
config the base branch has since corrected, and re-running the hook on the
merged tree reproduces pip's 100 column formatting, not the branch's.

It also carries no behaviour: all 682 files it touches are .py, and every
one of them is AST identical before and after, so dropping the reformat
drops formatting only. The resolved tree is byte identical to pip
everywhere except pyproject.toml.

pyproject.toml (no textual conflict, but two semantic points):

- torch>=2.4.0,<2.11.0 -> <2.12.0 was made independently on both sides,
  by this PR in cd50f9e and on pip in b22b243, with the identical value.
  The merged file keeps <2.12.0, so neither side is undone. This also
  matches the exclusive _TORCH_CEILING="2.12.0" that #7256 introduces in
  install.sh, which expands to torch>=2.4,<2.12.0.

- The huggingfacenotorch and amd extras are this PR's remaining novel
  content; pip has neither. They are re-applied on top of pip's file.
  The one deliberate rewrite is huggingfacenotorch's unsloth_zoo floor,
  from >=2026.7.4 to >=2026.7.6: b22b243 raised every other unsloth_zoo
  pin on pip to 2026.7.6, and main's own huggingfacenotorch already says
  2026.7.6, so keeping 2026.7.4 would have reintroduced a stale floor that
  the base branch had just retired. The amd extra is unchanged from main.

Line level preservation was checked in both directions: all 90477 lines
pip added since the merge base survive, and all 26 lines this branch added
survive except the single unsloth_zoo floor noted above.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Jul 27, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ab9e7dbd4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pyproject.toml
"sentence-transformers",
]
amd = [
"unsloth[huggingfacenotorch]",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep base hardware dependencies out of AMD installs

When a user runs pip install 'unsloth[amd]', this self-reference cannot make the installation torch-free: extras are additive, so pip still processes the unconditional project.dependencies, including torch, torchvision, bitsandbytes, and the platform-selected xformers/triton packages. Consequently the new AMD path can still resolve hardware packages from the default index and replace or conflict with the preinstalled ROCm stack—the exact clobber this extra is intended to prevent. The no-torch installation needs to avoid those base requirements rather than reference another extra of the same distribution.

Useful? React with 👍 / 👎.

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.

The mechanism is right, extras are additive and cannot subtract base deps. The conclusion doesn't hold on this branch though. With the base cap at torch<2.12.0, a preinstalled ROCm torch 2.11.0+rocm7.x satisfies the base pin; xformers requires torch>=2.10, satisfied; and torchvision's exact torch==2.11.0 pin also matches, because PEP 440 ignores the local version segment when the specifier has none. I checked all three with packaging rather than by eye. Nothing re-resolves torch, so the clobber this extra targets does not reappear.

The change being described here means moving torch/torchvision/xformers/triton out of [project].dependencies entirely, which redefines pip install unsloth for every CUDA and CPU user. That isn't something a release-snapshot patch can do. The supported torch-free path remains the Studio installer, which consumes this extra with --no-deps. The extra mirrors main.

Comment thread pyproject.toml Outdated
Comment on lines +174 to +175
"bitsandbytes>=0.49.1 ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64' or platform_machine == 'aarch64')",
"bitsandbytes>=0.49.1 ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Install the ROCm-fixed bitsandbytes build

On a clean Linux or Windows AMD installation that uses 4-bit generation, this constraint selects the current PyPI 0.49.x build rather than the continuous ROCm build used by the repository's installers. install.sh:260-263 and studio/install_python_stack.py:391-393 explicitly document that bitsandbytes through 0.49.2 produces NaNs at decode shape on every AMD GPU and that the required GEMV fix is only in the post-0.49.2 continuous build until 0.50 reaches PyPI. Thus the new AMD extra can install successfully while producing corrupted 4-bit outputs.

Useful? React with 👍 / 👎.

@LeoBorcherding LeoBorcherding Jul 27, 2026 •

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.

Fixed in 1e3190e: the floor is now bitsandbytes>=0.50.0, which excludes the NaN-at-decode range outright.

bnb 0.50.0 shipped to PyPI on 2026-07-24, and PR bitsandbytes#1887's merge commit is an ancestor of the 0.50.0 tag, so the ROCm GEMV fix is in the release. The PyPI wheels also carry the ROCm binaries for the platforms these markers select: libbitsandbytes_rocm{64,70,71,714,72}.so on manylinux x86_64, libbitsandbytes_rocm{72,714}.dll on win_amd64. 0.49.1 already required Python >=3.10, same as 0.50.0, so the Python floor is unchanged.

One correction to the finding: on Windows the old floor could not silently corrupt 4-bit output, because bnb 0.49.2's win_amd64 wheel ships no ROCm binary at all. ROCm wheels for Windows first appear in 0.50.0. The corruption scenario is real on Linux, where 0.49.2 does ship rocm62-rocm72 and can load and NaN.

Verified both directions: the built wheel's METADATA emits >=0.50.0 on both marker lines with no 0.49.x surviving, and 0.50.0 itself runs clean on a gfx1200 with ROCm torch 2.11.0+rocm7.13.0 (NF4 and FP4, batches 1/2/8/64, all finite, batch=1 in line with the rest).

install.sh and studio/install_python_stack.py still use the continuous-release wheel. That condition ("drop the pin once bnb 0.50+ ships on PyPI") is now true, but it's installer runtime behaviour rather than packaging, so it's going in a separate PR.

Edited: the bnb references above were bare #NNNN, which GitHub autolinked to unrelated unslothai/unsloth issues rather than the bitsandbytes PRs. Now full URLs.

@LeoBorcherding LeoBorcherding self-assigned this Jul 27, 2026
bnb <= 0.49.2 NaNs at decode shape on every AMD GPU. The ROCm 4-bit GEMV
fix (bnb PR #1887) merged after 0.49.2 and its merge commit is an ancestor
of the 0.50.0 tag, so 0.50.0 is the first PyPI release carrying it.

The PyPI wheels ship the ROCm binaries for the platforms these markers
select: libbitsandbytes_rocm{64,70,71,714,72}.so on manylinux x86_64 and
libbitsandbytes_rocm{72,714}.dll on win_amd64. 0.49.1 already required
Python >=3.10, same as 0.50.0, so the Python floor is unchanged.
@LeoBorcherding

LeoBorcherding commented Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

Pushed 1e3190e2e: bumped the amd extra's bitsandbytes floor from >=0.49.1 to >=0.50.0.

bitsandbytes 0.50.0 landed on PyPI on 2026-07-24. The ROCm 4-bit GEMV fix (bitsandbytes#1887) merged 2026-03-09, after 0.49.2, and its merge commit is an ancestor of the 0.50.0 tag, so 0.50.0 is the first PyPI release carrying it. That release also adds the fused 4-bit SIMT GEMM on ROCm and marks AMD ROCm stable. The old >=0.49.1 floor could resolve 0.49.x, which NaNs at decode shape on AMD; the new floor excludes that range outright.

Checked the published wheels rather than assuming: manylinux_2_24_x86_64 ships libbitsandbytes_rocm{64,70,71,714,72}.so and win_amd64 ships libbitsandbytes_rocm{72,714}.dll, so the platforms these markers select are covered. 0.49.1 already declared requires_python >=3.10, same as 0.50.0, so the Python floor is unchanged.

Two checks, covering different halves.

Packaging, which is what this diff actually changes: built the wheel from this branch and read its METADATA. The amd extra emits bitsandbytes>=0.50.0 on both marker lines, no 0.49.x bitsandbytes requirement survives anywhere, and base torch stays <2.12.0,>=2.4.0. Against the base pin >=0.45.5,!=0.46.0,!=0.48.0 the intersection is >=0.50.0, and 0.50.0 is the newest release, so the resolution is forced.

Runtime, i.e. whether the thing the extra now asks for actually works: bitsandbytes 0.50.0 installed directly with --no-deps, so this exercises the library rather than the extra's resolution. ROCm torch 2.11.0+rocm7.13.0 on a Radeon RX 9060 XT (gfx1200), NF4 and FP4, compress_statistics on and off, batches 1/2/8/64. All 16 combinations produced finite output, relative error against an fp16 reference 0.090-0.096 (nf4) and 0.111-0.112 (fp4), with batch=1 in line with every other batch size rather than blowing up. gfx1200 is not on bnb's validated list for the ROCm SIMT GEMM (they cite gfx1100, gfx1201, gfx1151), so that is extra coverage.

One correction to the finding as written: on Windows the old floor could not produce silently corrupted 4-bit output, because bnb 0.49.2's win_amd64 wheel ships no ROCm binary at all. ROCm wheels for Windows first appear in 0.50.0. The corruption scenario is real on Linux, where 0.49.2 does ship rocm62-rocm72 and can load and NaN.

On the additive-extras P1: with the base cap at torch<2.12.0, a preinstalled ROCm torch 2.11.0+rocm7.x satisfies the base pin, xformers asks torch>=2.10, and torchvision's exact torch==2.11.0 pin also matches, since PEP 440 ignores the local version segment when the specifier has none. I checked all three with packaging rather than by eye. Nothing re-resolves torch, so the clobber this PR targets does not reappear. Making the extra genuinely torch-free would mean pulling torch/torchvision/xformers/triton out of [project].dependencies, which changes pip install unsloth for every CUDA and CPU user and is out of scope for a release-snapshot patch.

install.sh and studio/install_python_stack.py still pin the continuous-release_main wheel behind a "drop the pin once bnb 0.50+ ships on PyPI" note. That condition is now true, but it changes installer runtime behaviour rather than packaging metadata, so it is going in its own PR rather than widening this one.

On CI as of the previous head 5ab9e7dbd, all four red checks were pre-existing on base pip: Repo tests (CPU) fails on a UI font-scale contract test over studio frontend .tsx chart cards, and the three pip scan-packages jobs exit 1 because third-party findings exceed scripts/scan_packages_baseline.json. All four also fail on pip at 2bea7862e, which contains none of this PR's changes. Will re-check against the new head once this run finishes.

Edited: the bnb references above were bare #NNNN, which GitHub autolinked to unrelated unslothai/unsloth issues rather than the bitsandbytes PRs. Now full URLs.

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

@codex review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Jul 27, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e3190e2e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pyproject.toml
# bnb <= 0.49.2 NaNs at decode shape on every AMD GPU; the ROCm 4-bit GEMV
# fix (bnb PR #1887) first ships in 0.50.0, which is now on PyPI.
"bitsandbytes>=0.50.0 ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64' or platform_machine == 'aarch64')",
"bitsandbytes>=0.50.0 ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the ROCm bitsandbytes wheel on Windows

On Windows ROCm, this marker requests the public bitsandbytes>=0.50.0, but the installer explicitly notes that the PyPI wheel contains only CUDA DLLs and force-installs the ROCm prerelease instead (studio/install_python_stack.py:1180-1203,1691-1695). That ROCm wheel reports 0.50.0.dev0, which does not satisfy this final-release floor, so a subsequent pip install "unsloth[amd]" can replace it with the incompatible PyPI wheel and make bitsandbytes fail on AMD. The Windows dependency needs to retain the ROCm-specific wheel path rather than requesting the public release.

Useful? React with 👍 / 👎.

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.

The mechanism is right but the version string isn't, and the finding doesn't survive contact with the actual wheel.

I downloaded the artifact the installer pins (bitsandbytes-1.33.7.preview-py3-none-win_amd64.whl, the win_amd64 entry in _BNB_ROCM_PRERELEASE_URLS). Its metadata reports 0.50.1.dev0, not 0.50.0.dev0:

dist-info: bitsandbytes-0.50.1.dev0.dist-info
Name: bitsandbytes
Version: 0.50.1.dev0

0.50.1.dev0 is a dev release of the next patch, so it sorts above 0.50.0 and satisfies the floor. Checked with packaging rather than by eye: 0.50.1.dev0 → True, 0.50.0.dev0 (as this finding assumes) → False, 1.33.7rc0 (the filename reading) → True. Both readings of that deliberately-mismatched wheel keep it, so pip install 'unsloth[amd]' reports it already satisfied rather than replacing it. The Linux x86_64 prerelease is the same build and also reports 0.50.1.dev0, so that path behaves identically.

The 0.50.0.dev0 figure comes from the docstring at studio/install_python_stack.py:1185, which is stale: the continuous-release_main wheel is rolling and has since bumped.

The second premise is stale as well. install_python_stack.py:1694-1695 says the PyPI wheel ships only CUDA DLLs, which was true of 0.49.x. The published bitsandbytes-0.50.0-py3-none-win_amd64.whl ships libbitsandbytes_rocm714.dll and libbitsandbytes_rocm72.dll alongside the CUDA DLLs, so even in the counterfactual where a replacement did happen the result would still be ROCm-capable.

Both stale comments are going in the installer PR that drops the continuous-release pin, not here.

Comment thread pyproject.toml
"pyyaml",
"nest-asyncio",
]
huggingfacenotorch = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Make the no-torch extra actually omit torch

For a normal pip install "unsloth[huggingfacenotorch]"—and therefore [amd] through line 173—optional dependencies are additive, while [project].dependencies still mandates torch, torchvision, xformers, bitsandbytes, and triton (pyproject.toml:27-41). Several entries in this extra also require torch transitively; the repository's actual no-torch installer explicitly uses --no-deps to prevent that resolution (studio/backend/requirements/no-torch-runtime.txt:1-7). Consequently this newly exposed pip extra always resolves torch rather than providing the promised torch-free stack, so it cannot protect an absent or incompatible ROCm/MLX installation; the package needs a minimal base plus a no-deps or constraints-based installation path instead of an additive extra.

Useful? React with 👍 / 👎.

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.

Same point as the two P2s on 69195bb8 and the P1 on 5ab9e7db, so the same answer.

Extras are additive and cannot subtract [project].dependencies — agreed, and that is exactly why this extra is not a torch-free path for a bare pip install. It is not presented as one. The clobber in #7275 is fixed by the base cap moving to torch<2.12.0: a preinstalled ROCm torch 2.11.0+rocm7.x satisfies the base pin, xformers wants torch>=2.10, and torchvision's exact torch==2.11.0 pin matches too, since PEP 440 ignores the local version segment when the specifier has none. Verified all three with packaging. Nothing re-resolves torch.

The shape being suggested — a minimal base plus a no-deps or constraints-based path — means removing torch/torchvision/xformers/triton from [project].dependencies, which redefines pip install unsloth for every CUDA and CPU user. That is not something a release-snapshot patch can carry. The torch-free path stays the Studio installer, which consumes this extra with --no-deps.

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

Re: P1 "Preserve the ROCm bitsandbytes wheel on Windows"

The mechanism is sound but the version string is wrong, and the finding collapses on the real wheel.

I downloaded the exact artifact the installer pins (bitsandbytes-1.33.7.preview-py3-none-win_amd64.whl, the win_amd64 entry in _BNB_ROCM_PRERELEASE_URLS). Its metadata does not report 0.50.0.dev0:

dist-info: bitsandbytes-0.50.1.dev0.dist-info
Name: bitsandbytes
Version: 0.50.1.dev0

0.50.1.dev0 is a dev release of the next patch, so it sorts above 0.50.0 and satisfies the new floor. Checked with packaging rather than by eye:

installed version satisfies >=0.50.0
0.50.1.dev0 (actual) True
0.50.0.dev0 (as the finding assumes) False
1.33.7rc0 (filename reading) True

Both readings of that deliberately-mismatched wheel keep it. Whether pip records the dist-info version (0.50.1.dev0) or the filename version (1.33.7.preview → 1.33.7rc0), the installed distribution already satisfies >=0.50.0, so pip install 'unsloth[amd]' reports it satisfied and does not replace it. The Linux x86_64 prerelease wheel is the same build and also reports 0.50.1.dev0, so the Linux path behaves identically.

The 0.50.0.dev0 figure in the finding comes from the docstring at studio/install_python_stack.py:1185, which is stale: the continuous-release_main wheel is rolling and has since bumped. That is a real doc bug, just not one in this diff.

The second premise is also stale. The comment at install_python_stack.py:1694-1695 says the PyPI wheel "ships only CUDA DLLs, fails on ROCm", which was true of 0.49.x. The published bitsandbytes-0.50.0-py3-none-win_amd64.whl ships libbitsandbytes_rocm714.dll and libbitsandbytes_rocm72.dll alongside the CUDA DLLs. So even in the counterfactual where a replacement did happen, the result would still be ROCm-capable.

Both stale comments go in the installer PR with the continuous-release_main pin removal, not here.

Re: P1 "Make the no-torch extra actually omit torch"

Same finding as the two P2s on 69195bb8 and the P1 on 5ab9e7db; answering consistently. Extras are additive and cannot subtract [project].dependencies — agreed, and that is why this extra is not a torch-free install path for a bare pip install. It is not presented as one. The clobber in #7275 is fixed by the base cap moving to torch<2.12.0: a preinstalled ROCm torch 2.11.0+rocm7.x satisfies the base pin, xformers wants torch>=2.10, and torchvision's exact torch==2.11.0 pin matches too, since PEP 440 ignores the local version segment when the specifier has none. Verified all three with packaging. Nothing re-resolves torch.

The suggested change — a minimal base plus a no-deps or constraints path — means removing torch/torchvision/xformers/triton from [project].dependencies, redefining pip install unsloth for every CUDA and CPU user. That is not something a release-snapshot patch can carry. The torch-free path stays the Studio installer, which consumes this extra with --no-deps. The extra mirrors main.

Final review of 1e3190e2e

Diffed against base pip at 2bea7862e. The change is correct for what it does; nothing below blocks merge.

P2 — amd now diverges from main, and main still carries the broken floor. pyproject.toml:176-177. Compared both extras against main with tomllib: huggingfacenotorch is byte-identical, amd is not. This branch requires bitsandbytes>=0.50.0; main still requires >=0.49.1, so installing from a main checkout still resolves into the NaN-at-decode range on Linux ROCm. "Copied verbatim from main" no longer holds for amd. Main wants the same bump.

P2 — CI hard-depends on huggingfacenotorch existing, and nothing tests it. .github/workflows/security-audit.yml:231 and :824 do d["project"]["optional-dependencies"]["huggingfacenotorch"] with no fallback, and no test under tests/ references either extra. A test asserting both extras exist and that amd's bnb floor is >=0.50.0 would pin the thing this PR is for.

P3 — amd advertises a configuration that cannot work on linux aarch64. pyproject.toml:176. The marker includes aarch64, but bitsandbytes ships no ROCm binary in its aarch64 wheel at any version: 0.50.0's manylinux_2_24_aarch64 holds only libbitsandbytes_cpu.so plus CUDA variants. Not a regression, since >=0.49.1 was identical, and the extra mirrors main.

P3 — description is stale. Says bitsandbytes>=0.49.1 and "+26/-1"; head is >=0.50.0 and +27.

P3 — studio/backend/requirements/no-torch-runtime.txt:33 is commented "from [huggingfacenotorch] extras in pyproject.toml" but is hand-maintained and already differs, carrying safetensors>=0.4.3 which the extra does not.

Correction, and what this PR silently fixes

I previously wrote that the red pip scan-packages jobs "exit 1 because third-party findings exceed scripts/scan_packages_baseline.json" and "also fail on pip at 2bea7862e". Each statement is true alone, but together they mislead. On base those jobs never reach the scan: advisory audit, :: extras, :: hf-stack and :: studio all die on KeyError: 'huggingfacenotorch' at the workflow's inline Python, confirmed on runs 28951127835 (4373fdbae, 07-08), 29998087676 (b22b243e, 07-23) and 30272147669 (2bea7862e, 07-27) — four hits each, same four jobs. So those jobs have not executed on the release branch since at least 2026-07-08, and adding huggingfacenotorch here unblocks them. Their failure on this branch is newly revealed, not newly caused, and someone should decide whether the baseline needs regenerating for pip. Repo tests (CPU) is genuinely pre-existing and unrelated: a UI font-scale contract test over studio frontend .tsx chart cards.

Checks on 1e3190e2e are still queued (52 pending at time of writing); I will confirm against this head once they land.

Verdict

Correct as written. The open decision is main's amd floor, since leaving it at >=0.49.1 keeps the bug live on the development branch.

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

Updated the branch: merged base pip (2bea7862e) in, now at c254d82f9. Clean auto-merge, no conflicts. Re-verified after the merge — the diff against the new base is still exactly one file at +27, base torch stays >=2.4.0,<2.12.0, the amd extra emits bitsandbytes>=0.50.0 on both marker lines, and huggingfacenotorch is unchanged and torch-free.

Both P1s from the 1e3190e2e review are answered inline. Short version: the Windows one assumes the installer's ROCm wheel reports 0.50.0.dev0, but the published artifact reports 0.50.1.dev0, which clears the >=0.50.0 floor, so nothing replaces it. The no-torch one is the fourth restatement of a structural property of pip extras that this release-snapshot patch cannot change.

On CI, one correction lands in this PR's favour. advisory audit now passes. On base pip it died on KeyError: 'huggingfacenotorch', as it has since at least 2026-07-08 (runs 28951127835, 29998087676, 30272147669). Adding the extra unblocked it — confirmed on the 1e3190e2e run, not inferred.

pip scan-packages :: studio still fails, but for a different reason than I originally described: 296 finding(s), 148 suppressed by scripts/scan_packages_baseline.json, so the remainder trips SCAN_ENFORCE. That job scans studio/backend/requirements/studio.txt, which this PR does not touch, so it is baseline drift on the release branch rather than anything from this diff. Someone should regenerate the baseline for pip; that is its own change.

The remaining items from my review are all outside this diff and are going into separate PRs: main's amd floor still at >=0.49.1, a test pinning both extras, and the two stale installer comments (install_python_stack.py:1185, :1694-1695).

A fresh CI run is going on c254d82f9; I will confirm against that head once it lands.

The comment credited bnb PR #1887 as "the ROCm 4-bit GEMV fix" for every
AMD GPU. #1887 decouples blocksize from warp size and fixes a hardcoded
warp size of 32 in kgemm_4bit_inference_naive, which is a CDNA problem by
construction. The RDNA-side work is #1979 (fused 4-bit SIMT GEMM) and
#2012 (RDNA3/4 workgroup resonance). All three first ship in 0.50.0, so
the >=0.50.0 floor is unchanged; only the justification was wrong.
@LeoBorcherding

LeoBorcherding commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

Correcting a comment, not the floor. bitsandbytes>=0.50.0 is unchanged and still right.

The comment credited bitsandbytes#1887 as "the ROCm 4-bit GEMV fix" that makes bnb <=0.49.2 NaN "on every AMD GPU". Reading bitsandbytes#1887 rather than the changelog line: it decouples blocksize from warp size and fixes a hardcoded warp size of 32 in kgemm_4bit_inference_naive. A hardcoded 32 is wrong on CDNA (warp=64) and correct on RDNA (warp=32), so that half is CDNA-specific; its title says CDNA too. The RDNA-side work in the same release is bitsandbytes#1979, the fused 4-bit SIMT GEMM validated on gfx1100/gfx1201/gfx1151, and bitsandbytes#2012, the RDNA3/RDNA4 workgroup-count fix.

All three land in 0.50.0 and none are in 0.49.2, so the floor holds either way — 0.50.0 remains the first PyPI release with the complete ROCm 4-bit path. My gfx1200 run was exercising bitsandbytes#1979 and bitsandbytes#2012, not bitsandbytes#1887.

I should also be straight that I never verified the "every AMD GPU" part. I confirmed 0.50.0 works on gfx1200; I never ran 0.49.2 to watch it fail. That phrasing came from install_python_stack.py:391-393 and I repeated it. The new comment states what's checkable and no more.

The original phrasing still lives in install.sh:260-263 and install_python_stack.py:391-393. Those go in the installer PR that drops the continuous-release_main pin.

On sourcing, since bare numbers were the wrong way to cite this: all three are AMD's own ROCm work in bitsandbytes, authored by sstamenk, and the 0.50.0 release notes say it plainly: "Stability and performance improvements bring AMD ROCm support out of preview; it is now considered stable." That page is the citation I should have led with.

Edited: the bnb references above were bare #NNNN, which GitHub autolinked to unrelated unslothai/unsloth issues rather than the bitsandbytes PRs. Now full URLs.

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 910a657d80

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread pyproject.toml
"sentence-transformers",
]
amd = [
"unsloth[huggingfacenotorch]",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the AMD extra from pulling core torch deps

When a ROCm user installs the new unsloth[amd] extra as the AMD/no-torch path, this self-reference is still only additive: pip also installs the package's [project].dependencies, which already include torch, torchvision, xformers, and triton. That means the new AMD extra can still trigger normal PyPI torch-stack resolution instead of preserving the ROCm stack it is meant to protect; the torch-bearing deps need to be moved out of the base metadata or this path needs to use an explicit no-deps/no-torch install mechanism.

Useful? React with 👍 / 👎.

Comment thread pyproject.toml
"protobuf",
"sentencepiece>=0.2.0",
"datasets>=3.4.1,!=4.0.*,!=4.1.0,<4.4.0",
"accelerate>=0.34.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid resolving torch transitively in the no-torch extra

For installs that use this new huggingfacenotorch/amd extra to preserve a preinstalled ROCm torch, pip will still follow the dependencies of these HF packages; the repo's no-torch requirements explicitly install with --no-deps because packages like accelerate, peft, trl, and sentence-transformers trigger transitive torch resolution (studio/backend/requirements/no-torch-runtime.txt lines 1-3). As a result, even after removing direct torch entries from this extra, pip install unsloth[huggingfacenotorch] or unsloth[amd] can still ask the resolver for a PyPI torch and clobber the ROCm wheel.

Useful? React with 👍 / 👎.

danielhanchen added a commit that referenced this pull request Jul 29, 2026
…NaNs) (#7535)

* amd: require bitsandbytes>=0.50.0 in the amd extra

bnb <= 0.49.2 NaNs at decode shape on every AMD GPU. The ROCm 4-bit GEMV
fix (bnb PR #1887) first ships in 0.50.0, on PyPI since 2026-07-24, so the
old >=0.49.1 floor could still resolve the broken range.

Mirrors the same change made on the pip release branch in #7278.

* amd: cite the 0.50.0 ROCm work accurately in the bnb floor comment

The comment credited bnb PR #1887 as "the ROCm 4-bit GEMV fix" for every
AMD GPU. #1887 decouples blocksize from warp size and fixes a hardcoded
warp size of 32 in kgemm_4bit_inference_naive, which is a CDNA problem by
construction. The RDNA-side work is #1979 (fused 4-bit SIMT GEMM) and
#2012 (RDNA3/4 workgroup resonance). All three first ship in 0.50.0, so
the >=0.50.0 floor is unchanged; only the justification was wrong.

* amd: raise the installer bitsandbytes fallback floors to 0.50.0

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* amd: stop reporting the bitsandbytes PyPI fallback as broken

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tighten AMD bnb floor comments

* Keep the amd extra citation and the AMD install guide reference

* amd: do not promise aarch64 a ROCm 4-bit backend it never gets

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* amd: fall back to the PyPI bitsandbytes floor on Windows ROCm too

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Daniel Han <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen added a commit that referenced this pull request Sep 15, 2026
…re (#7536)

* amd: require bitsandbytes>=0.50.0 in the amd extra

bnb <= 0.49.2 NaNs at decode shape on every AMD GPU. The ROCm 4-bit GEMV
fix (bnb PR #1887) first ships in 0.50.0, on PyPI since 2026-07-24, so the
old >=0.49.1 floor could still resolve the broken range.

Mirrors the same change made on the pip release branch in #7278.

* tests: pin the amd/huggingfacenotorch extras and name the audit failure

security-audit.yml builds its hf-stack scan set by indexing
[huggingfacenotorch] out of pyproject.toml with no guard. The pip release
branch never had that extra, so advisory audit and the three pip
scan-packages jobs died on a bare KeyError from at least 2026-07-08 to
2026-07-27 without anyone reading it as a missing extra.

Add a contract test for both extras (existence, torch-free, bnb floor
excludes the NaN-at-decode range) plus a check that every extra the
workflow indexes actually exists, and give the workflow a message that
names the problem instead of a raw traceback.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* amd: cite the 0.50.0 ROCm work accurately in the bnb floor comment

The comment credited bnb PR #1887 as "the ROCm 4-bit GEMV fix" for every
AMD GPU. #1887 decouples blocksize from warp size and fixes a hardcoded
warp size of 32 in kgemm_4bit_inference_naive, which is a CDNA problem by
construction. The RDNA-side work is #1979 (fused 4-bit SIMT GEMM) and
#2012 (RDNA3/4 workgroup resonance). All three first ship in 0.50.0, so
the >=0.50.0 floor is unchanged; only the justification was wrong.

* tests: match the corrected bnb 0.50.0 justification

Drops the unverified "NaNs on every AMD GPU" phrasing and the single-PR
attribution from the test's comments and assertion message. The floor
itself is unchanged.

* Let the torchcodec audit contract read the guarded extra lookup

test_security_audit_covers_every_installable_torchcodec_line asserts that both
halves of security-audit.yml index the audio-torch211 extra, by counting the
literal subscript. Routing the lookups through the guarded extra() helper drops
that count to zero and fails a test that is really about coverage, not spelling.

Count either shape. A lookup that names a group the workflow no longer indexes
still fails the assertion, which is what it is there to catch.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tighten the comments this change adds for PR #7536

* Check the extras guards structurally with an AST walk for PR #7536

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Parse the unquoted python heredocs in the guard test too for PR #7536

* Read extra names structurally and run the contract when the audit workflow changes for PR #7536

* Check the whole bitsandbytes floor and require a KeyError handler in the guard test for PR #7536

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: danielhanchen <[email protected]>
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…re (unslothai#7536)

* amd: require bitsandbytes>=0.50.0 in the amd extra

bnb <= 0.49.2 NaNs at decode shape on every AMD GPU. The ROCm 4-bit GEMV
fix (bnb PR unslothai#1887) first ships in 0.50.0, on PyPI since 2026-07-24, so the
old >=0.49.1 floor could still resolve the broken range.

Mirrors the same change made on the pip release branch in unslothai#7278.

* tests: pin the amd/huggingfacenotorch extras and name the audit failure

security-audit.yml builds its hf-stack scan set by indexing
[huggingfacenotorch] out of pyproject.toml with no guard. The pip release
branch never had that extra, so advisory audit and the three pip
scan-packages jobs died on a bare KeyError from at least 2026-07-08 to
2026-07-27 without anyone reading it as a missing extra.

Add a contract test for both extras (existence, torch-free, bnb floor
excludes the NaN-at-decode range) plus a check that every extra the
workflow indexes actually exists, and give the workflow a message that
names the problem instead of a raw traceback.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* amd: cite the 0.50.0 ROCm work accurately in the bnb floor comment

The comment credited bnb PR unslothai#1887 as "the ROCm 4-bit GEMV fix" for every
AMD GPU. unslothai#1887 decouples blocksize from warp size and fixes a hardcoded
warp size of 32 in kgemm_4bit_inference_naive, which is a CDNA problem by
construction. The RDNA-side work is unslothai#1979 (fused 4-bit SIMT GEMM) and
unslothai#2012 (RDNA3/4 workgroup resonance). All three first ship in 0.50.0, so
the >=0.50.0 floor is unchanged; only the justification was wrong.

* tests: match the corrected bnb 0.50.0 justification

Drops the unverified "NaNs on every AMD GPU" phrasing and the single-PR
attribution from the test's comments and assertion message. The floor
itself is unchanged.

* Let the torchcodec audit contract read the guarded extra lookup

test_security_audit_covers_every_installable_torchcodec_line asserts that both
halves of security-audit.yml index the audio-torch211 extra, by counting the
literal subscript. Routing the lookups through the guarded extra() helper drops
that count to zero and fails a test that is really about coverage, not spelling.

Count either shape. A lookup that names a group the workflow no longer indexes
still fails the assertion, which is what it is there to catch.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tighten the comments this change adds for PR unslothai#7536

* Check the extras guards structurally with an AST walk for PR unslothai#7536

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Parse the unquoted python heredocs in the guard test too for PR unslothai#7536

* Read extra names structurally and run the contract when the audit workflow changes for PR unslothai#7536

* Check the whole bitsandbytes floor and require a KeyError handler in the guard test for PR unslothai#7536

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: danielhanchen <[email protected]>
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.

2 participants