-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
release numpy <2 pin, and support python 3.13 #719
base: master
Are you sure you want to change the base?
release numpy <2 pin, and support python 3.13 #719
Conversation
pyproject.toml
Outdated
@@ -44,7 +44,7 @@ json = [ | |||
"pandas", | |||
"pydantic", | |||
"pint", | |||
"torch", | |||
"torch", # need torch>=2.3.0 for numpy 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems only torch>=2.3.0
works NumPy 2, I don't want to pin torch>=2.3.0
directly because there could be NumPy 1 user that needs torch < 2.3.0
. But as torch
is an optional dependency, I would prioritize numpy
.
I'm not a torch
user at all, is there a workaround?
import torch
import numpy as np # np is available
tensor = torch.tensor([1,2,3])
print(tensor.numpy().tolist())
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.2 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
Traceback (most recent call last): File "/Users/yang/developer/monty/debug/test_dump_torch_tensor.py", line 1, in <module>
import torch
File "/Users/yang/developer/monty/venv/lib/python3.12/site-packages/torch/__init__.py", line 1477, in <module>
from .functional import * # noqa: F403
File "/Users/yang/developer/monty/venv/lib/python3.12/site-packages/torch/functional.py", line 9, in <module>
import torch.nn.functional as F
File "/Users/yang/developer/monty/venv/lib/python3.12/site-packages/torch/nn/__init__.py", line 1, in <module>
from .modules import * # noqa: F403
File "/Users/yang/developer/monty/venv/lib/python3.12/site-packages/torch/nn/modules/__init__.py", line 35, in <module>
from .transformer import TransformerEncoder, TransformerDecoder, \
File "/Users/yang/developer/monty/venv/lib/python3.12/site-packages/torch/nn/modules/transformer.py", line 20, in <module>
device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'),
/Users/yang/developer/monty/venv/lib/python3.12/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/torch/csrc/utils/tensor_numpy.cpp:84.)
device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'),
Traceback (most recent call last):
File "/Users/yang/developer/monty/debug/test_dump_torch_tensor.py", line 4, in <module>
print(tensor.numpy().tolist())
^^^^^^^^^^^^^^
RuntimeError: Numpy is not available
pyproject.toml
Outdated
@@ -44,7 +44,7 @@ json = [ | |||
"pandas", | |||
"pydantic", | |||
"pint", | |||
"torch", | |||
"torch", # Note: need torch>=2.3.0 for numpy 2 # 719 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decide to drop this pin entirely because I believe it's something torch
should resolve instead of monty
(i.e. torch
should correctly list supported numpy
)
Unless tensor.numpy()
should not be used at certain versions? I'm not a torch
user, input appreciated!
Plan B (which I don't really like because it would narrow the default supported NumPy version) is to have something like:
json = [
...,
monty[torch_with_numpy2,...]
]
torch_with_numpy2 = [
"numpy>=2",
"torch>=2.3.0", # Torch version compatible with numpy 2
]
torch_with_numpy1 = [
"numpy<2",
"torch",
]
WalkthroughThe changes in this pull request primarily involve modifications to the Changes
Assessment against linked issues
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #719 +/- ##
==========================================
- Coverage 82.57% 82.53% -0.05%
==========================================
Files 27 27
Lines 1584 1580 -4
Branches 284 284
==========================================
- Hits 1308 1304 -4
Misses 215 215
Partials 61 61 ☔ View full report in Codecov by Sentry. |
@@ -9,7 +9,7 @@ maintainers = [ | |||
] | |||
description = "Monty is the missing complement to Python." | |||
readme = "README.md" | |||
requires-python = ">=3.9" | |||
requires-python = ">=3.9,<=3.13" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume setting an upper bound would be a good idea to avoid installation on unverified versions when new python release come out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- .github/workflows/test.yml (1 hunks)
- pyproject.toml (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- pyproject.toml
🧰 Additional context used
🔇 Additional comments (1)
.github/workflows/test.yml (1)
12-12
: Verify CI dependencies compatibility with Python 3.13.Let's ensure all dependencies specified in the '[ci]' extra are compatible with Python 3.13.
os: [ubuntu-latest, macos-14, windows-latest] | ||
python-version: ["3.9", "3.12"] | ||
os: [windows-latest, ubuntu-latest, macos-latest] | ||
python: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps just maximize test coverage as monty
test is super cheap (only a few seconds), also it's pretty lower level so we cannot afford it to break
Summary by CodeRabbit
New Features
numpy
,pint
, andtorch
.Bug Fixes
torch
dependency concerningnumpy 2
.Chores