Skip to content

requirements: relax torch~=2.6.0 to torch>=2.6.0 for convert_hf_to_gguf#23503

Merged
CISC merged 6 commits into
ggml-org:masterfrom
adityasingh2400:fix-torch-version-pin-23408
May 23, 2026
Merged

requirements: relax torch~=2.6.0 to torch>=2.6.0 for convert_hf_to_gguf#23503
CISC merged 6 commits into
ggml-org:masterfrom
adityasingh2400:fix-torch-version-pin-23408

Conversation

@adityasingh2400
Copy link
Copy Markdown
Contributor

Fixes #23408.

The ~=2.6.0 operator means >=2.6.0, <2.7.0, which fails to resolve on PyPI for some platform/CPython combinations where a 2.6.x wheel is not present. The accompanying comment already says 'PyTorch 2.6.0 or later', so the looser >=2.6.0 matches the documented intent and unblocks pip install -r requirements/requirements-convert_hf_to_gguf.txt.

The ~=2.6.0 operator resolves to >=2.6.0, <2.7.0, which fails on
PyPI for platform/CPython combinations where 2.6.x is not present.
The accompanying comment already says 'PyTorch 2.6.0 or later', so
the looser >=2.6.0 matches the documented intent and unblocks
pip install -r requirements/requirements-convert_hf_to_gguf.txt.

Fixes ggml-org#23408
@adityasingh2400 adityasingh2400 requested a review from CISC as a code owner May 21, 2026 23:21
@github-actions github-actions Bot added the python python script changes label May 22, 2026
@CISC
Copy link
Copy Markdown
Member

CISC commented May 22, 2026

The pinning was by design, however we should bump it now due to various compatibility reasons, possibly to 2.11.0.

@adityasingh2400
Copy link
Copy Markdown
Contributor Author

Bumped the pin to torch>=2.11.0 in 05935c9 per your suggestion. Updated the comment to note the bump while preserving the original Embedding Gemma context. Let me know if you would prefer a different operator (~=2.11.0 to keep major-version pinning) or a different floor.

Comment thread requirements/requirements-convert_hf_to_gguf.txt Outdated
@taronaeo
Copy link
Copy Markdown
Member

FYI we started pinning package versions ever since the LiteLLM supply-chain attack. You may wish to read more about our security and preventative measures here: #20954

We will not allow the use of the >= range operator without an upper limit.

@adityasingh2400
Copy link
Copy Markdown
Contributor Author

Understood, thanks for the context on #20954. I switched the pin to torch==2.11.0 in 527a078 to match the project policy and the rest of the file (transformers==5.5.1, etc). The s390x nightly line is left as is since it has no upstream release to pin against.

Copy link
Copy Markdown
Member

@taronaeo taronaeo left a comment

Choose a reason for hiding this comment

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

Might need to update ggml-org/ggml's requirements.txt as well since it follows llama.cpp.

@CISC
Copy link
Copy Markdown
Member

CISC commented May 22, 2026

Might need to update ggml-org/ggml's requirements.txt as well since it follows llama.cpp.

Oh, right. We should look into moving the lower end of numpy to 2.x as well, but let's see how this goes first. :)

@CISC
Copy link
Copy Markdown
Member

CISC commented May 23, 2026

tools/mtmd/requirements.txt needs to be updated too.

@adityasingh2400
Copy link
Copy Markdown
Contributor Author

Pushed f851ecd to bump tools/mtmd/requirements.txt to torch==2.11.0 and torchvision==0.26.0, with the s390x nightly carve-out so it stays consistent with the main requirements file.

@CISC
Copy link
Copy Markdown
Member

CISC commented May 23, 2026

LOL, CI didn't like that, wonder why it doesn't trigger on transformers?

The check_requirements script flags '==' on lines in files matched by
*/**/requirements*.txt. Append the documented suppression comment to the
pinned torch and torchvision lines (and to the s390x platform marker lines)
so the check passes while keeping the pins required by project policy.
@CISC
Copy link
Copy Markdown
Member

CISC commented May 23, 2026

There's also this, though not sure why that changed:
https://github.com/ggml-org/llama.cpp/actions/runs/26333317550/job/77523074728?pr=23503

@adityasingh2400
Copy link
Copy Markdown
Contributor Author

Looked at the failing type-check. The error is in examples/model-conversion/scripts/embedding/run-original-model.py:67:

config = model[0].auto_model.config

ty now reports model[0] as Tensor | Module and Tensor has no auto_model. The line itself was not touched by this PR, but the new torch wheels carry stricter stubs which is why the error showed up only after the bump.

Two options I can see:

  1. Land a small follow-up here that pulls model[0] into a local, asserts it is a Module, then reads auto_model. About 3 lines.
  2. Add a targeted ignore for the line and open a separate issue to type it properly.

Happy to push either, just want to confirm you would rather see this fixed inline on this PR than punted to a follow-up. The transformers job not triggering on its own bump looks like a path-filter quirk in the workflow, I can dig into that separately if useful.

@CISC
Copy link
Copy Markdown
Member

CISC commented May 23, 2026

ty now reports model[0] as Tensor | Module and Tensor has no auto_model. The line itself was not touched by this PR, but the new torch wheels carry stricter stubs which is why the error showed up only after the bump.

Yeah, noticed, wonder why it would be typed that way?

2. Add a targeted ignore for the line and open a separate issue to type it properly.

Do that, behavior should be unchanged, so this is something that should be fixed separately if it's an actual issue.

