Repository navigation
ci: install CPU-only torch in Python CI - #2164
Merged
Merged
Conversation
On Linux, torch from PyPI is the CUDA build. It brings about 3 GB of CUDA packages, which made the uv cache entry of the Python CI jobs 3.4 GB. The runners have no GPU. The lint and test jobs now skip torch, torchvision, torchaudio and the Linux-only nvidia-*, cuda-* and triton packages in uv sync, and install the +cpu builds of the locked versions from the PyTorch CPU index. pyproject.toml and uv.lock do not change.
dangusev
marked this pull request as ready for review
November 20, 2026 16:37
dev.py mypy starts its own uv run, which synced the environment to uv.lock again and replaced the CPU build of torch with the CUDA build and its CUDA packages. The setup action now sets UV_NO_SYNC for the rest of the job, so the --no-sync flags in run_tests.yml are not needed.
aliev
approved these changes
Nov 20, 2026
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.
Why
The Python CI jobs (lint and test) restore a 3.4 GB uv cache entry. It is the largest entry in the repository's Actions cache. The repository uses 11.05 GB of the 10 GB limit, so GitHub deletes entries. The Go cache of CI (Go) is one of them: on 2026-11-20, 6 of 11 CI (Go) runs had no cache and took 15–18 min instead of 4–5 min.
About 2.6 GB of the 3.4 GB is
torchand its CUDA packages. On Linux,torchfrom PyPI is the CUDA build. The runners have no GPU.How it works
main)torchbuild on CInvidia-*,cuda-*,triton)3.12.133.12.13-cpu-torchpyproject.toml,uv.lockChanges
python-uv-setup: a new inputcpu-torch, off by default. When it is on, the cache key gets-cpu-torch, so the old 3.4 GB entry is not restored, and the action setsUV_NO_SYNC=1for the rest of the job.torchis in the default dependency set, so auv runthat syncs would install the CUDA build again.dev.py mypystarts its ownuv run mypy(dev.py:101,dev.py:109), so a flag on the workflow's ownuv runcalls is not enough.run_tests.yml: the lint and test jobs turncpu-torchon.The published package does not change: the job that builds it in
release.ymldoes not turn the input on, and the wheels take their dependencies frompyproject.toml.Tradeoffs: CI tests the CPU build of the locked
torchversion, not the locked wheel. This also applies to the callers ofrun_tests.yml: the integration job before a release (release.yml) and the daily integration run (daily.yml). download.pytorch.org is a new host that Python CI needs.onnxruntime-gpu(270 MB) stays: it installs the same module asonnxruntime, so a change to it is a separate PR.Validation
uv syncinstalls 393 packages with no CUDA package, then the step installstorch==2.12.1+cpu,torchvision==0.27.1+cpuandtorchaudio==2.11.0+cpu. No later step syncs or downloads a CUDA package.mainis 3,278 MB.uv runinsidedev.py mypysynced to the lock again and installed the CUDA build. 0a58f02 fixes that, and that entry was deleted.UV_NO_SYNC=1with a script that has inline metadata (plugins/stream/generate.py): uv prints a warning that it has no effect and installs the script's dependencies as before.🤖 Generated with Claude Code