Skip to content

ci(multi-arch): selective per-PR builds via TheRock build_stages - #10920

Open
ammallya wants to merge 1 commit into
developfrom
users/ammallya/multiarch-build-stages
Open

ci(multi-arch): selective per-PR builds via TheRock build_stages#10920
ammallya wants to merge 1 commit into
developfrom
users/ammallya/multiarch-build-stages

Conversation

@ammallya

Copy link
Copy Markdown
Collaborator

Motivation

The multi-arch CI (therock-multi-arch-ci.yml) currently rebuilds every TheRock
build stage on every rocm-systems PR, regardless of how small the change is. This is
because rocm-systems is represented as a single source_set in TheRock's
BUILD_TOPOLOGY.toml, so any change maps to the full stage graph and nothing can be
narrowed. The result is slow per-PR turnaround and a scaling bottleneck as more projects
land in the monorepo.

The pre-multi-arch CI only built the components a PR actually touched. This PR restores
that behavior for the multi-arch pipeline: it builds only the stages a PR needs and
skips the rest outright (no build, no artifact copy). This is a pure per-PR speed-up; it
does not change what a full/nightly build produces.

Technical Details

This builds on ROCm/TheRock#7600 ("feat(ci): Add build_stages input to filter CI
build graph"), now merged, which adds a build_stages allowlist input to TheRock's
setup_multi_arch.yml. When set, TheRock builds only the listed stages and skips every
other stage outright; it also validates unknown stage names and auto-scopes test labels to
the allowlisted stages. rocm-systems just needs to compute and pass the allowlist.

Changes in this PR (rocm-systems only):

  • New .github/scripts/compute_build_stages.py. Maps the changed projects (already
    produced by TheRock's configure_external_repo_ci.py) to the minimal allowlist of build
    stages required to build them, using TheRock's build topology as the single source of
    truth (BuildTopology.get_stages_for_projects, which walks the upstream build-dependency
    closure). The topology module is imported read-only from the TheRock checkout, so this
    script owns no dependency math and cannot drift from the actual build graph.

  • therock-multi-arch-ci.yml wiring.

    • The configure job's repo sparse-checkout now also fetches the new script; the TheRock
      sparse-checkout is broadened to include build_tools/_therock_utils (cone mode also
      pulls the root BUILD_TOPOLOGY.toml and build_tools/project_mappings.json).
    • A new "Compute build-stage allowlist" step emits build_stages.
    • The setup job passes build_stages: ${{ needs.configure.outputs.build_stages }} to
      setup_multi_arch.yml.

Dependency / rollout. This PR does not change the pinned TheRock ref; the
build_stages input is consumed only once the pinned ref includes #7600, which is being
bumped in a separate PR. Until that lands, build_stages is an inert no-op (unknown inputs
are ignored), so this change is safe to merge independently and activates automatically when
the ref is updated. Keep the configure-checkout ref and the setup/multi_arch_ci_* refs
in sync so the topology used for selection matches what is built.

Fail-safe (empty allowlist ⇒ build all). The script conservatively builds everything
whenever the change set cannot be safely narrowed:

  • CI-infra changes (run_all_tests true — workflow/scripts/repos-config.json);
  • no changed projects;
  • a fan-out project whose ABI ripples into consumers (clr, hip, hipother,
    hip-tests, rocr-runtime, amdsmi);
  • any unrecognized/unmapped project (guards the mixed known/unknown case, since
    get_stages_for_projects silently ignores names it cannot resolve);
  • any topology-load error.

Safety. get_stages_for_projects always returns the full upstream closure, so no
built stage ever depends on a skipped stage. The trade-off while active: skipped stages
produce no artifacts, so downstream jobs see only the built subset. This is intentional and
temporary; see the tracking issue below.

Relevant links:

Issue Tracking

ISSUE ID: ROCm/rocm-libraries#11195

Test Plan

  • Unit tests (.github/scripts/tests/compute_build_stages_test.py) covering: project-path
    normalization, the run_all_tests short-circuit, fan-out policy, mixed known/unknown
    projects, the "all stages required" case, and topology-load failure. The topology is
    stubbed so the tests need no TheRock checkout.
  • Ran compute_build_stages.py against a real TheRock checkout pinned to the Bump tornado from 6.5.4 to 6.5.7 in /projects/rocminfo/docs/sphinx #7600 merge
    commit for representative changed-project sets.
  • Validated the workflow parses as YAML and the patch applies cleanly on develop.

Test Result

  • 10/10 unit tests pass; black clean; workflow YAML valid.
  • Representative allowlists against the pinned TheRock topology:
    • projects/rdccompiler-runtime,dctools-core
    • projects/rocshmemcomm-libs,compiler-runtime
    • projects/rocprofiler-systemscompiler-runtime,profiler-apps
    • projects/hip (fan-out), unknown project, empty, and run_all_tests=true → empty
      (build all).

Submission Checklist

Copilot AI lite review requested due to automatic review settings August 28, 2026 22:36
@ammallya
ammallya requested a review from a team as a code owner August 28, 2026 22:36
@ammallya ammallya added the ci:skip If applied, TheRock CI will be skipped label Aug 28, 2026
@github-actions github-actions Bot added the github actions Pull requests that update GitHub Actions code label Aug 28, 2026
@therock-pr-bot

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass
Forbidden Files ✅ Pass
🧪 Unit Test ✅ Pass
🚫 Draft PR 🔜 To Be Enabled
🚩 Feature Flag 🔜 To Be Enabled
📊 Code Coverage 🔜 To Be Enabled

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

Copilot AI 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.

Pull request overview

This PR speeds up rocm-systems multi-arch presubmit CI by computing a per-PR allowlist of TheRock build stages to build (and skipping all others) based on the changed projects and TheRock’s build topology.

Changes:

  • Add .github/scripts/compute_build_stages.py to map changed projects → minimal required TheRock build stages (fail-safe to “build all” when narrowing is unsafe).
  • Wire build_stages through .github/workflows/therock-multi-arch-ci.yml from the configure job into TheRock’s setup_multi_arch.yml.
  • Add unit tests for the rocm-systems-owned selection/fail-safe logic.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/therock-multi-arch-ci.yml Computes and forwards a per-PR build_stages allowlist into TheRock multi-arch setup.
.github/scripts/compute_build_stages.py New script that computes the stage allowlist from changed projects using TheRock topology.
.github/scripts/tests/compute_build_stages_test.py Unit tests covering parsing and fail-safe behaviors without requiring a TheRock checkout.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +103 to 106
sparse-checkout: |
build_tools/github_actions
build_tools/_therock_utils
sparse-checkout-cone-mode: true
Comment on lines +102 to +104
therock_build_tools = Path(therock_path) / "build_tools"
sys.path.insert(0, os.fspath(therock_build_tools))
try:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:skip If applied, TheRock CI will be skipped github actions Pull requests that update GitHub Actions code organization: ROCm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants