-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Summary
Currently, the project is pinned to PyTorch 2.3.0, which is incompatible with NumPy 2.0. This requires constraining NumPy to <2.0, preventing users from benefiting from NumPy 2.0's performance improvements and new features.
Current State
- PyTorch version: 2.3.0 (pinned in
pyproject.toml) - NumPy constraint:
>=1.24,<2.0(added as workaround) - Issue: PyTorch 2.3.0 was compiled against NumPy 1.x C API and fails on Windows with NumPy 2.0+
Problem Details
Error on Windows with NumPy 2.0:
RuntimeError: Numpy is not available
UserWarning: Failed to initialize NumPy: _ARRAY_API not found
Affected operations:
torch.from_numpy()conversionstorchaudio.load()operations- Sparse tensor operations
- Any torch/numpy interoperability
Root cause:
PyTorch binaries must be recompiled against NumPy 2.0's new C API to support both NumPy 1.x and 2.x. PyTorch 2.3.0 predates NumPy 2.0 (released June 2024) and lacks this compatibility.
Proposed Solution
Upgrade PyTorch to version 2.3.1 or later:
torch = [
"torch>=2.3.1", # NumPy 2.0 compatible
"torchvision>=0.18.1",
"torchaudio>=2.3.1",
]Then remove the NumPy upper bound:
"numpy>=1.24", # NumPy 2.0 supported with PyTorch 2.3.1+Benefits
- NumPy 2.0 features: Access to performance improvements and new functionality
- Future compatibility: Aligns with ecosystem migration to NumPy 2.0
- Simplified dependencies: Removes artificial version constraints
- Better Windows support: Eliminates Windows-specific NumPy compatibility issues
Considerations
Python version compatibility:
- PyTorch 2.3.1: Supports Python 3.10-3.12
- PyTorch 2.4+: Adds Python 3.13 support (if we want to re-enable it in CI)
- PyTorch 2.9+: Adds Python 3.14 preview support
Testing requirements:
- Verify all tests pass on Linux, macOS, Windows
- Check for any breaking changes in PyTorch 2.3.1+ release notes
- Regenerate
uv.lockafter version updates
References
Upstream issues:
- PyTorch #107302: NumPy 2.0 Support
- PyTorch #131668: Release 2.4 windows wheels not compatible with numpy 2.0
- PyTorch #135013: NumPy 2.1.0 Compatibility Issue
PyTorch releases:
Related PRs:
- augmentation method in numpy: flip up/down #2: Current CI modernisation (adds numpy<2.0 workaround)
Acceptance Criteria
- Upgrade PyTorch to 2.3.1+ (or 2.4+ if Python 3.13 support desired)
- Remove
<2.0constraint from NumPy dependency - Regenerate
uv.lockfile - All CI tests pass on Linux, macOS, Windows
- Update documentation if there are any breaking changes
- Consider if torchvision/torchaudio versions need updating for compatibility
Priority
Medium - Current workaround (numpy<2.0) is functional, but upgrading provides better long-term compatibility and performance.