Skip to content

test(ci): uv cache seed refresh/reuse/prune test for #4863 (DO NOT MERGE) - #4891

Closed
kajalj22 wants to merge 8 commits into
mainfrom
kajalj/uv-cache-seed-test
Closed

kajalj22 wants to merge 8 commits into
mainfrom
kajalj/uv-cache-seed-test

Conversation

@kajalj22

@kajalj22 kajalj22 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

DO NOT MERGE. Test-only PR, stacked on #4863 (which now includes main's BuildKit uv cache mount from #4340). It runs #4863's prune against a real seed without touching the real uv-cache-* tags.

What this changes (on top of #4863)

  • Both builds use the uv-cache-test tag prefix, so they read and write rl:uv-cache-test-<arch>-<key>, never rl:uv-cache-<arch>-<key>.
  • The Update uv cache image step also runs on this PR.

Before the first run, rl:uv-cache-test-amd64-<key> is created as a copy of main's current rl:uv-cache-amd64-<key>, so the build starts from main's real seed.

Test runs

Run Push Expected
1 this commit Using uv cache seed …uv-cache-test…; the prune runs on main's real seed and logs what it removes; offline check passes; Update uv cache image pushes the pruned seed to the test tag
2 comment-only change in nemo_rl/distributed/actor_environments.py (an input to the dependency layer) Seed from run 1 reused; the prune removes nothing (nothing stale left)

Remaining CI jobs (unit tests, etc.) are cancelled once the build finishes. The uv-cache-test* tags get deleted after the test.

🤖 Generated with Claude Code

kajalj22 and others added 6 commits October 22, 2026 14:32
The release image's shipped uv cache (UV_CACHE_DIR) is append-only:
uv.lock's own cache-seed key is BASE_IMAGE+UV_VERSION+HYBRID_EP_MULTINODE,
not the lock content, so every routine dependency-version bump (torch,
vLLM, SGLang, ...) leaves its predecessor's wheel behind forever as long
as that key stays the same -- which is most of the time.

Add docker/prune_uv_cache.py, run once after all uv-writing RUNs finish
and before the ownership handoff. It parses uv.lock for every (name,
version) pin across all extras (installed in this build or not, so it
cannot break the offline `uv run --extra <backend>` promise UV_CACHE_DIR
exists for) and removes only cache entries nothing in the current lock
still references.

Signed-off-by: Kajal Jain <[email protected]>
update-uv-cache and update-uv-cache-gb200 had no status function in their
if:, so GitHub implied success(), which also requires every transitive need
to succeed. Since cicd-wait-in-queue (and later prepare-megatron-lock) became
needs of the build jobs, and both are skipped on main pushes, the refresh
has been skipped on every main run. The seed went stale, its cache key no
longer matches, and every build that reruns the dependency layer starts
from an empty uv cache.

Use the always() ... !cancelled() pattern the build jobs already use, with
explicit result checks on the jobs these depend on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
…hives

- Garbage-collect archive-v0 by scanning every remaining link under
  wheels-v*/ and sdists-v*/ (as uv cache prune does), instead of only kept
  pypi entries. The old scan deleted archives still referenced by index/,
  url/ and built-from-source entries, leaving dangling links that break
  offline installs of e.g. torch.
- Prune alternative-index trees (index/<digest>/, used for torch and
  flashinfer) by (name, version), not just pypi/.
- Prune git source builds and checkouts whose commit uv.lock no longer pins.
- Judge each cache file by its own parsed version; the old prefix glob
  removed 1.0.1's files when pruning 1.0.
- Keep the truncated form of long versions, matching uv's wheel cache keys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
Deleting cache files in a later RUN only hides them behind whiteouts; the
layers that wrote them still ship every byte. The release-stage prune
therefore left the image size unchanged (61 vs 60 layers, the extra one
~0 bytes).

- Prune at the end of the dependency RUN, which seeds and fills the cache,
  so superseded versions never get committed to a layer.
- Install Dynamo with a throwaway UV_CACHE_DIR: it syncs its own Python 3.12
  lock into a --link-mode copy venv that nothing re-syncs at runtime, so its
  wheels were stored twice.
- Drop the release-stage prune RUN, and add a test that pins the prune to
  the dependency RUN and the Dynamo install to a throwaway cache.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
Pruning at the end of the dependency RUN also deleted the build-isolation
deps the syncs resolve outside uv.lock (setuptools, setuptools-scm,
poetry-core, a build-time torch 2.14.1 + CUDA wheels, ...), which the
TRT-LLM step then downloaded again. Run the prune right after the seed is
copied, so it only judges what older locks left behind.

Also, from review:
- copy the script from the recipe's context, so building an older
  NRL_GIT_REF that lacks it still works
- compare sdist version directories verbatim instead of stripping a
  metadata suffix from the version
- keep archives of a package named `src`
- type-check the script with pyrefly

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
Test-only, stacked on #4863: the H100 build reads its uv cache seed from
rl:uv-cache-test, and update-uv-cache runs on this PR and writes that tag,
so the seed refresh, seed reuse and in-build prune can be exercised
without touching rl:uv-cache.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
@kajalj22 kajalj22 added the CI:L0 Run doctests and unit tests label Oct 23, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 23, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@kajalj22

Copy link
Copy Markdown
Contributor Author

/ok to test 1a8eaf4

@github-actions github-actions Bot added Documentation Improvements or additions to documentation CI Relating to CI labels Oct 23, 2026
main (#4340) replaced the update-uv-cache jobs with an in-build cache mount
and seed export, so this branch drops its workflow change and takes main's.

- Prune right after `uv_cache_restore force`, before any sync; the RUN's
  `uv_cache_persist prune` trap mirrors the result into the cache mount.
- Dynamo keeps its throwaway UV_CACHE_DIR, so its RUN no longer needs the
  cache mount or the restore/persist helpers.
- Placement test and docs updated for the new flow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
main (#4340) replaced the update-uv-cache jobs, so retarget the test at
the new mechanism: both builds use the uv-cache-test tag prefix, and the
"Update uv cache image" step also runs on this PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
@kajalj22

Copy link
Copy Markdown
Contributor Author

/ok to test e3b4d5a

@terrykong terrykong added CI:L1 Run doctests, unit tests, and functional tests and removed CI:L0 Run doctests and unit tests labels Nov 5, 2026
@kajalj22 kajalj22 closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:L1 Run doctests, unit tests, and functional tests CI Relating to CI Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants