Declare torch as a runtime dependency#4189
Open
abondarev84 wants to merge 1 commit intopytorch:mainfrom
Open
Conversation
torchaudio imports torch unconditionally at package init, so pip install torchaudio into an environment without a separate pip install torch fails with ModuleNotFoundError. Restore the _get_pytorch_version() call that was commented out in pytorch#4171. This matches the pattern used in pytorch/vision and pytorch/text: - Local / dev builds: install_requires = ["torch"] (unpinned). - Release builds (PYTORCH_VERSION env var set by the release builder): install_requires = ["torch==X.Y.Z"], preserving the ABI-match guarantee that historical torchaudio releases shipped with. The in-thread comment on pytorch#4171 flagged that an unpinned dep would be enough to keep pip's resolver correct: pytorch#4171 (comment)
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/audio/4189
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Author
|
@malfet any suggestions who can help with reviewing this PR? |
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
torchaudio 2.11.0 ships with
install_requires=[], sopip install torchaudiono longer pullstorch. Sincetorchaudio/__init__.pyimportstorchunconditionally, any clean install into an environment without a separatepip install torchfails with:Fix
Restore the
_get_pytorch_version()call that was commented out in #4171. This matches the pattern already used in pytorch/vision and pytorch/text:PYTORCH_VERSIONenv var):install_requires=["torch"]— pip pulls the latest torch.PYTORCH_VERSIONset by the release builder):install_requires=["torch==X.Y.Z"]— pinned to the matching torch release, preserving the ABI guarantee historical torchaudio releases shipped with.The
_get_pytorch_version()function itself is already defined at line 41 — this just re-enables its use.Context
The pre-2.11.0 behavior (
torch==X.Y.Zpinned in release wheels) was removed in #4171 to avoid version pinning. @adamjstewart flagged in-thread that listingtorchunpinned would achieve the stated goal (no version pin) while still keeping pip's resolver correct. This PR takes that further by restoring the env-var-controlled dependency expression, which gives maintainers back the ability to pin in release builds without forcing a pin on local/dev installs.Observed externally
The arm64-python-wheel-tester — an aarch64 wheel-install smoke test — has shown torchaudio failing since the 2.11.0 release, because the tester installs each wheel in isolation and
torchis no longer pulled as a dep.Diff
Two chunks: uncomment the
_get_pytorch_version()call and associated print, and pass the result toinstall_requires. Also removes the now-stale TODO comment.Tests
No tests added. The change is to packaging metadata (
setup.pyinstall_requires); exercising it would require a full install-into-clean-env integration test, which is outside the scope of the existing test suite. The fix can be verified by inspecting the resulting wheel'sMETADATA/requires_distafter building, or bypip install torchaudiointo a fresh venv without a separate torch install.