unsloth/.github/actions
Daniel Han 6c41897833
Cache uv's downloads, which is now the largest single cost in CI (#9271)
* Cache uv's downloads, which is now the largest single cost in CI

Re-profiling after the apt work landed changed the ranking completely.
The old top step, Install Playwright browsers at 557-671s, is now 91s.
What sits at the top instead:

  3588s total    92s x39   Install Unsloth (--local, --no-torch)
  1925s total   175s x11   Update banner layout regression (Playwright)
  1910s total   478s x 4   unsloth_zoo @ main - full pytest (CPU)
  1683s total    99s x17   Perform CodeQL Analysis

More total time than any test, in 39 job runs, and all of it uv
re-resolving and re-downloading the same wheels: nothing carried its
cache between runners. UV_CACHE_DIR appears in this repo only in the two
clean-machine workflows, which set it in order to delete it.

Caching this is safe because of WHAT is cached. uv's cache is content-
addressed by URL and hash, so a stale entry cannot serve wrong content --
the worst it can do is miss. That is the difference between this and
caching the venv, which would have to reason about an editable overlay
(--local installs the repo with -e, so source changes need no reinstall),
a moving `unsloth-zoo @ git+main`, and absolute paths baked into console
scripts. I looked at the venv first and it is not worth the hazard.

restore-keys is deliberate and is correct only here: a near-miss still
supplies almost every wheel, which is most of the win, and it is safe
precisely because entries are content-addressed. The same fallback on an
install cache would be a bug.

Saved on main only, like the HF and Playwright caches and for the reason
they record: a PR-scoped entry is restorable only by re-runs of that same
PR, while every PR can restore from the default branch, so saving on PRs
spends a 50 GiB budget measured at 99.3% full once already and evicts
main's copy. `uv cache prune --ci` first, so the key does not grow without
bound across 39 jobs.

Placed in the composite action, so all 39 call sites get it from one
definition -- which is what that action exists for.

The cold-install lanes are untouched and a test keeps them that way. They
do not use this action today; if one ever did, the composite writes
UV_CACHE_DIR to $GITHUB_ENV, which outranks a job-level env: for every
later step, so a warm cache would silently replace the cold machine those
workflows are named after and they would still go green.

Nine tests. All five mutants reintroduced and confirmed red: the cache
pointed at the venv, saved on every ref, restore-keys removed,
UV_CACHE_DIR set after the install, and a cold lane adopting the action.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-08-19 05:47:32 -07:00
..
install-unsloth-local Cache uv's downloads, which is now the largest single cost in CI (#9271) 2026-08-19 05:47:32 -07:00
pip-cache-restore Stop spending the Actions cache budget on caches nothing reads (#9151) 2026-08-18 04:47:22 -07:00
pip-cache-save Stop spending the Actions cache budget on caches nothing reads (#9151) 2026-08-18 04:47:22 -07:00