Field note / CRCR onboarding

PyTorch ecosystem · downstream CI · trusted results

Onboard a backend to CRCR without losing the evidence.

Cross-Repository CI Relay lets an out-of-tree backend validate an exact PyTorch change in its own CI and return an authenticated result to the PyTorch CI HUD. This guide turns that architecture into a deliberate onboarding path for backend maintainers.

A useful downstream signal says more than “the job passed.” It identifies the PyTorch revision that was tested, points to the downstream run that produced the result, and arrives through a path the upstream system can verify. CRCR provides that path; the backend still owns the build, test selection, and day-to-day reliability of its CI.

01 / Understand the model

Start with the smallest integration that proves the path.

CRCR begins with a PyTorch event, dispatches it to a registered backend, and lets that backend test the exact revision in its own environment. The result returns by an OIDC-authenticated callback and becomes inspectable in the CI HUD. The relay does not replace a backend's CI; it connects that CI to an upstream compatibility decision with verifiable context.

New backends normally start at L1: receive events and establish observability. L2 adds callback results to the HUD. Higher levels are a separate maturity decision based on sustained evidence, ownership, and the effect a result may have on a pull request. Do not treat promotion as a setup checkbox.

At L3, a backend can add a non-blocking PR check under its configured opt-in label. L4 is the critical-backend tier where a result may gate every PR and on-call ownership is required. Both are maintained promotion decisions; new integrations should focus on a dependable L1 or L2 path first.

First prove that the right revision reaches the right CI. Then make the result trusted and useful.

02 / Prepare the integration

Make the backend known before it starts reporting.

  1. Choose the event participation.Decide whether the backend should validate pull requests, nightlies, or both. Match this to real capacity and the signal the maintainers intend to own.
  2. Open the allowlist change.Add the backend and its event participation to PyTorch's allowlist. This establishes the registry the relay uses rather than relying on an ad hoc endpoint.
  3. Install the relay GitHub App.Authorize the official relay application on the downstream repository so it can dispatch the registered events. Follow the current onboarding instructions for the application and approval flow.
  4. Name an operational owner.Decide who watches failures, owns workflow changes, and can respond when the upstream contract or backend environment changes.

Registration is intentionally explicit. It creates a bounded list of integrations, makes event participation reviewable, and gives the relay an accountable destination for each dispatch.

The relay app dispatches the event after installation. A downstream repository does not need a callback URL, a relay secret, or custom token-minting code: the official callback action handles identity and delivery once the workflow has the appropriate OIDC permission.

03 / Receive the revision

Build what PyTorch asked you to build.

Add a downstream workflow that listens for repository_dispatch events. The current reference receiver handles pull_request and push payloads. Event participation in the allowlist—pull requests, nightlies, or both—is a registration choice; it is not a reason to guess at the payload shape. Keep the receiver aligned with the current documented contract.

on:
  repository_dispatch:
    types: [pull_request, push]

permissions:
  id-token: write # required for L2 callback authentication

# Use actions: write only when the workflow calls the Actions API to cancel runs.

Read the payload and check out the exact source revision it identifies; do not silently substitute a default-branch tip or a later commit. For a PR that is pull_request.head.sha; for a non-deleted push it is after. A deleted push has the GitHub null SHA and must skip checkout because there is no revision to build.

  1. Validate and keep the dispatch context.Confirm the upstream repository is pytorch/pytorch, retain the event kind and source URL, and carry delivery_id through the workflow. It is required for L2 state tracking.
  2. Handle closed and deleted events safely.A closed PR may need only cancellation or cleanup. A deleted push must not attempt a checkout of its null SHA.
  3. Use concurrency deliberately.Cancel superseded work when that is safe for the backend, while preserving enough run context to explain what happened to an earlier dispatch.
  4. Run a representative check first.Start with a build or focused test that can be maintained reliably. A small dependable signal is more valuable than a large flaky one.

The CRCR test backend documentation shows concrete receiver patterns. Treat it as a reference implementation and testbed, not a requirement to copy its probe-specific workflows into every backend. Its health probe has no cron: live upstream activity produces the relay dispatch. A backend's own scheduled nightly workflow is a separate integration concern.

04 / Report trusted results

Send lifecycle and outcome through the authenticated callback.

At L2, grant the callback workflow permission to request an OIDC token and use the relay callback action to report the work in progress before the build begins. Send a completion result after the test step finishes, including the test outcome and the identifying context supplied by the dispatch. The relay validates the workload identity before it accepts that result.

permissions:
  id-token: write

- uses: pytorch/test-infra/.github/actions/cross-repo-ci-relay-callback@main
  with:
    status: in_progress

# Run the build and test step here.

- if: always()
  uses: pytorch/test-infra/.github/actions/cross-repo-ci-relay-callback@main
  with:
    status: completed
    conclusion: ${{ steps.tests.outputs.outcome }}
    test-results: '{"passed": 42, "failed": 0, "skipped": 3}'
  1. Report in_progress early.This distinguishes a running validation from a missing response and lets timeout handling describe the real lifecycle.
  2. Report completion on every path.Use an always-run completion step so a failing test, cancellation, or infrastructure error does not leave a stale in-progress state behind. Report a conclusion and test-result counts, and verify that the artifact link resolves to the GitHub Actions run.
  3. Preserve actual outcomes.Do not turn expected probe outcomes such as xfail, xcancel, or xtimeout into generic success. They have distinct meanings in the relay model.
  4. Retry rate-limited callbacks.For a 429 response, use bounded backoff and honor Retry-After; a temporary delivery limit should not erase a completed test result.

05 / Operate and advance

Use the HUD to close the loop, then earn more responsibility.

Trigger a controlled dispatch and verify the whole chain: the correct backend workflow starts, its run links to the expected SHA, the callback is accepted, and the result is visible in the HUD. Check both a passing path and a realistic failure path before treating the integration as ready.

From there, use the signal as operational evidence. Watch for missing callbacks, stuck work, outdated checkout logic, and changes in runtime or test duration. When the backend is reliable enough for a stronger role, discuss the next level with the CRCR maintainers rather than assuming the workflow itself grants promotion.

Keep callback bursts under control. The current reference guidance documents a shared relay limit of 60 callback requests per minute: add jitter where multiple jobs report together, bound retries with backoff, and honor Retry-After when the relay responds with 429. Treat the limit as an operational guardrail, not a number to work around.

References

Use the living sources while you implement.

The architecture overview explains why CRCR exists; the reference backend documents the current receiver and callback patterns. Consult both alongside the allowlist when preparing an integration.