Skip to content

[CI] Fix viable/strict freeze: tag the newest push-green candidate instead of the raw tip of main - #25684

Open
Gasoonjia wants to merge 2 commits into
mainfrom
fix/viable-strict-promotion-race
Open

Gasoonjia wants to merge 2 commits into
mainfrom
fix/viable-strict-promotion-race

Conversation

@Gasoonjia

@Gasoonjia Gasoonjia commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix the viable/strict promotion freeze by changing how .github/workflows/promote-to-viable-strict.yml picks the commit it tags. One file changed; no required-check changes; no pytorch/test-infra changes. The advancement step (.github/workflows/update-viablestrict.yml → pytorch/test-infra/.github/actions/update-viablestrict) was located during investigation and deliberately not touched.

Update: an earlier version of this PR tagged the oldest aged commit behind a commit-age lock. Review (thanks @claude) showed that caps advancement at one commit per tick — the updater promotes the newest fully green commit — and tags intermediate commits of multi-commit pushes, which never receive push-side pull/Lint/Build documentation rows (push workflows run only for the head of a push) and can never be promoted. This version implements the corrected selection below.

Problem (HUD freeze + root cause)

Per HUD, viable/strict sat on a 2026-11-19 commit (c29858d) for ~4 days while main moved ~170 commits ahead; nightlies cut from viable/strict shipped stale bytes. No single PR blocked it (QNN blocker #25424 merged): candidates died on scattered flaky reds (~22 distinct reasons), on push-side rows that were still running or already red, and on commits that could never be promoted at all. A one-off manual dispatch (PR #25525's commit) has since advanced viable/strict to a272663; this PR is the structural fix so it does not freeze again.

Old vs new behavior

Aspect Before After (scheduled runs)
Candidate choice Tip of main every 4h tick, regardless of its CI state Newest commit ahead of viable/strict that is ≥ CANDIDATE_MIN_AGE_HOURS (6h, whole hours) old, untagged, and green on all push-side required workflows (pull, Lint, Build documentation) with no failed run
Never-promotable commits Tagged like any other tip Skipped by the push-side filter (covers multi-commit-push intermediates, cancelled docs builds, already-red commits)
Blocking A tagged candidate's full CI runs independently; updater picks newest green Same, and each tick re-picks the newest eligible commit, so a red candidate never blocks newer green ones (no head-of-line blocking, no lock needed)
Concurrency cancel-in-progress: false Unchanged
Manual dispatch Blank = tip; explicit SHA tagged immediately Unchanged (selection runs only on schedule)

The push-side query mirrors update-viablestrict.yml's own API usage and the updater's one-failure-is-fatal semantics; it needs actions: read for GITHUB_TOKEN (added; contents stays read-only, tag push still uses the bot token). The walk is capped at 50 commits per tick.

Simulation walkthrough (verified locally)

Selection block exercised verbatim in a scratch repo with a stubbed gh:

  1. Tip young (30 min), next commit aged 10h and push-green, older commits various: selects the aged push-green commit (skips the young tip by age).
  2. Same repo with no push-green commit: selects nothing, exits 0 ("nothing to promote on this tick").
  3. Already-tagged commits are skipped; after the updater advances viable/strict, the range shrinks accordingly.

Scope / non-goals

Validation

  • actionlint clean apart from pre-existing info-level shellcheck notes in unchanged script parts; YAML parses; permissions now {contents: read, actions: read}.
  • Selection logic simulated as above.
  • This job's environment only allows deployment from main, so the new scheduled path is first live after merge; manual-dispatch paths are unchanged code.

This PR was authored with an AI coding assistant (Muse Code). Please keep as-is for review; do not land until reviewed.

…asing the tip of main

viable/strict froze for ~4 days on a 2026-11-19 commit (c29858d) while main moved ~170 commits ahead, so executorch nightlies cut from viable/strict shipped stale bytes under a new date. There is no single blocking PR (the QNN blocker #25424 has merged): ~57 candidates fail for ~22 mostly flaky reasons, and 5 of 7 sampled commits were green on every push-side required check, missing only the gate row.

Root cause: promote-to-viable-strict.yml tagged the tip of main every 4 hours. The tip advances 100+ commits a day while full CI takes hours, so each new tick replaced the candidate before its required checks finished and candidates kept dying halfway.

Scheduled runs now (1) keep evaluating the oldest tagged candidate still ahead of viable/strict, using the existing ciflow/trunk/<sha> tags as the persisted candidate set, (2) tag the oldest commit ahead of viable/strict that is at least CANDIDATE_MIN_AGE_HOURS (6h) old, never the tip, and (3) abandon a candidate older than CANDIDATE_LOCK_TIMEOUT_HOURS (24h, from commit time) by leaving its tag as a tombstone and tagging the next-oldest aged commit, so one red/flaky commit cannot block advancement forever. cancel-in-progress was already false and stays false. A hand dispatch with an explicit SHA bypasses selection as before.

Scope: only .github/workflows/promote-to-viable-strict.yml changes. The required-check set in update-viablestrict.yml and the advancement logic in pytorch/test-infra (update-viablestrict action) are untouched; this PR does not change which checks gate viable/strict.
@pytorch-bot

pytorch-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit da3cd79 with merge base 0986bc8 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 24, 2026
@Gasoonjia
Gasoonjia marked this pull request as ready for review November 24, 2026 20:30
@Gasoonjia

Copy link
Copy Markdown
Contributor Author

@claude review effort=max

@claude

claude Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Claude finished @Gasoonjia's task in 30m 2s —— View job


Review of PR #25684

  • Load /pr-review skill
  • Gather context (diff, related workflows, updater semantics)
  • Independent review panel (3 reviewers)
  • Consolidate findings
  • Fact-check findings (re-read every cited line; hand-traced the selection logic)
  • Post review

Summary: The new selection always tags the oldest commit and only one per run, so viable/strict can move forward by about one commit every 4 hours, and it stalls for days after every multi-commit ghstack landing. That would leave viable/strict further behind main than the current code does, so I'm requesting changes.

Detailed review

PR Review: #25684

Summary

The PR changes scheduled promotion. It used to tag the tip of main every 4h. Now it tags the oldest untagged commit ahead of viable/strict that is at least 6h old, and holds a lock, based on commit age, on the oldest live candidate. There are three problems:

  • The selection caps advancement far below the rate commits land.
  • It picks commits that can never be promoted.
  • The lock guards against a race that the CI concurrency config already rules out.

Infrastructure

  • Blocker: viable/strict can advance by at most one commit per tick (promote-to-viable-strict.yml:183-198).

    • Why:
      • Only tagged commits can be promoted. viable-strict-gate runs only on ciflow/trunk/* tags (viable-strict-gate.yml:26-29) and is required (update-viablestrict.yml:27).
      • Each scheduled run tags at most one commit (the break at 196), always the oldest untagged one (rev-list --reverse at 198).
      • So the scheduled tags form an unbroken run starting right after viable/strict, and the updater can never jump past the newest of them.
    • Rate:
      • At most 1 commit per 4h tick, so 6/day. Once full CI takes more than ~3.5h it drops to 1 per 8h, because the candidate is still locked at the next tick.
      • main lands ~42 commits/day (170 in ~4 days), or "100+/day" per line 29.
      • Even if every candidate is green, the lag grows by at least 36 commits/day with no upper limit. Working through today's ~170-commit backlog alone would take at least 28 days.
      • The PR's own walkthrough shows these one-commit steps (ticks 2–4: the 30h, then 10h, then 8h commit). The old code could jump straight to a green tip.
    • Fix: pick the newest eligible commit. Walk git rev-list --first-parent origin/viable/strict..origin/main newest-first and tag the first commit that is old enough and passes the push-side check in the next finding.
      • The existing "already contained" and "tag exists" checks (243-265) then handle quiet periods again.
      • The oldest-first tombstone walk can be removed.

    Fix this →

  • Blocker: the selection tags commits that can never be promoted, and with the lock this stalls advancement for days (promote-to-viable-strict.yml:187-198).

    • Why: pull, lint and Build documentation are required, but none of them has a ciflow/trunk/* trigger (pull.yml:3-9, lint.yml:3-11, doc-build.yml:3-14). Their rows come only from the push to main, and the selection never reads them.
    • Multi-commit pushes (confirmed):
      • trymerge.py:1147-1151 lands a whole ghstack in one repo.push, and push-triggered workflows run only for the head of a push. Every earlier commit in the stack therefore never gets those three rows.
      • This checkout has an example: 08bf3a2..b04668b, 17 pytorchbot commits all committed between 06:41:39 and 06:41:42 -0800 today.
      • Tracing the new code through that stack:
        1. The first stack commit is tagged at 6–10h old.
        2. It holds the lock until it is 24h old, which is 14–18h.
        3. Each remaining intermediate commit is then tagged and tombstoned at one per tick.
        4. The stack head, the only commit in it that can be promoted, gets tagged about 3 days after step 1.
      • Nothing advances in that time, and 16 full CI runs go to commits that can never be promoted. This is the head-of-line blocking the PR says it removes.
      • The old code always tagged the tip, and the tip is always the head of a push.
    • Cancelled docs builds (mechanism confirmed, frequency suspected): doc-build.yml:16-18 uses one concurrency group per ref with cancel-in-progress: false on push. GitHub cancels the pending run whenever a newer push queues, so those commits can never be promoted either. The notice at 276-278 already says a tag cannot bring them back.
    • The 6h minimum age doesn't help: it is justified as giving push-side checks time to finish (43-45, 70-72). Their results are never read, so it only adds delay.
    • Fix: only consider commits whose push-event pull, lint and Build documentation runs all concluded success.
      • Query: gh api "repos/pytorch/executorch/actions/runs?head_sha=$C&event=push&per_page=100", the same call update-viablestrict.yml:76 already makes.
      • This needs actions: read next to line 105, or the bot token.

    Fix this →

  • Major: the lock guards against a race the CI config rules out, and it is released based on commit age rather than CI state (promote-to-viable-strict.yml:162-181; rationale at 29-31).

    • There is no race:
      • A newer tag never replaces runs started by an older one. trunk.yml:18, apple.yml:36 and windows-msvc.yml:20 put github.ref_name (= ciflow/trunk/<sha>) in the concurrency group, so each tag gets its own group. viable-strict-gate.yml has no concurrency block at all.
      • Under the old code, every tagged tip ran to completion and stayed promotable. This assumes the updater promotes the newest commit where every required check is green, which is how fetch_latest_green_commit.py works; I couldn't re-check that here.
      • So "kept replacing the candidate before its required checks finished" doesn't match the config.
      • The PR's own numbers point elsewhere: ~57 candidates red for ~22 flaky reasons, and green commits missing only the gate row. That means failing or missing rows and too few tagged commits. A lock can only reduce the number of attempts.
      • If you have evidence that tag-triggered runs were cancelled, please link it.
    • The release condition ignores CI: commit_age_sec (148-152) uses the commit's %ct. The tags are lightweight (269), so --sort=creatordate (181) also sorts by commit date. Nothing checks the candidate's CI.
      • A candidate tagged at 6–10h old whose CI fails within an hour, or that can never be promoted (previous finding), blocks every new tag for 14–18h. Line 177 meanwhile logs it as "still in flight".
      • During a backlog, every candidate is already more than 20h old when tagged, so the lock never takes effect. The promise at 74-77 ("a healthy candidate is never dropped mid-flight") doesn't hold.
    • Fix: drop the lock and the tombstones; one tag per tick at the newest eligible commit is enough. If CI spend must be capped, hold the lock only while the candidate's tag-started trunk, Apple and viable-strict-gate runs are queued or in progress, and release it as soon as one fails.

    Fix this →

Backward Compatibility

  • Minor: manual dispatches behave differently (promote-to-viable-strict.yml:136, 167-181).

    • Blank dispatch: it used to promote the tip of main, the one-click way to unstick promotion. It now runs the scheduled selection and usually exits 0 having done nothing ("still in flight"). The table's "Manual dispatch: Unchanged" doesn't reflect this.
    • Dispatch with a SHA: the lock loop treats every ciflow/trunk/<40-hex> tag as a candidate. A dispatch on a commit ahead of viable/strict, such as the bisect use case in the header (19-20), which usually targets a red commit, pauses all scheduled promotion until that commit is 24h old.
    • Fix: run the selection only when GITHUB_EVENT_NAME is schedule, and keep a blank dispatch promoting the tip. The lock interaction goes away with the lock fix above.

    Fix this →

Code Quality

  • Minor: redundant fetch that can fail the step (promote-to-viable-strict.yml:140-142).

    • actions/checkout@v4 with fetch-depth: 0 (122) fetched all branches and tags seconds earlier, as 213-214 already notes.
    • The extra git fetch --tags has no --force. Since git 2.20, fetch refuses to update a tag that has moved ("would clobber existing tag"). pytorch-probot moves ciflow/trunk/<PR#> tags whenever a PR is pushed, so this can fail the step under set -e. That failure is suspected; I didn't run it.
    • Fix: delete the extra fetch.

    Fix this →

Specific Comments

  • promote-to-viable-strict.yml:28-32: the incident narrative (dates, commit counts) sits in a permanent header comment. It belongs in the PR or commit message (CLAUDE.md: minimal comments).
  • promote-to-viable-strict.yml:43, :65, :186: "never the tip" is false. After 6h with no new commits, the tip becomes the oldest untagged commit that is old enough, and it gets tagged.
  • promote-to-viable-strict.yml:11-17, :59-60: stale. Scheduled runs no longer promote the tip. With the 6h minimum and oldest-first order, the 08:00 UTC run can't get the night's last commits into that day's nightly.
  • promote-to-viable-strict.yml:73, :78: the values must be whole hours, because $(( … * 3600 )) at 145-146 errors on "1.5". The comment invites tuning, so it should say this.
  • promote-to-viable-strict.yml:180: the ::warning:: repeats on every run for every tombstone still ahead of viable/strict. Warnings pile up during exactly the kind of freeze this PR targets.
  • promote-to-viable-strict.yml:243-245, :259-261: stale. A scheduled SHA now always comes from the untagged viable/strict..main range, so a scheduled run can never reach either branch, yet both comments describe the scheduled case.
  • promote-to-viable-strict.yml:137-139, :154-156, :162-166, :183-186: these inline comments repeat the header.
  • promote-to-viable-strict.yml:5, :272-279 and _ci-run-decision.yml:21-24: these lines predate this PR, but the new min-age reasoning depends on them. They say the tag starts pull.yml, but pull.yml:3-9 has no tag trigger. The tag starts six workflows, and three of them are required (trunk, Apple, viable-strict-gate).

Recommendation

Request Changes

The two blockers mean that, once merged, the scheduled path would advance viable/strict more slowly than the code it replaces and stall it for days after each large ghstack landing. That reproduces the freeze it is meant to fix. Picking the newest eligible commit, filtered on push-side results, fixes both and makes the lock unnecessary.

What I couldn't verify:

  • I couldn't run the scratch-repo simulation, because running scripts needs approval in this sandbox.
  • I couldn't fetch pytorch/test-infra, because network access is blocked.
  • So the findings rest on reading the code and tracing it by hand. The updater behaviour assumed in the lock finding (it promotes the newest commit where every required check is green) comes from memory of fetch_latest_green_commit.py.

…oldest

Address review on the previous version: tagging the oldest commit caps advancement at one commit per tick (the updater promotes the newest fully green commit, so oldest-first can never catch up), and it tags intermediate commits of multi-commit pushes, which never receive push-side pull/Lint/Build documentation rows (push workflows run only for the head of a push) and can never be promoted.

Scheduled runs now walk newest-first from viable/strict to main and tag the first commit that is at least CANDIDATE_MIN_AGE_HOURS old, not already tagged, and green on all three push-side required workflows with no failed run (queried with gh api, mirroring the updater's one-failure-is-fatal semantics; needs actions: read for GITHUB_TOKEN). The commit-age lock and tombstones are removed: a red candidate cannot block newer ones because each tick re-picks the newest eligible commit. Manual dispatch without a SHA promotes the tip again, the redundant git fetch is removed, and the tag notice now correctly lists pull/Lint/Build documentation as push-side checks.

Selection logic re-verified in a scratch repo with a stubbed gh: youngest commits are skipped by age, already-tagged commits are skipped, and the newest push-green aged commit is selected (NONE when no commit qualifies).
@Gasoonjia Gasoonjia changed the title [CI] Fix viable/strict freeze: lock promotion to one aged candidate instead of chasing the tip of main [CI] Fix viable/strict freeze: tag the newest push-green candidate instead of the raw tip of main Nov 25, 2026
@Gasoonjia Gasoonjia added the release notes: none Do not include this in the release notes label Nov 25, 2026

This branch was previously deployed

1 inactive deployment
cadence — da3cd79d Deployed Nov 25, 2026 by Gasoonjia via hifi5s-op-test / hifi5s #41058
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant