Skip to content

ci: commit uv.lock + cpu-only torch + --locked installs#4

Closed
random-walks wants to merge 1 commit into
mainfrom
ci/speedup-install
Closed

ci: commit uv.lock + cpu-only torch + --locked installs#4
random-walks wants to merge 1 commit into
mainfrom
ci/speedup-install

Conversation

@random-walks

Copy link
Copy Markdown
Owner

Summary

Audits the current CI for lossless speedup wins. Three changes, zero §10 impact:

1. Commit uv.lock

Previously gitignored. Committed now so:

Size: 1.4MB. Astral now recommends committing lockfiles even for libraries — the lockfile is CI's dep graph, not the users'.

2. Richer cache-dependency-glob

All three jobs now cache-key on both pyproject.toml AND uv.lock. Precise invalidation — bumping a dep and regenerating the lock rebuilds the cache; touching pyproject without a lock change shouldn't.

3. uv sync --locked on all jobs

Enforces lock-pyproject consistency as a CI-side invariant. A silent drift would fail loudly; the resolver otherwise skips resolution work.

4. CPU-only torch for Linux test jobs

The default torch wheel bundles CUDA (~800MB); the CPU-only variant is ~200MB. CI has no GPU. The ~600MB saving compounds across 4 Linux matrix cells.

Mechanism: UV_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu set only when runner.os == 'Linux'. macOS keeps the standard wheel (no CUDA variant there anyway). Workflow-level UV_INDEX_STRATEGY=unsafe-best-match so uv falls back to PyPI for non-torch deps.

Expected gains

Rough per-cell runtime (py3.12 Linux):

  • Before: ~3m47s (install ~3m, test ~30s)
  • After (cold): ~2m20s (install ~1m40s, test ~30s)
  • After (warm rerun): ~1m30s (cache hits dominate)

py3.14 was the slow cell at ~7min; expected to land closer to 3-4min post-change.

Invariant touched?

None. Pure CI config + lockfile addition.

Test plan

  • uv sync --locked --extra dev --extra all succeeds locally (lock in sync)
  • uv run pytest tests/unit — 499 passed locally
  • CI green on this PR (observe the new timings for the perf claim)
  • Rerun CI on this PR — cache hits should materially drop the second-run time

🤖 Generated with Claude Code

Three modest wins on the ~3-7min test-matrix cells. All lossless w/r/t
correctness; the trade is a bigger git repo (1.4MB uv.lock).

**1. Commit `uv.lock`.** Previously gitignored, which meant every CI run
resolved dependencies from scratch against PyPI. Committed now so:
- Resolution is deterministic — same run twice, same wheels, no
  drift from upstream floor-version updates.
- Cache keys stabilize (see #2 below).
- `uv sync --locked` can assert the lock matches pyproject.toml
  as a config-drift tripwire (see #3).

Libraries have historically not committed lockfiles because users
consume floors, not locks — but astral now recommends committing them
even for libraries (the lockfile is CI's dependency graph, not the
users'). Modern uv-based projects do.

**2. Add `uv.lock` to the cache-dependency-glob** on all three jobs so
setup-uv's cache invalidates precisely on lockfile bumps rather than
generously on any pyproject edit.

**3. `uv sync --locked` everywhere.** Enforces the lock is in sync with
pyproject on every CI run (fails loudly if someone edits pyproject
without regenerating). Side effect: resolution work is skipped.

**4. CPU-only torch on Linux test jobs.** The default torch wheel ships
with CUDA (~800MB); the CPU-only variant is ~200MB. CI has no GPU
anyway, so this is a pure ~600MB / ~60s download-and-extract saving
per Linux matrix cell. Configured via env: `UV_EXTRA_INDEX_URL=
https://download.pytorch.org/whl/cpu` set only when
`runner.os == 'Linux'`. macOS keeps the standard wheel (no CUDA
variant there anyway). Top-level `UV_INDEX_STRATEGY=unsafe-best-match`
so uv falls back to PyPI for everything else on the index.

Expected test-job runtime after (rough estimates, py3.12 Linux cell):
- before:  ~3m47s  (install ~3m, test ~30s)
- after:   ~2m20s  (install ~1m40s cold / ~15s cached, test ~30s)
- warm rerun on same PR: ~1m30s (cache hits dominate).

None of the three §10 contracts change. Only CI config + the lockfile
addition.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@random-walks random-walks mentioned this pull request Apr 24, 2026
9 tasks
@random-walks

Copy link
Copy Markdown
Owner Author

Folded into #3 — all four commits (ci + docs + changelog) live on release/v0.2.0 now. Closing so the PR list isn't noisy; the CI speedup ships with v0.2.0.

@random-walks random-walks deleted the ci/speedup-install branch April 24, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant