Add Python 3.12-3.14 support - #6
Open
HasinthakaPiyumal wants to merge 1 commit into
Open
Conversation
- Remove deprecated `distutils` imports from setup.py (removed in Python 3.12)
- Guard `import torch` in setup.py with try/except for clean pip install
- Read version from file instead of importing torchonn at build time
- Add mmcv fallback shim in base_layer.py (mmcv fails to build on Python 3.12+)
- Fix circular import by deferring mobilevit import in base_layer.py
- Fix `matrix_parametrization_cuda` to gracefully handle missing CUDA extension
- Fix `.cpu().numpy()` -> `.detach().cpu().numpy()` for newer PyTorch
- Fix `torch.linalg.svd(driver="gesvd")` to only pass driver on CUDA tensors
- Fix raw string escape sequence warning in mrr_op.py
- Replace hardcoded `torch.device("cuda:0")` defaults with CPU fallback
- Update dependency versions for Python 3.12+ compatibility
- Move tensorflow to optional dependency (no Python 3.14 wheel available)
- Fix wrong package name: `pyutils` -> `torchonn-pyutils`
- Add mmengine to dependencies
- Update python_requires to >=3.10 and add 3.11-3.14 classifiers
- Fix CleanCommand for cross-platform support (shutil instead of rm)
- Update tests to support CPU-only execution
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
distutilsmodule usagemmcvbuilder functions when mmcv is unavailable (fails to build on Python 3.12+)tensorflowto optional dependency (pip install torchonn[tf]) since no Python 3.14 wheel existsKey changes
setup.pydistutils, guard torch import, read version from file, update deps/classifierstorchonn/layers/base_layer.pytorchonn/op/matrix_parametrization.py.detach().numpy()torchonn/layers/mzi_conv2d.pydriver="gesvd"(CUDA-only arg)torch.device("cuda:0")with CPU fallbackunitest/*Dependency changes
numpy>=1.26.0(was 1.19.2)torch>=2.1.0(was 1.13.0)torchvision>=0.16.0(was 0.9.0.dev)scipy>=1.11.0,scikit-learn>=1.3.0,matplotlib>=3.8.0torchonn-pyutils>=0.0.2(waspyutils>=0.0.1— wrong package name)mmengine>=0.10.0(new — needed for mmcv fallback)tensorflowmoved toextras_requirepython_requires=">=3.10"Test plan
pip install -e .succeeds on Python 3.14.3import torchonnand all submodule imports work🤖 Generated with Claude Code