The transformers job not triggering on its own bump looks like a path-filter quirk in the workflow, I can dig into that separately if useful.

Yes please.

With torch 2.11.0 stubs, nn.Sequential.__getitem__ now returns
Tensor | Module rather than Module, so model[0].auto_model fails ty
on the SentenceTransformer code path. The runtime behavior is
unchanged because SentenceTransformer always wraps a Module at
index 0. Adding a targeted unresolved-attribute ignore keeps the
type-check green without altering behavior. A follow-up issue
tracks typing the variable explicitly.
@adityasingh2400
Copy link
Copy Markdown
Contributor Author

Pushed 6fca63c with the targeted ignore on examples/model-conversion/scripts/embedding/run-original-model.py:67. Filed #23576 to track typing the variable explicitly so the ignore can be removed.

On the path-filter question: the python-type-check workflow already watches */requirements.txt and **.py, so the transformers 5.5.1 bump in #21617 did trigger the workflow and the type-check job ran green. What changed here is the content of the torch stubs, not whether the workflow fires. The transformers 5.5.1 bump did not touch torch, so nn.Sequential.getitem kept returning Module and the SentenceTransformer line stayed quiet. Bumping to torch 2.11.0 swapped that signature to Tensor | Module, which is the first time the existing line surfaced an error. So the workflow path filter is fine, the trigger you may have wanted is some kind of stub-aware run on dependency bumps, which I do not think is easy to wire up generically. Let me know if you want me to file a separate issue to track that too.

@CISC
Copy link
Copy Markdown
Member

CISC commented May 23, 2026

On the path-filter question: the python-type-check workflow already watches */requirements.txt and **.py, so the transformers 5.5.1 bump in #21617 did trigger the workflow and the type-check job ran green.

It's not the type-check that fails, but check-requirements, and it should have failed for that bump as well.

What changed here is the content of the torch stubs, not whether the workflow fires. The transformers 5.5.1 bump did not touch torch, so nn.Sequential.getitem kept returning Module and the SentenceTransformer line stayed quiet. Bumping to torch 2.11.0 swapped that signature to Tensor | Module, which is the first time the existing line surfaced an error.

Well, why did the signature change, and is that a potential issue?

@CISC CISC merged commit c0c7e14 into ggml-org:master May 23, 2026
6 of 7 checks passed
kashif pushed a commit to kashif/llama.cpp that referenced this pull request May 23, 2026
* requirements: relax torch~=2.6.0 to torch>=2.6.0 for convert_hf_to_gguf

The ~=2.6.0 operator resolves to >=2.6.0, <2.7.0, which fails on
PyPI for platform/CPython combinations where 2.6.x is not present.
The accompanying comment already says 'PyTorch 2.6.0 or later', so
the looser >=2.6.0 matches the documented intent and unblocks
pip install -r requirements/requirements-convert_hf_to_gguf.txt.

Fixes ggml-org#23408

* requirements: bump torch floor to 2.11.0 per maintainer

* requirements: pin torch to ==2.11.0 per project policy

* requirements: pin mtmd torch and torchvision to 2.11.0/0.26.0 per project policy

* requirements: suppress check_requirements pin warning on mtmd

The check_requirements script flags '==' on lines in files matched by
*/**/requirements*.txt. Append the documented suppression comment to the
pinned torch and torchvision lines (and to the s390x platform marker lines)
so the check passes while keeping the pins required by project policy.

* ty: silence Tensor/Module union check on model[0].auto_model

With torch 2.11.0 stubs, nn.Sequential.__getitem__ now returns
Tensor | Module rather than Module, so model[0].auto_model fails ty
on the SentenceTransformer code path. The runtime behavior is
unchanged because SentenceTransformer always wraps a Module at
index 0. Adding a targeted unresolved-attribute ignore keeps the
type-check green without altering behavior. A follow-up issue
tracks typing the variable explicitly.
carlosfundora pushed a commit to carlosfundora/llama.cpp-1-bit-turbo that referenced this pull request May 24, 2026
* requirements: relax torch~=2.6.0 to torch>=2.6.0 for convert_hf_to_gguf

The ~=2.6.0 operator resolves to >=2.6.0, <2.7.0, which fails on
PyPI for platform/CPython combinations where 2.6.x is not present.
The accompanying comment already says 'PyTorch 2.6.0 or later', so
the looser >=2.6.0 matches the documented intent and unblocks
pip install -r requirements/requirements-convert_hf_to_gguf.txt.

Fixes ggml-org#23408

* requirements: bump torch floor to 2.11.0 per maintainer

* requirements: pin torch to ==2.11.0 per project policy

* requirements: pin mtmd torch and torchvision to 2.11.0/0.26.0 per project policy

* requirements: suppress check_requirements pin warning on mtmd

The check_requirements script flags '==' on lines in files matched by
*/**/requirements*.txt. Append the documented suppression comment to the
pinned torch and torchvision lines (and to the s390x platform marker lines)
so the check passes while keeping the pins required by project policy.

* ty: silence Tensor/Module union check on model[0].auto_model

With torch 2.11.0 stubs, nn.Sequential.__getitem__ now returns
Tensor | Module rather than Module, so model[0].auto_model fails ty
on the SentenceTransformer code path. The runtime behavior is
unchanged because SentenceTransformer always wraps a Module at
index 0. Adding a targeted unresolved-attribute ignore keeps the
type-check green without altering behavior. A follow-up issue
tracks typing the variable explicitly.

(cherry picked from commit c0c7e14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples python python script changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

installing python requirements fails because of strict torch version

3 participants