File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -411,10 +411,24 @@ jobs:
411411 # digest on every cold build. Listing more than one cache-from donor lets
412412 # BuildKit chain from a conflicting copy of such a layer and miss every
413413 # layer downstream — a ~40 min cold rebuild even when a warm cache exists.
414- # So read EXACTLY ONE donor: PR builds integrate into main, so they seed
415- # from main; main/branch builds seed from their own chain.
414+ # So we still read EXACTLY ONE donor; only WHICH donor changes below.
415+ #
416+ # A PR's first build has no cache of its own and seeds from main. Every
417+ # LATER push on the same PR seeds from the PR's OWN buildcache instead of
418+ # main: a PR that touches an early layer (Dockerfile.ci, pyproject.toml,
419+ # uv.lock, the MCore stubs) never has those layers in main-buildcache, so
420+ # seeding from main cold-rebuilt the ~40 min dependency layer on EVERY
421+ # push. Seeding from the PR's own cache reuses the layers that same PR
422+ # already built and pushed to ${KEY}-buildcache. This stays single-donor,
423+ # so the non-reproducible-DeepEP cascade above cannot happen. The probe
424+ # falls back to main on any error, so this never fails the build.
416425 if [[ -n "$PR_NUMBER" && "${{ github.ref }}" != "refs/heads/main" ]]; then
417- SEED="main"
426+ PR_CACHE="${{ matrix.registry }}/megatron-bridge:${KEY}-buildcache"
427+ if docker buildx imagetools inspect "$PR_CACHE" > /dev/null 2>&1; then
428+ SEED="$KEY"
429+ else
430+ SEED="main"
431+ fi
418432 else
419433 SEED="$KEY"
420434 fi
You can’t perform that action at this time.
0 commit comments