← Back to Pull requests

[torch] Streamline sccache setup and enable for HIP on Windows #9744

Merged
ScottTodd merged 3 files (254 lines) on Nov 10, 2026 22:39 UTC
View on GitHub
ScottTodd ScottTodd commented on Nov 04, 2026 18:38 UTC
Author

Motivation

We were setting:

CMAKE_C_COMPILER_LAUNCHER=sccache
CMAKE_CXX_COMPILER_LAUNCHER=sccache
# Linux-only
HIP_CLANG_LAUNCHER=sccache

We can now just set these options for both platforms:

CMAKE_C_COMPILER_LAUNCHER=sccache
CMAKE_CXX_COMPILER_LAUNCHER=sccache
CMAKE_HIP_COMPILER_LAUNCHER=sccache

This will improve build performance (especially on Windows) and allows us to remove layers of indirection in build_tools/setup_sccache_rocm.py.

See also:

Progress on https://github.com/ROCm/TheRock/issues/9091
Follow-up to https://github.com/ROCm/TheRock/pull/8783
Follow-up to https://github.com/ROCm/TheRock/pull/8824
This will improve time to signal for https://github.com/ROCm/TheRock/issues/3291
Related to https://github.com/ROCm/TheRock/pull/9560
Docs: https://github.com/ROCm/TheRock/blob/main/docs/development/hipcc_migration.md

Technical Details

The remote cache server we use is still configured directly in workflow .yml files such as https://github.com/ROCm/TheRock/blob/466276391eb1cef8ac82b550a7dd3180c5951852/.github/workflows/multi_arch_build_portable_linux_pytorch_wheels.yml#L253-L265

This PR deletes build_tools/setup_sccache_rocm.py as it reduced down to 3 lines of code, but we could add it back or merge with build_tools/github_actions/compute_pytorch_cache_type.py in the style of build_tools/setup_ccache.py - having the script write the _configuration_ (server to use, other settings).

Test Plan

Local testing on Windows

<details><summary>Expand for repro commands</summary>
<p>

rustup update stable
cargo install sccache --locked
sccache --version
# sccache 0.19.0

cd external-builds\pytorch\
python -m venv .venv && .venv\Scripts\activate.bat
pip install --index-url https://nightly.repo.amd.com/rocm/whl-next/ rocm[libraries,devel,device-gfx1100]
pip install -r packaging

python pytorch_torch_repo.py checkout ^
    --gitrepo-origin https://github.com/ROCm/pytorch.git ^
    --repo-hashtag release/2.14 ^
    --checkout-dir D:/b/pytorch

# three times
#    1. cold cache
#    2. cache with CMAKE_HIP_COMPILER_LAUNCHER
#    3. cache without CMAKE_HIP_COMPILER_LAUNCHER
python build_prod_wheels.py build ^
    --pytorch-dir D:/b/pytorch ^
    --no-build-pytorch-audio --no-build-pytorch-vision ^
    --pytorch-rocm-arch=gfx1100 ^
    --output-dir %HOME%/.therock/pytorch ^
    --use-sccache

</p>
</details>

Cache status | Build time | C/C++ cache hit rate | HIP cache hit rate
-- | -- | -- | --
Cold cache | 24 minutes | 0.00% | 0.00%
Warm cache without CMAKE_HIP_COMPILER_LAUNCHER | 11 minutes | 72.30% | 0.00%
Warm cache with CMAKE_HIP_COMPILER_LAUNCHER | 6 minutes | 72.30% | 100.00%

CI testing on Linux and Windows

I re-ran CI jobs to check cache behavior:
https://github.com/ROCm/TheRock/actions/runs/41889393295/attempts/1?pr=9744 cold cache.

Platform | Build time | C/C++ cache hit rate | HIP cache hit rate
-- | -- | -- | --
Linux | 36m 0s | 99.10% | 0.00%
Windows | 1h 9m 29s | 99.34 % | 0.00%

https://github.com/ROCm/TheRock/actions/runs/41889393295/attempts/2?pr=9744 warm cache

Platform | Build time | C/C++ cache hit rate | HIP cache hit rate
-- | -- | -- | --
Linux | 7m 1s | 99.80% | 100.00%
Windows | 26m 47s | 99.34 % | 100.00%

Submission Checklist

  • Look over the contributing guidelines at https://github.com/ROCm/TheRock/blob/main/CONTRIBUTING.md.
  • Diff: 254 lines (+32 / -222) across 3 files Reviewer: ethanwee1 Review duration: 8881m
    All Vouch review confidence checks passed
    Residual risk 0.07 = Change Risk (0.39) × (1 − Review Confidence (0.82)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 254 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.73 · 5 substantive comment(s)
    0.73
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    81%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.332
    Real PR Conversation Timeline
    7 items
    therock-pr-bot[bot] therock-pr-bot[bot] commented on Nov 04, 2026 18:39 UTC
    Bot

    <!-- therock-pr-bot-policy-check -->

    ✅ All Checks Passed — Ready for Review

    | Check | Status | Details |
    |---|:---:|---|
    | 📝 PR Description | ✅ Pass | — |
    | ⛔ Forbidden Files | ✅ Pass | — |
    | 🧪 Unit Test | ⚠️ Warning | Error: Source/code files changed without an accompanying unit test.<br>Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).<br>Current: code file(s) changed: external-builds/pytorch/build_prod_wheels.py; no test file found |
    | 🔎 pre-commit | ✅ Pass | — |
    | 🚫 Draft PR | 🔜 To Be Enabled | — |
    | 🚩 Feature Flag | 🔜 To Be Enabled | — |
    | 📊 Code Coverage | 🔜 To Be Enabled | — |
    | 🤖 therock-pr-bot | ✅ Pass | — |

    🎉 All checks passed! This PR is ready for review.

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

    🙋 Wish to Override Policy?

    therock-pr-bot[bot] therock-pr-bot[bot] commented on Nov 04, 2026 18:39 UTC
    Bot

    <!-- therock-pr-bot-fix-policies -->
    🎉 All checks passed! This PR is ready for review.

    ScottTodd ScottTodd commented on Nov 10, 2026 17:54 UTC
    Author

    Ping?

    ethanwee1 ethanwee1 commented on code on Nov 10, 2026 18:13 UTC
    Code Review
    external-builds/pytorch/build_prod_wheels.py:1

    Did we mean to change it from 100755 to 100644? Approving

    ethanwee1 ethanwee1 approved these changes on Nov 10, 2026 18:13 UTC
    Approved Reviewer

    Approved these changes.

    ScottTodd ScottTodd commented on code on Nov 10, 2026 18:26 UTC
    Code Review
    external-builds/pytorch/build_prod_wheels.py:1

    No, I can change it back.

    https://github.com/ROCm/TheRock/pull/9590 also changed another test script, I wonder if coding agents just started doing that 🤔

    Reviewers
    Assignees
    ScottTodd ScottTodd
    Labels
    risk: low confidence: 81.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 81.8% · Lower = rushed or shallow review
    81.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.1% · Safe to merge
    7.1%
    Repository