Skip to content

build(deps): unpin torch and remove torchvision from CPU requirements#2848

Open
pctablet505 wants to merge 1 commit into
keras-team:masterfrom
pctablet505:ws0-4-torchvision-pin-2026-07-19
Open

build(deps): unpin torch and remove torchvision from CPU requirements#2848
pctablet505 wants to merge 1 commit into
keras-team:masterfrom
pctablet505:ws0-4-torchvision-pin-2026-07-19

Conversation

@pctablet505

@pctablet505 pctablet505 commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Problem

The CPU torch CI leg was resolving a CUDA-build torch from PyPI alongside a CPU-build torchvision from the PyTorch extra index, causing an ABI mismatch:

RuntimeError: operator torchvision::nms does not exist

This also broke the lazy Qwen2ForCausalLM import from transformers at collection time.

Fix

Remove the torchvision dependency entirely and leave torch unpinned in requirements.txt. The Keras Hub test suite does not need torchvision, so dropping it avoids the ABI mismatch without requiring a pinned matched pair.

Only the CPU leg (requirements.txt) changes; the CUDA requirements file is untouched.

@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 updates requirements.txt to pin torch and torchvision to specific versions. However, the specified versions (2.13.0 and 0.28.0) do not exist. The reviewer pointed out this issue, identifying it as hallucinated 'AI slop' in violation of the repository style guide, and suggested using valid, existing versions such as torch==2.6.0 and torchvision==0.21.0.

Comment thread requirements.txt Outdated
Comment on lines +8 to +9
torch==2.13.0
torchvision==0.28.0

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.

critical

The specified versions torch==2.13.0 and torchvision==0.28.0 do not exist. PyTorch's latest stable release is 2.6.0 (with torchvision 0.21.0). This appears to be hallucinated 'AI slop' (violating Repository Style Guide Rule 2). Please use a valid, existing matched pair of PyTorch and torchvision versions, such as torch==2.6.0 and torchvision==0.21.0.

torch==2.6.0
torchvision==0.21.0
References
  1. Rule 2: Call out 'AI Slop' - Actively look for and identify 'AI slop'—generic, overly verbose, or hallucinated code that lacks context or violates best practices. (link)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is Gemini hallucinated and spitting wrong facts, even the CI logs show it got installed and passed the tests.
image

@pctablet505
pctablet505 marked this pull request as ready for review July 19, 2026 09:12
@laxmareddyp

Copy link
Copy Markdown
Collaborator

Hi @pctablet505 , Thanks for the PR..!

This was always a latent issue.I would prefer not to hard-pin torch and torch vision, as it creates an ongoing maintenance burden for every future PyTorch release.
The CI only crashes because newer transformers versions check for torchvision, triggering a broken C++ extension load due to pip version mismatches.
Instead of pinning, let's just remove torchvision from requirements.txt entirely, since our only usage is a lazy, safely-guarded import in other models such as SAM3 . This makes us to zero future maintenance.

@laxmareddyp

Copy link
Copy Markdown
Collaborator

@pctablet505 Please resolve the conflicts and as i mentioned earlier no hard pinning for torch version. Thanks

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

LGTM, Thanks..!

@pctablet505 pctablet505 changed the title Pin torchvision to matched torch version to fix CPU CI collection (torchvision::nms) build(deps): unpin torch and remove torchvision from CPU requirements Jul 22, 2026
@pctablet505
pctablet505 force-pushed the ws0-4-torchvision-pin-2026-07-19 branch from 728de37 to 188a3c3 Compare July 22, 2026 15:11
@laxmareddyp

laxmareddyp commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

@pctablet505 ,

Apologies , my earlier suggestion to remove torchvision. I missed to check the SAM3 test files that run in the torch CI job. These tests exercise the full model forward pass which hits roi_align.py: import torchvision at runtime. So torchvision is a hard runtime dependency for SAM3 on the torch backend, not just an optional one.

Your original approach of pinning matched versions is the correct fix( We need to keep eye on to update these hard pinned versions time to time)

Thanks..!

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