Skip to content

remove pytroch restriction - #1768

Merged
manuelgloeckler merged 3 commits into
mainfrom
remove_pytorch_upper_bound
Feb 18, 2026
Merged

manuelgloeckler merged 3 commits into
mainfrom
remove_pytorch_upper_bound

Conversation

@manuelgloeckler

@manuelgloeckler manuelgloeckler commented Feb 17, 2026 •

Copy link
Copy Markdown
Contributor

This finally removes dependency upper bound on torch fixing #1380.

The problem is:

  1. Tensor | Module union types are more strictly distinguished by torch.
  2. +,-,... operator stubs between a Tensor and a Module are no longer supported by stubs.

This new Tensor | Module divide makes it very hard to type (e.g because buffers or parameters or Modules). This was introduce in torch 2.6 and will likely stay like this, so we have to adapt to ignore this.

@codecov

codecov Bot commented Feb 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@0a39118). Learn more about missing BASE report.
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1768   +/-   ##
=======================================
  Coverage        ?   86.87%           
=======================================
  Files           ?      141           
  Lines           ?    12644           
  Branches        ?        0           
=======================================
  Hits            ?    10985           
  Misses          ?     1659           
  Partials        ?        0           
Flag Coverage Δ
fast 83.30% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

@manuelgloeckler

Copy link
Copy Markdown
Contributor Author

So there are two options:

  • (i) disable the check globally (as done here)
  • (ii) ignoring every line (and future line)

The first option has the disadvantages as it allows "False-Positives" (i.e. torch unrelated thinks). The (ii) has the advantages that we need to add 70 pyright ignores across 10 files (+ every future torch line would also be type ignored). Do you have any preference for either? @janfb

The only other alternative I know of is writing a custom torch ".pyi" (stubs) file, but this seems like too much.

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

Thanks @manuelgloeckler for looking into this!

I am fine with option (i), but should add a comment in pyproject.toml for reference.

Comment thread pyproject.toml Resolved
@manuelgloeckler
manuelgloeckler merged commit b546366 into main Feb 18, 2026
9 checks passed
mhusnain-tech added a commit to mhusnain-tech/sbi that referenced this pull request Feb 19, 2026
This PR updates the pyproject.toml to align with recent changes in the repository. 
Main changes include:
- Cleaned up Pyright configuration by removing redundant 'false' flags for torch-related issues.
- Updated project metadata and classifiers for better consistency.
- Standardized dependency formatting.

This follows the work initiated in PR sbi-dev#1768 to handle Torch 2.5+ type-stub issues more cleanly.
@manuelgloeckler manuelgloeckler mentioned this pull request Feb 27, 2026
@janfb
janfb deleted the remove_pytorch_upper_bound branch April 9, 2026 10:22
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