Skip to content

ci: pull CPU-only torch wheels on GPU-less runners#163

Open
bkowshik wants to merge 1 commit into
facebookresearch:mainfrom
bkowshik:ci/cpu-only-torch-backend
Open

ci: pull CPU-only torch wheels on GPU-less runners#163
bkowshik wants to merge 1 commit into
facebookresearch:mainfrom
bkowshik:ci/cpu-only-torch-backend

Conversation

@bkowshik

Copy link
Copy Markdown
Contributor

What

Add UV_TORCH_BACKEND: cpu to the Install / sync packages step in .github/actions/setup-python-env/action.yml so CI installs CPU-only torch/torchvision/torchaudio.

Why

CI installs torch via uv on GPU-less 8-core-ubuntu runners with no CPU pin. torch comes from the sub-project pyprojects (torch>=2.5.1 in neuralset/neuraltrain, the all extra adding torchvision/torchaudio; torch==2.6 in neuralbench). With no backend hint, uv resolves the CUDA builds and pulls ~5 GB of CUDA libraries that never run. The cost is paid twice: on every install, and again on every monthly .venv cache upload/restore (already 5-6 GB).

Fix

The composite action's install step is the single chokepoint — every env-using job (test-neuralset, test-downstream, typecheck, build-docs) calls it. One env var fixes all four.

Scoped to CI, not the pyprojects: neuralbench pins torch for CUDA capability sm_60, so GPU users must stay on CUDA builds. The env var only affects this workflow.

Notes

UV_TORCH_BACKEND requires uv >= 0.6.0. setup-uv@v4 is unpinned and defaults to latest, so this works today; pinning uv < 0.6.0 would silently no-op it.

YAML validated; no change to local/GPU installs.

CI installs torch/torchvision/torchaudio via uv on GPU-less 8-core-ubuntu
runners with no CPU pin, so uv resolves the default CUDA builds and drags
in ~5 GB of CUDA libraries that never execute. That bloat is paid twice:
once on every install, and again on every monthly .venv cache upload and
restore (the venv cache is already 5-6 GB).

Set UV_TORCH_BACKEND=cpu on the shared "Install / sync packages" step in
the setup-python-env composite action, which every env-using job calls, so
all four jobs (test-neuralset, test-downstream, typecheck, build-docs) get
the CPU-only index in one place.

Scoped to the CI action rather than the package pyprojects: neuralbench
pins torch to keep CUDA capability sm_60 support for GPU users, and that
intent stays intact since the env var only affects this workflow.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 18, 2026
# instead of the default CUDA builds (~5 GB of unused CUDA libs that also
# inflate every monthly .venv cache upload/restore). Scoped to CI here,
# not the pyprojects, so GPU users (neuralbench sm_60) are unaffected.
UV_TORCH_BACKEND: cpu

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrapin ok for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants