Skip to content

[mergebot] Block merge of docker-affecting PRs with skew or unbuilt images - #191508

Closed
ezyang wants to merge 4 commits into
gh/ezyang/3527/basefrom
gh/ezyang/3527/head
Closed

ezyang wants to merge 4 commits into
gh/ezyang/3527/basefrom
gh/ezyang/3527/head

Conversation

@ezyang

@ezyang ezyang commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

PRs that touch .ci/docker generate a new set of CI docker images, keyed by
the git tree hash of .ci/docker (see docker-builds.yml, which tags images
with git rev-parse HEAD:.ci/docker). If such a PR lands while its images
are missing or stale, every downstream trunk job fails because it can't find
the image it needs -- as happened in the #190927 / #186302 land race, where a
force-merge bypassed CI and a second docker PR landed in the skew window.

Add two hard gates in merge_into (the shared chokepoint for both normal and
force merges, so -f no longer bypasses them):

  1. check_docker_builds_ready: a docker-affecting PR must have run the
    docker-builds (ciflow/docker) workflow with all jobs passing, so the
    images are pre-built and pushed to ECR. Pending builds raise
    MandatoryChecksMissingError so a normal merge waits; missing/failed
    builds are refused.

  2. check_no_docker_merge_skew: after the merge commit is created locally,
    its .ci/docker tree hash must match the tree that ciflow/docker actually
    built and tested on the PR head. A mismatch means another docker change
    landed in the skew window and the required images were never built, so
    the merge is refused with a request to rebase.

Both gates are intentionally not overridable by -f, matching existing
-f-proof invariants like ghstack-out-of-sync and internal-changes-must-land-
via-Phabricator. Add unit tests for the pure helpers.

Refactor the docker merge gates so their file-matching and check-filtering
logic lives in pure, module-level helpers, and cover those helpers with unit
tests.

- Extract `is_docker_affecting_files(files)`, which decides whether a set of
  changed files touches the `.ci/docker` tree hash. `GitHubPR.is_docker_affecting`
  now delegates to it. The matcher requires either an exact `.ci/docker` path or
  a `.ci/docker/` prefix, so lookalikes like `.ci/docker-something/x` no longer
  count.
- Extract `get_docker_build_checks(checks)`, which selects the checks belonging
  to the `docker-builds` workflow (the bare workflow name plus its
  `docker-builds / ...` sub-jobs), and use it in `check_docker_builds_ready`.
- Add `TestDockerCiGates` covering both helpers: affecting vs. non-affecting
  file lists (including the empty list and the lookalike-prefix case) and the
  workflow-check filtering (excluding unrelated jobs and the
  `docker-builds-nightly` lookalike).

The end-to-end gate functions (`check_docker_builds_ready` /
`check_no_docker_merge_skew`) are still best exercised through a real GitHubPR
backed by recorded fixtures; that coverage is noted as a follow-up in the test
class docstring.

[ghstack-poisoned]
@ezyang
ezyang requested a review from a team as a code owner July 29, 2026 17:35
@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Jul 29, 2026
@pytorch-bot

pytorch-bot Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/191508

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit b69d0af with merge base 3ee692b (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@ezyang
ezyang requested a review from huydhn July 29, 2026 17:43
@ezyang ezyang added the mergedog mergedog is watching this PR label Jul 29, 2026
ezyang added a commit that referenced this pull request Jul 29, 2026
…mages

PRs that touch .ci/docker generate a new set of CI docker images, keyed by
the git tree hash of .ci/docker (see docker-builds.yml, which tags images
with `git rev-parse HEAD:.ci/docker`). If such a PR lands while its images
are missing or stale, every downstream trunk job fails because it can't find
the image it needs -- as happened in the #190927 / #186302 land race, where a
force-merge bypassed CI and a second docker PR landed in the skew window.

Add two hard gates in merge_into (the shared chokepoint for both normal and
force merges, so -f no longer bypasses them):

1. check_docker_builds_ready: a docker-affecting PR must have run the
   docker-builds (ciflow/docker) workflow with all jobs passing, so the
   images are pre-built and pushed to ECR. Pending builds raise
   MandatoryChecksMissingError so a normal merge waits; missing/failed
   builds are refused.

2. check_no_docker_merge_skew: after the merge commit is created locally,
   its .ci/docker tree hash must match the tree that ciflow/docker actually
   built and tested on the PR head. A mismatch means another docker change
   landed in the skew window and the required images were never built, so
   the merge is refused with a request to rebase.

Both gates are intentionally not overridable by -f, matching existing
-f-proof invariants like ghstack-out-of-sync and internal-changes-must-land-
via-Phabricator. Add unit tests for the pure helpers.

ghstack-source-id: a820cfd
Pull-Request: #191508
Failing job: lintrunner-noclang-partial / lint
Failing lint target: .github/scripts/trymerge.py
Failing CI command: spin lint -- --force-color --tee-json=lint.json --skip CLANGTIDY,CLANGTIDY_EXECUTORCH_COMPATIBILITY,CLANGFORMAT,PYREFLY .github/scripts/test_trymerge.py .github/scripts/trymerge.py
Error:
  Warning (PYFMT) format
  Run `lintrunner -a` to apply this patch.

Put the `any` expression on the single line required by PYFMT. This is the exact formatter patch reported by CI and does not change behavior.

Test Plan:
```
git diff --check
```

The targeted `spin lint` command could not be run locally because `spin` is unavailable and there is no project or parent `.venv`.

AI assistance: This CI fix was prepared with an AI assistant.

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Jul 29, 2026
…mages

PRs that touch .ci/docker generate a new set of CI docker images, keyed by
the git tree hash of .ci/docker (see docker-builds.yml, which tags images
with `git rev-parse HEAD:.ci/docker`). If such a PR lands while its images
are missing or stale, every downstream trunk job fails because it can't find
the image it needs -- as happened in the #190927 / #186302 land race, where a
force-merge bypassed CI and a second docker PR landed in the skew window.

Add two hard gates in merge_into (the shared chokepoint for both normal and
force merges, so -f no longer bypasses them):

1. check_docker_builds_ready: a docker-affecting PR must have run the
   docker-builds (ciflow/docker) workflow with all jobs passing, so the
   images are pre-built and pushed to ECR. Pending builds raise
   MandatoryChecksMissingError so a normal merge waits; missing/failed
   builds are refused.

2. check_no_docker_merge_skew: after the merge commit is created locally,
   its .ci/docker tree hash must match the tree that ciflow/docker actually
   built and tested on the PR head. A mismatch means another docker change
   landed in the skew window and the required images were never built, so
   the merge is refused with a request to rebase.

Both gates are intentionally not overridable by -f, matching existing
-f-proof invariants like ghstack-out-of-sync and internal-changes-must-land-
via-Phabricator. Add unit tests for the pure helpers.

ghstack-source-id: 58e7dfa
Pull-Request: #191508
@ezyang ezyang added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 29, 2026
@huydhn

huydhn commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Thinking more about this. Does this check need to be in mergebot? Having the check as a simple job on https://github.com/pytorch/pytorch/blob/main/.github/workflows/docker-builds.yml is cleaner IMO, basically having check_no_docker_merge_skew logic in its own place and fail when it needs to. We have jobs of similar nature like https://github.com/pytorch/pytorch/blob/main/.github/workflows/lint-bc.yml.

This would also:

  • Avoid hardcoding docker-build related stuffs in mergebot
  • Simplify testing

@ezyang

ezyang commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@huydhn It can't live in ciflow/docker triggered jobs. You need to know exactly what the final hash will be and you only know that as you're getting ready to merge into main. Anything else is subject to race.

@ezyang

ezyang commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

mergedog handoff

Note

This PR is being shepherded by mergedog, an automation tool run by a maintainer. It watches CI and may push fixes; the PR author does not need to act unless a maintainer asks.

All CI is green (or skipped). Ready for human review and @pytorchbot merge.

Current PR head: 441fda8f12b83c74ee3190dead887c5ac0e39a93.

Autonomous changes pushed

  • 8bcb0c257c9a — pushed fix commit 8bcb0c257c9a — failing jobs: lintrunner-noclang-partial / lint (fix-CI (2026-07-29T19:35:19+00:00))
  • a5fc225da606 — resolved rebase conflicts in commit a5fc225da606 (rebase-resolver (2026-07-29T19:37:16+00:00))
  • d82d80f13572 — pushed fix commit d82d80f — failing jobs: lintrunner-noclang-partial / lint (fix-CI (2026-07-29T19:46:57+00:00))

During shepherding, the configured LLM was invoked 3 times. If any CI shows red, it judged that failure unrelated to this PR's changes — please verify below before merging.

Session 1 — fix-CI (2026-07-29T19:35:19+00:00)

  • Before: b001d5973821
  • After: 8bcb0c257c9a
  • Verdict: pushed fix commit 8bcb0c257c9a — failing jobs: lintrunner-noclang-partial / lint
LLM transcript

Session 2 — rebase-resolver (2026-07-29T19:37:16+00:00)

  • Before: 3ee692b38020
  • After: a5fc225da606
  • Verdict: resolved rebase conflicts in commit a5fc225da606
LLM transcript

Session 3 — fix-CI (2026-07-29T19:46:57+00:00)

  • Before: 951a76a5e95a
  • After: d82d80f13572
  • Verdict: pushed fix commit d82d80f — failing jobs: lintrunner-noclang-partial / lint
LLM transcript

@huydhn

huydhn commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@huydhn It can't live in ciflow/docker triggered jobs. You need to know exactly what the final hash will be and you only know that as you're getting ready to merge into main. Anything else is subject to race.

That's a fair point. I don't remember we have any land check running at merge, but let me double check that

@claude Are there any CI jobs trigger at merge time by pytorchbot?

@claude

claude Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Claude finished @huydhn's task in 3m 8s —— View job


Answer: no, pytorchbot does not launch any CI at merge time

  • Searched trymerge.py / merge workflows for merge-time CI triggering
  • Checked whether the old land-check mechanism still exists
  • Enumerated what the merge-time gates actually are

Short answer: the merge path is read-only with respect to CI. trymerge.py polls check results that already exist on the PR head; it never dispatches a workflow, adds a ciflow/* label, or pushes a branch that would start a build. The one exception is --rebase, which does force-push the PR branch and therefore restarts PR CI — see below, it's relevant to this PR's design.

Details

What the merge workflow does

.github/workflows/trymerge.yml is a single job triggered by repository_dispatch: try-merge. It checks out the repo and runs python3 .github/scripts/trymerge.py. No workflow_dispatch, no gh workflow run, no create_ref. The only labels mergebot writes are cosmetic/bookkeeping (MERGE_IN_PROGRESS_LABEL at trymerge.py:2550, merged/land-failed, and ci-no-td on revert at trymerge.py:2364) — none of them are ciflow/*, so none of them start a workflow.

The only git push in the merge path is repo.push(self.default_branch(), dry_run) at .github/scripts/trymerge.py:1348 — pushing the merge commit to main. That does start CI, but it's the post-merge trunk run, which is exactly the run this PR is trying to protect.

The one thing that does trigger CI at merge time: --rebase

trymerge.yml:52-63 runs tryrebase.py before trymerge.py in the same job, and tryrebase.py:77 force-pushes the PR branch. That restarts the PR's CI, and then trymerge.py's retry loop (trymerge.py:2608, 5-minute poll, timeout_minutes=400 at :2541) blocks until the new checks go green. So @pytorchbot merge --rebase is effectively "trigger fresh CI at merge time, then land" — which is precisely the remediation check_no_docker_merge_skew tells the user to run (trymerge.py:1833). Worth noting since it means the fix path is already wired up and self-serve.

Land checks are gone from the merge path

landchecks/* survives only as a push-trigger branch filter in pull.yml:12, trunk.yml:9, lint.yml:12, plus an exception entry in runner_determinator.py:299. Nothing in .github/scripts/ creates or pushes a landchecks/<pr> branch anymore, and trymerge.py has no -g/--land-checks flag. (Caveat: this checkout is shallow — 21 commits — so I couldn't pin down the removal commit via git log -S.)

The merge-time gates that do exist today

All of these are read-and-decide, no CI launch:

Gate Location Behavior
find_matching_merge_rule trymerge.py:1553 approvals + mandatory checks vs. merge_rules.yaml
get_classifications trymerge.py:2098 Dr.CI call to bucket failures as flaky / broken-trunk / unstable
categorize_checks trymerge.py:2449 splits pending vs. failing, tolerates up to IGNORABLE_FAILED_CHECKS_THESHOLD
check_for_sev trymerge.py:2423 blocks on open merge-blocking SEV
internal-changes check trymerge.py:1715 must land via Phabricator; not -f-overridable
check_docker_builds_ready trymerge.py:1744 (this PR) reads existing ciflow/docker checkruns
check_no_docker_merge_skew trymerge.py:1798 (this PR) compares tree hashes locally after the merge commit exists

Bearing on @huydhn's suggestion

This confirms @ezyang's reply. check_no_docker_merge_skew has to read HEAD:.ci/docker of the merge commit, which only exists between merge_changes_locally (:1340) and repo.push (:1348). A docker-builds.yml job or a lint-bc.yml-style workflow runs against the PR head and its base at trigger time, so it can't see the tree the merge will actually produce — any such check is racy by construction.

The precedent for a non--f-overridable, merge-commit-dependent invariant living in trymerge.py is the internal-changes check at :1715, so this isn't a new kind of thing being added to mergebot. The genuine cost of the trymerge.py placement is the one @huydhn named: DOCKER_CI_PATH / DOCKER_BUILDS_WORKFLOW_NAME become mergebot-side constants coupled to docker-builds.yml. If those drift, is_docker_affecting() silently returns False and the gate becomes a no-op rather than failing loudly — that seems like the thing worth a consistency test, more than relocating the check.

• branch [`gh/ezyang/3527/head`](https://github.com/pytorch/pytorch/tree/gh/ezyang/3527/head)

@huydhn

huydhn commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

I think there might be a gap here for ghstack depending on if the change to .ci/docker is at the top of the stack

Result:
- Top PR touches .ci/docker: ✅ Works. The top PR head is cumulative (gh/user/N/head is built on the lower diffs), so ciflow/docker on it builds the cumulative .ci/docker tree, and the skew check's pr_head_tree (top head) vs merge-HEAD tree comparison is valid — including correctly detecting cross-base skew if main's .ci/docker moved.
- .ci/docker change is in a lower diff, top PR isn't docker-affecting: ❌ Both gates short-circuit on if not pr.is_docker_affecting(): return — because the top PR's own file list has nothing under .ci/docker. The stacked docker change gets cherry-picked and lands with no builds-ready check and no skew check. That's precisely the land-race class this PR exists to prevent, just reachable via ghstack.

@huydhn

huydhn commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@claude Check if the change here work with ghstack?

@claude

claude Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Claude finished @huydhn's task in 15m 34s —— View job


Answer: mostly yes, but there is one real ghstack hole — a docker change in a lower diff of the stack bypasses both gates

  • Traced merge_into -> merge_changes_locally -> merge_ghstack_into for the ghstack path
  • Checked what GitHubPR.get_changed_files() returns for a ghstack PR (base = gh/user/N/base, not main)
  • Verified the skew comparison (HEAD:.ci/docker vs <pr head>:.ci/docker) is valid for the cherry-pick flow
  • Enumerated the cases that work vs. the one that doesn't, and sketched a fix

Summary: the tree-hash comparison itself is sound for ghstack — cherry-picking the stack onto main produces the same .ci/docker tree as the top PR head unless the base moved, which is exactly what you want to detect. The problem is the if not pr.is_docker_affecting(): return guard at trymerge.py:1755 and :1818: it consults only the PR you typed merge on, and a ghstack PR's file list is the diff against gh/user/N/base, so it does not include lower diffs in the stack. Merging the top of a stack lands every open PR below it via merge_ghstack_into (trymerge.py:1254), so a .ci/docker change carried by a lower diff lands with neither gate ever running.

Details — case-by-case, plus a fix sketch

Why the mechanism is otherwise correct for ghstack

The head branch gh/user/N/head is cumulative (it sits on gh/user/N/base, which contains diffs 1..N-1), so ciflow/docker on the top PR builds and tags images from the cumulative .ci/docker tree. merge_ghstack_into then cherry-picks each open rev onto main, leaving HEAD as the top diff replayed on trunk. The two trees can therefore only differ if main's .ci/docker moved out from under the stack — precisely the land race. So the comparison at trymerge.py:1820-1824 is not fooled by ghstack's branch layout.

Case matrix

Scenario Behavior
Top PR touches .ci/docker, merged from the top ✅ Both gates run. Skew detection is correct including cross-base skew.
Merged from a middle PR that touches .ci/docker ✅ Correct. Only PRs at-or-below land, HEAD is that PR's cherry-pick, and last_commit_sha() is that same PR's head — the two sides of the comparison stay consistent.
Lower diff touches .ci/docker, top PR does not ❌ Gap. Both gates short-circuit on the top PR's file list. The docker change is cherry-picked and lands unchecked.
Lower docker diff already merged/closed ✅ Correctly ignored — merge_ghstack_into skips closed PRs, so those .ci/docker changes are already in main.

The ❌ row is not exotic: the ciflow/docker labeler entry (.github/labeler.yml:189) is also driven by per-PR file lists, so the lower PR gets labeled and builds images tagged with its head tree, while the merge-time gate looks at the top PR and sees nothing. If main's .ci/docker moves in the meantime, that's the #190927 / #186302 failure mode reachable straight through ghstack.

Fix sketch

Both gates need to consider the whole landed range rather than self. merge_into already has repo, so get_ghstack_prs(repo, pr) (trymerge.py:739, open_only=True by default, which conveniently excludes already-landed docker diffs) gives the exact set.

One subtlety worth getting right: with several docker-affecting PRs in one stack, the images matching the final tree are the ones built by the topmost docker-affecting PR — every PR below it has a stale .ci/docker tree by construction. So the invariant to enforce is "some PR in the landed range has green docker-builds and a head .ci/docker tree equal to the merge commit's", which subsumes both of today's gates:

# in merge_into, replacing check_docker_builds_ready(self)
gated = [p for p, _ in get_ghstack_prs(repo, self)] if self.is_ghstack_pr() else [self]
docker_prs = [p for p in gated if p.is_docker_affecting()]

then run check_docker_builds_ready against the topmost entry of docker_prs, and keep check_no_docker_merge_skew comparing merge HEAD against that same PR's head tree. Note the gate is currently checked before merge_changes_locally, while find_matching_merge_rule for stacked PRs runs inside merge_ghstack_into (trymerge.py:1241) — pulling the stack once in merge_into and passing it down avoids a second get_ghstack_prs round trip.

Fix this →

Two smaller notes

  1. trymerge.py:1820-1822 — the comment says the PR head "may not be present locally (e.g. for ghstack)". That's inverted: gh/* head branches are ordinary refs in the repo and trymerge.yml checks out with fetch-depth: 0, so the ghstack head is the case most likely to already be local; the fork-PR case is the one that genuinely needs the fetch. The repo.fetch() is harmless either way, just the rationale that's off.
  2. repo.rev_parse(f"HEAD:{DOCKER_CI_PATH}") raises if .ci/docker doesn't exist at that tree. Only reachable if a PR deletes the directory wholesale, in which case a hard error is arguably fine — flagging it only so it's a deliberate choice.

I have not pushed any changes — this was a read-only investigation of the ghstack path, per the "check if" framing.
• branch gh/ezyang/3527/head

… in a ghstack

A ghstack merge lands every open PR below the one being merged, so gating only
`self` was wrong: it would miss a docker-affecting PR lower in the stack, and
for a stack whose top PR touches `.ci/docker` it checked the top PR's own head
rather than the cumulative merge tree that actually needs images.

Compute the set of PRs that a merge will land (for ghstack, all open PRs in the
stack) and run both gates against the topmost docker-affecting PR via the new
`get_topmost_docker_pr` helper. That PR's cumulative head carries the final
`.ci/docker` tree, so its images are the ones that must have been built.

To avoid resolving the stack twice, `merge_into` now fetches `ghstack_prs` up
front and threads it through `merge_changes_locally` and `merge_ghstack_into`,
which take an optional `ghstack_prs` argument and only call `get_ghstack_prs`
themselves when it isn't supplied.

Tests: add `test_get_topmost_docker_pr` for the stack-walk helper, and
`test_merge_into_gates_lower_ghstack_docker_pr`, which drives `merge_into` on a
ghstack whose top PR is docker-neutral and confirms the lower docker PR is the
one passed to `check_docker_builds_ready`. Trim the placeholder docstring on
`TestDockerCiGates` now that the gates have real coverage.

Minor comment fixes: note that a wholesale deletion of `.ci/docker`
intentionally fails the merge-commit tree lookup, and correct the missing-object
example from ghstack to fork PRs.

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Jul 30, 2026
…mages

PRs that touch .ci/docker generate a new set of CI docker images, keyed by
the git tree hash of .ci/docker (see docker-builds.yml, which tags images
with `git rev-parse HEAD:.ci/docker`). If such a PR lands while its images
are missing or stale, every downstream trunk job fails because it can't find
the image it needs -- as happened in the #190927 / #186302 land race, where a
force-merge bypassed CI and a second docker PR landed in the skew window.

Add two hard gates in merge_into (the shared chokepoint for both normal and
force merges, so -f no longer bypasses them):

1. check_docker_builds_ready: a docker-affecting PR must have run the
   docker-builds (ciflow/docker) workflow with all jobs passing, so the
   images are pre-built and pushed to ECR. Pending builds raise
   MandatoryChecksMissingError so a normal merge waits; missing/failed
   builds are refused.

2. check_no_docker_merge_skew: after the merge commit is created locally,
   its .ci/docker tree hash must match the tree that ciflow/docker actually
   built and tested on the PR head. A mismatch means another docker change
   landed in the skew window and the required images were never built, so
   the merge is refused with a request to rebase.

Both gates are intentionally not overridable by -f, matching existing
-f-proof invariants like ghstack-out-of-sync and internal-changes-must-land-
via-Phabricator. Add unit tests for the pure helpers.

ghstack-source-id: 8cfe250
Pull-Request: #191508
@ezyang

ezyang commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

mergedog handoff (after merge failure)

pytorchmergebot reported Merge failed. mergedog re-inspected CI and is handing back off to you. Please review the latest session(s) below and re-run @pytorchbot merge if you're happy — mergedog will not retrigger the merge itself.

Current PR head: b69d0af28562c15112cd221f058fd256b9320c05.

Autonomous changes pushed

  • 8bcb0c257c9a — pushed fix commit 8bcb0c257c9a — failing jobs: lintrunner-noclang-partial / lint (fix-CI (2026-07-29T19:35:19+00:00))
  • a5fc225da606 — resolved rebase conflicts in commit a5fc225da606 (rebase-resolver (2026-07-29T19:37:16+00:00))
  • d82d80f13572 — pushed fix commit d82d80f — failing jobs: lintrunner-noclang-partial / lint (fix-CI (2026-07-29T19:46:57+00:00))

CI notes at handoff

mergedog is treating these still-failing checks as unrelated/spurious. Please verify before merging:

  • linux-jammy-rocm-py3.10-mi350 / test (default, 7, 8, linux.rocm.gpu.gfx950.1)

Warning: mergedog's suppressed check list differs from the latest Dr. CI summary.

Suppressed by mergedog but not listed by Dr. CI:

  • linux-jammy-rocm-py3.10-mi350 / test (default, 7, 8, linux.rocm.gpu.gfx950.1)
Latest Dr. CI summary
## :link: Helpful Links
### :test_tube: See artifacts and rendered test results at [hud.pytorch.org/pr/191508](https://hud.pytorch.org/pr/191508)
* :page_facing_up: Preview [Python docs built from this PR](https://docs-preview.pytorch.org/pytorch/pytorch/191508/index.html)
* :page_facing_up: Preview [C++ docs built from this PR](https://docs-preview.pytorch.org/pytorch/pytorch/191508/cppdocs/index.html)
* :question: Need help or want to give feedback on the CI? Visit the [bot commands wiki](https://github.com/pytorch/pytorch/wiki/Bot-commands)

Note: Links to docs will display an error until the docs builds have been completed.


## :hourglass_flowing_sand: No Failures, 4 Pending
As of commit b69d0af28562c15112cd221f058fd256b9320c05 with merge base 3ee692b380206d788625e0a4474d758f93571ee9 (<sub><sub><img alt="image" width=70 src="https://img.shields.io/date/1785351714?label=&color=FFFFFF&style=flat-square"></sub></sub>):
:green_heart: Looks good so far! There are no failures yet. :green_heart:


This comment was automatically generated by Dr. CI and updates every 15 minutes.

During shepherding, the configured LLM was invoked 4 times. If any CI shows red, it judged that failure unrelated to this PR's changes — please verify below before merging.

Session 1 — fix-CI (2026-07-29T19:35:19+00:00)

  • Before: b001d5973821
  • After: 8bcb0c257c9a
  • Verdict: pushed fix commit 8bcb0c257c9a — failing jobs: lintrunner-noclang-partial / lint
LLM transcript

Session 2 — rebase-resolver (2026-07-29T19:37:16+00:00)

  • Before: 3ee692b38020
  • After: a5fc225da606
  • Verdict: resolved rebase conflicts in commit a5fc225da606
LLM transcript

Session 3 — fix-CI (2026-07-29T19:46:57+00:00)

  • Before: 951a76a5e95a
  • After: d82d80f13572
  • Verdict: pushed fix commit d82d80f — failing jobs: lintrunner-noclang-partial / lint
LLM transcript

Session 4 — fix-CI (2026-07-30T07:32:39+00:00)

  • Before: 9870c1a2c89d
  • Verdict: judged failures spurious (no commit) — failing jobs: linux-jammy-rocm-py3.10-mi350 / test (default, 7, 8, linux.rocm.gpu.gfx950.1); rationale: linux-jammy-rocm-py3.10-mi350 / test (default, 7, 8, linux.rocm.gpu.gfx950.1): test_ops 6/6 exceeded the 30-minute command timeout and exited 124 without reporting a failing test. This ROCm test timeout is unrelated to the PR's merge-bot-only changes and is transient CI capacity/runtime behavior.
LLM transcript

@huydhn huydhn left a comment

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.

LGTM!

@ezyang

ezyang commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: trunk / linux-jammy-rocm-py3.10-mi350 / test (default, 7, 8, linux.rocm.gpu.gfx950.1)

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

atalman added a commit to atalman/pytorch that referenced this pull request Aug 7, 2026
Follow-up to pytorch#191508. That PR added two gates for docker-affecting PRs. The
first, check_docker_builds_ready, requires the PR's own ciflow/docker builds to
have run and passed -- that one stays. The second, check_no_docker_merge_skew,
additionally required the .ci/docker tree of the *merge commit* to equal the
tree ciflow/docker built on the PR head, and refused the merge otherwise:

    Refusing to merge: this PR modifies the CI docker images, but the .ci/docker
    tree of the merge commit (...) does not match the tree that ciflow/docker
    built and tested on the PR head (...)

In practice that makes a docker PR win a race against the base branch. Rebasing
only helps until the next docker-affecting PR lands, so on a busy day a PR can
bounce indefinitely -- pytorch#190639 hit it twice in a row, with the PR-head tree
moving (08b9699 -> 75ce86e) while the merge-commit tree stayed the same.

Downgrade it to a warning:

- The builds-are-green requirement is unchanged: check_docker_builds_ready still
  blocks (and MandatoryChecksMissingError still makes a normal merge wait).
- A missing post-merge image is not fatal. docker-builds.yml runs on push to the
  default branch, so it publishes the merged tree's images right after the merge,
  and test-infra's calculate-docker-image polls for the image (docker manifest
  inspect, up to 120 min) before falling through to rebuilding it locally. So a
  skew costs time on the first trunk jobs rather than breaking them.
- The mismatch is still printed to the merge job log, so a slow or rebuilding
  trunk job can be correlated with the land race that caused it.

Renamed to warn_on_docker_merge_skew so the name matches the behaviour.
pytorchmergebot pushed a commit that referenced this pull request Aug 7, 2026
…arn (#192522)

Follow-up to #191508.

## What #191508 added, and what changes here

It added two gates for docker-affecting PRs, both in `merge_into` so force merges
cannot bypass them:

1. **`check_docker_builds_ready`** — the PR's own `ciflow/docker` builds must have
   run and passed. **Unchanged by this PR.** Pending builds still raise
   `MandatoryChecksMissingError` so a normal merge waits; missing/failed builds are
   still refused.
2. **`check_no_docker_merge_skew`** — additionally required the `.ci/docker` tree of
   the *merge commit* to equal the tree `ciflow/docker` built on the PR head, and
   refused the merge otherwise. **This PR downgrades it to a warning.**

So the "all the builds are green" requirement is fully retained; what goes away is
the extra requirement that the base branch not have moved.

## Why

Requiring the two trees to match means a docker PR has to win a race against the
base branch, and a rebase only helps until the next docker-affecting PR lands. On
a busy day a PR can bounce indefinitely. #190639 hit it twice in a row — the
PR-head tree moved (`08b9699a` → `75ce86e4`) after a rebase while the merge-commit
tree stayed `ab961773`:

```
Refusing to merge: this PR modifies the CI docker images, but the .ci/docker tree
of the merge commit (ab96177...) does not match the tree that ciflow/docker built
and tested on the PR head (75ce86e...)
```

**A missing post-merge image is not fatal**, which is the key point:

- `docker-builds.yml` triggers on `push` to `main` / `release/*`, so the merged
  tree's images get built and pushed right after the merge lands.
- test-infra's `calculate-docker-image` polls for the image before giving up —
  `docker manifest inspect` in a loop, `sleep 300` per iteration, up to 120
  minutes for non-docker-build jobs — and then falls through to `rebuild=true`
  and builds it locally.

So a skew costs **time** on the first trunk jobs after the merge (waiting for
docker-builds, or a local rebuild with longer TTS), not a hard failure. Trading
that against docker PRs being unable to land seems like the better default.

## Kept: the diagnostic

The mismatch is still printed to the merge job log, so a slow or rebuilding trunk
job can be correlated with the land race that caused it:

```
WARNING: docker land race on PR #NNNNN: the .ci/docker tree of the merge commit
(...) does not match the tree that ciflow/docker built and tested on the PR head
(...). ... the first trunk jobs after this merge may wait for docker-builds to
publish the merged tree's images, or rebuild them locally. Merging anyway.
```

Renamed `check_no_docker_merge_skew` → `warn_on_docker_merge_skew` so the name
matches the behaviour.

## Test plan

- `python -m pytest .github/scripts/test_trymerge.py` → **74 passed, 2 skipped**
  (the 4 docker-gate tests included; none referenced the renamed function).
- `py_compile` clean; no remaining references to the old name
  (`grep -rn check_no_docker_merge_skew .github/` → empty).
- `MergeRuleFailedError` is still used in 7 other places, so the import is not
  orphaned.

## Trade-off, stated plainly

This intentionally reopens the window that #191508 closed: a docker PR can now
land whose post-merge images were never built or tested, which is the shape of the
#190927 / #186302 land race cited in that PR. The mitigation is that the images
are auto-published by `docker-builds.yml` on the merge and that jobs wait for
them, so the failure mode is latency rather than red trunk. If dev-infra would
rather keep a hard gate, an alternative is to keep refusing only when
`check_docker_builds_ready` did **not** pass, i.e. exactly the unbuilt-image case,
and always allow the pure-skew case — happy to switch to that.

Pull Request resolved: #192522
Approved by: https://github.com/tinglvv, https://github.com/izaitsevfb, https://github.com/ezyang
ankitbhrdwj pushed a commit to ankitbhrdwj/pytorch that referenced this pull request Aug 12, 2026
…arn (pytorch#192522)

Follow-up to pytorch#191508.

## What pytorch#191508 added, and what changes here

It added two gates for docker-affecting PRs, both in `merge_into` so force merges
cannot bypass them:

1. **`check_docker_builds_ready`** — the PR's own `ciflow/docker` builds must have
   run and passed. **Unchanged by this PR.** Pending builds still raise
   `MandatoryChecksMissingError` so a normal merge waits; missing/failed builds are
   still refused.
2. **`check_no_docker_merge_skew`** — additionally required the `.ci/docker` tree of
   the *merge commit* to equal the tree `ciflow/docker` built on the PR head, and
   refused the merge otherwise. **This PR downgrades it to a warning.**

So the "all the builds are green" requirement is fully retained; what goes away is
the extra requirement that the base branch not have moved.

## Why

Requiring the two trees to match means a docker PR has to win a race against the
base branch, and a rebase only helps until the next docker-affecting PR lands. On
a busy day a PR can bounce indefinitely. pytorch#190639 hit it twice in a row — the
PR-head tree moved (`08b9699a` → `75ce86e4`) after a rebase while the merge-commit
tree stayed `ab961773`:

```
Refusing to merge: this PR modifies the CI docker images, but the .ci/docker tree
of the merge commit (ab96177...) does not match the tree that ciflow/docker built
and tested on the PR head (75ce86e...)
```

**A missing post-merge image is not fatal**, which is the key point:

- `docker-builds.yml` triggers on `push` to `main` / `release/*`, so the merged
  tree's images get built and pushed right after the merge lands.
- test-infra's `calculate-docker-image` polls for the image before giving up —
  `docker manifest inspect` in a loop, `sleep 300` per iteration, up to 120
  minutes for non-docker-build jobs — and then falls through to `rebuild=true`
  and builds it locally.

So a skew costs **time** on the first trunk jobs after the merge (waiting for
docker-builds, or a local rebuild with longer TTS), not a hard failure. Trading
that against docker PRs being unable to land seems like the better default.

## Kept: the diagnostic

The mismatch is still printed to the merge job log, so a slow or rebuilding trunk
job can be correlated with the land race that caused it:

```
WARNING: docker land race on PR #NNNNN: the .ci/docker tree of the merge commit
(...) does not match the tree that ciflow/docker built and tested on the PR head
(...). ... the first trunk jobs after this merge may wait for docker-builds to
publish the merged tree's images, or rebuild them locally. Merging anyway.
```

Renamed `check_no_docker_merge_skew` → `warn_on_docker_merge_skew` so the name
matches the behaviour.

## Test plan

- `python -m pytest .github/scripts/test_trymerge.py` → **74 passed, 2 skipped**
  (the 4 docker-gate tests included; none referenced the renamed function).
- `py_compile` clean; no remaining references to the old name
  (`grep -rn check_no_docker_merge_skew .github/` → empty).
- `MergeRuleFailedError` is still used in 7 other places, so the import is not
  orphaned.

## Trade-off, stated plainly

This intentionally reopens the window that pytorch#191508 closed: a docker PR can now
land whose post-merge images were never built or tested, which is the shape of the
pytorch#190927 / pytorch#186302 land race cited in that PR. The mitigation is that the images
are auto-published by `docker-builds.yml` on the merge and that jobs wait for
them, so the failure mode is latency rather than red trunk. If dev-infra would
rather keep a hard gate, an alternative is to keep refusing only when
`check_docker_builds_ready` did **not** pass, i.e. exactly the unbuilt-image case,
and always allow the pure-skew case — happy to switch to that.

Pull Request resolved: pytorch#192522
Approved by: https://github.com/tinglvv, https://github.com/izaitsevfb, https://github.com/ezyang
@github-actions
github-actions Bot deleted the gh/ezyang/3527/head branch October 28, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged mergedog mergedog is watching this PR topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants