Repository navigation
RFC-0056: CRCR Support for Nightly CI - #98
Conversation
Proposes extending CRCR to support scheduled (nightly/periodic) CI dispatches for downstream repositories. Presents two options — EventBridge cron vs. upstream GitHub Actions workflow — with detailed tradeoffs, implementation effort, and open questions for WG discussion.
| 1. Fetch pytorch/pytorch main HEAD SHA via GitHub API | ||
| 2. Build synthetic client_payload: | ||
| - event_type: "nightly" (or "periodic") | ||
| - delivery_id: "nightly-{date}-{uuid}" |
There was a problem hiding this comment.
Suggestion: use the pytorch/pytorch main HEAD commit SHA as the dispatch/correlation ID instead of a random uuid — and avoid any trigger from pytorch/pytorch.
Option 2 already fetches the main HEAD SHA here (step 1). That fetch is a pull via the GitHub API on the relay's own EventBridge schedule — it needs no workflow_dispatch/repository_dispatch/webhook emitted by pytorch/pytorch. So the relay never depends on an event from torch; it just reads GET /repos/pytorch/pytorch/commits/main. That's a strong reason to prefer Option 2 over Option 1 (Option 1's whole premise is torch emitting the event).
Given the SHA is in hand, make it the ID rather than nightly-{date}-{uuid}:
- Meaningful & correlatable — the ID is the tested commit, so HUD (and humans) can map a nightly run straight to
github.com/pytorch/pytorch/commit/<sha>. - No torch coupling — derived entirely on the relay side.
Uniqueness for the Redis state machine (DISPATCHED → IN_PROGRESS → COMPLETED): a bare SHA can collide if main hasn't advanced between two scheduled runs, or on a manual re-trigger. Two clean options:
- SHA-keyed + idempotent (recommended): key on the bare SHA and skip re-dispatch if a
DISPATCHED/COMPLETEDrecord already exists for it. Bonus — you don't re-run nightlies whenmaindidn't move. - Composite if you want exactly one nightly per calendar day regardless of
mainmovement:nightly-{sha}-{YYYYMMDD}(or-{run_id}). Keeps the SHA as the correlation key while guaranteeing a fresh state key per run.
HUD grouping (see the "HUD Changes" note near the end): this also lets you avoid the pr_number = 0 sentinel, which collapses every nightly into one bucket. Carry the SHA (already in payload.head_sha) and group non-PR runs by SHA — each nightly stays distinguishable and links to its commit. pr_number = 0 throws away that per-commit granularity.
Net design: EventBridge cron → relay reads main HEAD SHA → delivery_id = SHA (idempotent) → HUD correlates by commit — no event from pytorch/pytorch anywhere in the path.
There was a problem hiding this comment.
Sure @atalman
Also noting the differences in terms of changes between the option 1 and option 2 for clarity
Option A: EventBridge → Lambda
- Requires provisioning new AWS resources (EventBridge rules, targets, Lambda permissions, CloudWatch alarms) via change in Terraform.
- Adds a new Lambda entry point and a GitHub API dependency to fetch the HEAD SHA.
- Add Redis idempotency logic to avoid duplicate dispatches.
- Schedule changes require a Terraform deployment.
Option B: Reuse Existing Events from pytorch/pytorch workflow
- Adds a periodic trigger workflow in pytorch/pytorch
- Adds the event types in the lambda.
- Nightly uses the existing nightly branch push that already generates a webhook daily.
- The Lambda maps the ref name to a dispatch type; the SHA, delivery ID, and signature verification are all used from the current workflow.
There was a problem hiding this comment.
Per @atalman's review feedback — the main HEAD SHA is already fetched, so use it as the dispatch/correlation ID. This makes the ID meaningful and lets HUD correlate nightly runs directly to the tested commit.
|
Following up on the trigger discussion — I'd like to put a third option on the table that I think fits the nightly/periodic use case better than either Option A (EventBridge cron) or Option B (reuse existing events), because it removes the scheduled trigger from the critical path entirely. Option C: Authenticated self-reportInstead of a central scheduler dispatching to downstream repos, let each downstream repo drive its own schedule and report results back. The relay stops being a trigger and becomes a validating ingest endpoint. This drops the "callback requires a prior Why this is attractive
Two requirements to make it safe
Explicit non-goal: missing-run detectionUnlike central dispatch, the relay never "expects" N callbacks, so it cannot tell "a repo's cron silently broke" from "a repo isn't participating." That's fine by design here — we only care about the signals that arrive; absence of a signal is not an error condition. This is what lets us drop all the completeness/liveness bookkeeping. On SHA alignmentIf we want rows from different backends to line up for side-by-side comparison, downstreams should pin the same stable daily ref ( NetThis keeps the SHA-as-correlation-ID improvement already applied in this PR, and it satisfies "nightly/periodic must not require a workflow to be initiated near |
Adds Option C proposed by @atalman: downstream repos self-schedule via their own crons and report results back through OIDC-validated callbacks. Includes pros/cons analysis, implementation effort estimate, updated comparison table, and open questions around state machine divergence, trust model, and missing-run detection.
Remove Option 1 (upstream cron workflow) and Option 2 (EventBridge) sections. Present only the authenticated self-report approach proposed by @atalman, where downstream repos self-schedule nightly/periodic CI and report results via OIDC-validated callbacks with SHA-keyed upserts.
Keep only the design structure and implementation details. Replace open questions/drawbacks/alternatives with a concrete file changes table showing exactly what needs to be modified.
Briefly document the two alternatives (EventBridge cron and upstream workflow) that were evaluated before settling on the authenticated self-report design, with reasons they were set aside.
Nightly runs fetch HEAD from pytorch/pytorch nightly branch (updated daily by trigger_nightly_core.yml). Periodic runs use main or viable/strict. dispatch_id is the commit SHA per @atalman's suggestion. Includes SHA source table, example downstream workflow, and updated flow diagram.
No in_progress state — downstream workflows report the final result in one callback. No Redis state tracking, no zombie sweeper needed. Adds comparison table showing PR/push vs nightly/periodic callback models.
Document the manual replay procedure via workflow_dispatch. Callbacks are idempotent (SHA-based delivery_id + upsert), so re-running is safe. Automated detection deferred to WG.
## Summary Phase 1 of the CRCR nightly/periodic self-report implementation ([RFC 98](pytorch/rfcs#98)). Adds a new code path in the callback Lambda for `nightly` and `periodic` event types. Unlike PR/push callbacks which require a `DISPATCHED` record in Redis and follow a two-step state machine (`in_progress` → `completed`), nightly/periodic callbacks use a **single-callback model**: - Downstream repo self-triggers via cron - Runs CI against a `pytorch/pytorch` SHA (from `nightly` branch or `main`) - Reports the final result in **one callback** — no `in_progress` step **What's different from PR/push:** - No Redis writes, no state machine, no zombie tracking - Status must be `completed` (rejects `in_progress`) - No upstream check runs (nightly results are informational only) - Timing metrics (queue_time, execution_time) are `null` — no dispatch record to measure against **Changes:** | File | Change | |------|--------| | `callback/callback_handler.py` | New `_handle_nightly_callback()` + routing in `handle()` | | `tests/test_callback_handler.py` | 8 new tests covering the nightly path | **Remaining phases:** - Phase 2: Update callback action YAML with `delivery-id` / `event-type` inputs - Phase 3: Downstream cron workflow in `TorchedHat/pytorch-redhat-ci` - Phase 4: ClickHouse query for nightly results - Phase 5-6: HUD display ## Test plan - [x] 8 unit tests: forward to HUD, skip Redis, no timing metrics, periodic variant, reject `in_progress`, allowlist gating, rate limiting, missing `delivery_id` - [ ] CI passes on this PR
…e 2) (#8303) ## Summary Phase 2 of the CRCR nightly/periodic self-report implementation ([RFC 98](pytorch/rfcs#98)). Extends the callback action (`.github/actions/cross-repo-ci-relay-callback/action.yml`) to support **self-report mode** for nightly/periodic workflows. Downstream repos that self-trigger via cron (no upstream `repository_dispatch`) can now report results by setting two new inputs: - **`delivery-id`**: The upstream `pytorch/pytorch` commit SHA that was tested — becomes the correlation key on the HUD - **`event-type`**: `"nightly"` or `"periodic"` When both are set, the action constructs the payload from scratch (no `client_payload` needed). Existing PR/push behavior is completely unchanged. **Validation:** - `event-type` must be `"nightly"` or `"periodic"` - `status` must be `"completed"` (single-callback model, no `in_progress` step) **Example downstream usage:** ```yaml - name: Report nightly results to CRCR if: always() uses: pytorch/test-infra/.github/actions/cross-repo-ci-relay-callback@main with: status: completed conclusion: ${{ job.status }} delivery-id: ${{ steps.sha.outputs.sha }} event-type: nightly ``` **Depends on:** Phase 1 (#8302) — callback Lambda handler for nightly/periodic ## Test plan - [ ] CI passes (actionlint) - [ ] End-to-end test with Phase 3 downstream workflow
…8304) ## Summary Phase 1.2 of the CRCR nightly/periodic self-report implementation ([RFC 98](pytorch/rfcs#98)). Adds `utils/sha_validator.py` — validates that a self-reported commit SHA exists on `pytorch/pytorch` via the GitHub API before accepting nightly/periodic callback results. **Key features:** - `validate_sha(upstream_repo, sha)` → `True` if SHA exists, `False` on 404, raises on other errors - Module-level TTL cache (1 hour) avoids redundant API calls when multiple downstream repos report against the same nightly SHA - Expired entries are evicted lazily on each call **Depends on:** Phase 1 (#8302) — will be called from `_handle_nightly_callback()` **Changes:** | File | Change | |------|--------| | `utils/sha_validator.py` | New module: SHA validation with TTL cache | | `tests/test_sha_validator.py` | 7 tests: valid/invalid SHA, cache hit/miss, TTL expiry, error propagation | ## Test plan - [x] 7 unit tests covering all paths - [ ] CI passes
#8353) ## Summary Prepares the data layer for nightly and periodic CI support ([RFC 98](pytorch/rfcs#98)). The `crcr_workflow_job` ClickHouse table currently has no way to distinguish between PR-triggered, nightly, and periodic CI runs. This PR: 1. **Schema**: Adds `event_type String DEFAULT 'pull_request'` column to `crcr_workflow_job` — existing rows automatically get `'pull_request'` via the DEFAULT 2. **Write path**: Extracts `event_type` from the callback payload in `crcrUtils.ts` and persists it through DynamoDB to ClickHouse 3. **Queries**: Adds `pr_number > 0` filter to all PR-related queries (`crcr_summary`, `crcr_success_rate`, `crcr_backend_dashboard`, `crcr_backend_summary`, `crcr_pr_results`) to prevent nightly/periodic rows from polluting PR dashboards 4. **Tests**: Adds tests for `event_type` extraction (PR, nightly, periodic, empty) ### Deployment note Run the following ALTER TABLE on ClickHouse before or after merge: ```sql ALTER TABLE default.crcr_workflow_job ADD COLUMN IF NOT EXISTS event_type String DEFAULT 'pull_request' COMMENT 'Dispatch event type: pull_request, nightly, periodic' AFTER downstream_repo_level ``` ### Data flow ``` Downstream CI → Relay Lambda → POST /api/crcr/results → DynamoDB → Replicator → ClickHouse ↑ event_type extracted here ``` ### Nightly HUD design The nightly results will be displayed on the CRCR summary page using a **Page-Level Tabs** design (PR | Nightly tabs at the top). **Mockup**: https://subinz1.github.io/CRCR/mockups/crcr-summary-nightly-design.html Fixes pytorch/crcr-test#17 ## Related PRs - RFC 98: pytorch/rfcs#98 - Nightly handler: #8302 - Callback action: #8303 - SHA validator: #8304 cc @atalman @jewelkm89
Document the multi-issuer OIDC design for supporting Buildkite and other CI providers alongside GitHub Actions. Uses vLLM as a concrete example. Links to tracking issue pytorch/test-infra#8326.
atalman
left a comment
There was a problem hiding this comment.
The SHA-as-correlation-ID and self-report points are all addressed — thanks. Three blockers left:
1. Metrics contradicts the design. "Nightly callback completion rate: Percentage of expected nightly runs (per downstream cron schedule)" isn't measurable under self-report — the relay never learns a downstream's cron schedule, so "expected" is undefined. The Replay section already concedes this ("Automated missed-nightly detection ... may be considered in a future iteration"). Leftover from the Option A/B framing. Suggest replacing with callbacks received per backend per day + time since last callback, or stating the gap explicitly.
2. Missing caveat on SHA validation. GET /commits/{sha} proves the SHA is real, not that CI actually ran against it. That's inherent to self-reporting and fine, but it's the security boundary of the whole model and should be one explicit sentence in the doc.
3. "Multi-CI Provider Authentication" is out of date with shipped code. Added Aug 4, after review, and it documents an approach that was rejected:
- Says
verify_oidc_token()is single-issuer — multi-issuer landed in pytorch/test-infra#8453. - Proposes
_BUILDKITE_REPO_MAPkeyed on slugs injwt_helper.py. Shipped code keys on immutable UUIDs (organization_id/pipeline_id) fromconfig/ci_providers.yml, loaded at runtime — deliberately, since slugs are renameable and a released slug can be claimed by another org. - The slug is wrong anyway: the pipeline is org
vllm/ pipelineci, notvllm-ci. - Omits
required_claims. That's the actual security control — the vLLM pipeline builds fork PRs and any job in it can mint a token, so the mapping must pinbuild_branch: [main]. - Implementation Scope (~45 LOC, 3 tests) is already done.
Issuer URLs and audience do match the shipped constants.
1. Metrics: Replace unmeasurable "completion rate" with observable metrics (callbacks/day, time since last callback). Add explicit note that relay cannot know downstream schedules. 2. SHA validation: Add security boundary statement — SHA existence proves the commit is real, not that CI ran against it. Trust boundary is OIDC identity + allowlist. 3. Multi-CI Provider Authentication: Rewrite to reflect shipped code: - UUIDs (organization_id/pipeline_id) instead of slugs - External ci_providers.yml config instead of hardcoded map - required_claims for branch pinning (fork PR protection) - Correct pipeline naming - Reference actual PRs (#8453, #8468) 4. Update status from Draft to Implemented.
|
All three blockers addressed in 5fd44c7: 1. Metrics — Removed "completion rate" (unmeasurable under self-report). Replaced with:
2. SHA validation caveat — Added one-sentence security boundary statement after the flow diagram: SHA existence proves the commit is real, not that CI actually ran against it. Trust boundary = OIDC identity + allowlist. 3. Multi-CI Provider Authentication — Rewrote to match shipped code:
Also moved status from "Draft" to "Implemented" and filled in the Resolution section. |
The self-report model is shipped — update wording from "evaluated before arriving at" to explicitly state the decision: Option A and B rejected, self-report adopted and implemented.
|
|
||
| ## Proposed Design: Authenticated Self-Report | ||
|
|
||
| *Proposed by @atalman in [PR #98 comment](https://github.com/pytorch/rfcs/pull/98#issuecomment-4962790260).* |
There was a problem hiding this comment.
Perhaps we should review work in progress proposal mentioned here. Lets keep just clean version of final proposal
There was a problem hiding this comment.
Done — renamed the section to "## Design: Authenticated Self-Report", removed the proposal attribution line, and reworded the opening to present it as the shipped design.
|
|
||
| Only GitHub Actions and Buildkite are implemented. GitLab and CircleCI can be added by extending the `_ISSUERS` registry and `ci_providers.yml`. | ||
|
|
||
| ### Implementation (shipped) |
There was a problem hiding this comment.
Here perhaps we can just keep tracker issue. Leaving out implementation PR's since these can be changed.
There was a problem hiding this comment.
Done — removed the implementation PR table. Only the tracking issue link remains: pytorch/test-infra#8326.
|
|
||
| Tracking issue: [pytorch/test-infra#8326](https://github.com/pytorch/test-infra/issues/8326) | ||
|
|
||
| ### File Changes |
There was a problem hiding this comment.
I am not sure we need this section, lets track all the changes via umbrella
There was a problem hiding this comment.
Done — removed the File Changes table. All implementation details are now tracked via the umbrella issue pytorch/test-infra#8326.
Remove WIP/proposal attribution and rename section header from "Proposed Design" to "Design" to reflect the shipped state.
Implementation PRs can change over time — replace the detailed PR table with just the tracking issue link as suggested in review.
Per review: detailed file-level changes are better tracked in the umbrella issue (pytorch/test-infra#8326) than in the RFC itself.
Authored with Claude.
Authored with Claude.
Summary
Documents the implemented Cross-Repository CI Relay (CRCR) nightly self-report model. CRCR already dispatches
pull_requestandpushevents to downstream repositories; nightly CI has no upstream trigger. A downstream backend therefore schedules its own nightly workflow, tests the PyTorch nightly branch, and sends one authenticated completed-result callback directly to the relay.The relay accepts this callback without a prior
DISPATCHEDrecord, validates the caller with OIDC and the tested PyTorch SHA, then upserts the result for HUD. Event-scoped enrollment keeps nightly-only backends out of Pull Requests metrics and prevents irrelevant upstream dispatches.Nightly Flow
flowchart TD A["Downstream cron schedule<br/>(for example, daily 02:00 UTC)"] --> B["Fetch HEAD SHA from<br/>pytorch/pytorch nightly branch"] B --> C["Build and test PyTorch<br/>at that SHA"] C --> D["Single callback to relay<br/>dispatch_id = SHA<br/>event_type = nightly<br/>conclusion = success or failure"] D --> E{"Relay validates"} E -->|"OIDC token maps to an allowlisted repo"| F["Valid"] E -->|"SHA exists on pytorch/pytorch"| F F --> G["Direct upsert to DynamoDB<br/>(no Redis or state machine)"] G --> H["DynamoDB to ClickHouse"] H --> I["HUD display<br/>hud.pytorch.org/crcr"]Callback model comparison
DISPATCHED -> IN_PROGRESS -> COMPLETEDin_progressandcompletedcompletedonlySHA source
Nightly workflows resolve
pytorch/pytorchbranchnightly. The commit SHA is thedispatch_id: it is idempotent, correlatable, and links directly to the corresponding PyTorch commit on HUD.Replay and Recovery
Nightly callbacks are idempotent by design. Re-running a downstream workflow through
workflow_dispatchfetches the current nightly SHA and reports the same way as the cron run. The relay cannot know a downstream repository's intended schedule, so it cannot determine an expected callback count; callbacks received per backend and time since the last callback are the observable signals.Implemented Work
Backend
HUD, enrollment, and observability
crcr_workflow_jobmergedData correctness and diagnostics
Current Follow-up
pytorch/test-infra#8897 tracks the remaining pass-rate aggregation alignment. The intended rule is to count each completed latest-attempt job once for a selected range, keyed by
(downstream_repo, run_id, job_name). SHA grouping in the nightly matrix is presentation-only and must not change the numerator or denominator used by the summary, per-repository card, or trends.Related RFCs
Status
Implemented. Nightly self-reporting, event-scoped enrollment, separate PR and nightly HUD views, and GitHub Actions and Buildkite OIDC support are live.
NVIDIA/pytorch-windows-ci,TorchedHat/pytorch-redhat-ci, andvllm-project/vllmare configured as L2 nightly-only backends.