Skip to content

Changes in type annotations break downstream code #138478

@lw

Description

@lw

🐛 Describe the bug

xFormers just upgraded PyTorch to 2.5.0 and mypy in our CI started failing with these errors:

xformers/ops/unbind.py:28: error: Unsupported operand types for - ("int" and "SymInt")  [operator]
xformers/ops/unbind.py:28: note: Both left and right operands are unions
xformers/ops/unbind.py:44: error: Unsupported operand types for * ("int" and "SymInt")  [operator]
xformers/ops/unbind.py:44: note: Right operand is of type "int | SymInt"
xformers/ops/unbind.py:44: note: Left operand is of type "int | SymInt"

The relevant lines are
https://github.com/facebookresearch/xformers/blob/77c1da7fe5c9a25f613bd4045bb1da4856310aab/xformers/ops/unbind.py#L28
and
https://github.com/facebookresearch/xformers/blob/77c1da7fe5c9a25f613bd4045bb1da4856310aab/xformers/ops/unbind.py#L44

I'm surprised to see that SymInts don't support being added and/or multiplied with regular ints. Are we doing something wrong? Or is this a bug?

Versions

PyTorch 2.5.0.

cc @ezyang @malfet @xuzhao9 @gramster @chauhang @penguinwu @bobrenjc93

Metadata

Metadata

Assignees

Labels

module: dynamic shapesmodule: typingRelated to mypy type annotationsoncall: pt2triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions