Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions external-builds/pytorch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Table of contents:

- [Support status](#support-status)
- [Build instructions](#build-instructions)
- [Compiler cache](#compiler-cache)
- [Running/testing PyTorch](#runningtesting-pytorch)
- [Advanced build instructions](#advanced-build-instructions)
- [Development instructions](#development-instructions)
Expand Down Expand Up @@ -204,6 +205,46 @@ mix/match build steps.
--output-dir %HOME%/tmp/pyout
```

## Compiler cache

PyTorch wheel builds cache compiles with
[sccache](https://github.com/mozilla/sccache), not the ccache setup that covers
TheRock's CMake stages (see
[CCache Troubleshooting](/docs/development/ccache_troubleshooting.md)).

### Local builds

Pass `--use-sccache` or `--use-ccache` (not both) to `build_prod_wheels.py build`:

- `--use-sccache` sets the CMake C/C++ compiler launchers and, on Linux,
`HIP_CLANG_LAUNCHER`, so hipcc also routes HIP device compiles through
sccache.
Comment on lines +219 to +221

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to document what currently exists, but we should set -DCMAKE_HIP_COMPILER_LAUNCHER=ccache instead now, on both Linux and Windows. See #8824

We're missing out of a large number of potential cache hits with the current code here:

env = {
"CMAKE_C_COMPILER_LAUNCHER": str(sccache_path),
"CMAKE_CXX_COMPILER_LAUNCHER": str(sccache_path),
}
if hip_launcher and not is_windows:
env["HIP_CLANG_LAUNCHER"] = str(sccache_path)

See also the "Optimizing the PyTorch build" section on this recent comment of mine: #7346 (comment)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a fix for this ready, preparing a PR now.

We'll just set all three compiler launchers on both platforms, as that works now. I'll also delete build_tools/setup_sccache_rocm.py for now since there's no meaningful logic left in the file now, but we can add it back later if we want to configure the remote cache server based on release type, job triggers, etc. in there.

- `--sccache-no-wrap` skips `HIP_CLANG_LAUNCHER` and caches host C/C++ only,
for hipcc from ROCm older than 7.13.

sccache must be installed, and it uses its own configuration (a local disk
cache unless you point it elsewhere). See
[`setup_sccache_rocm.py`](/build_tools/setup_sccache_rocm.py).

### CI and release builds

The Linux and Windows wheel workflows default to `cache_type: sccache`
(`ccache` and `none` are also accepted) and store entries in S3, with a bucket
and an OIDC-assumed IAM role per release type (see
[cache buckets](/docs/development/s3_buckets.md#cache-buckets)):

| Builds | Bucket | Key prefix |
| ------- | ---------------------------------------- | ------------------------------------------------------ |
| CI | `therock-pytorch-sccache-ci` | `linux/<artifact_group>/`, `windows/<artifact_group>/` |
| Release | `therock-pytorch-sccache-<release_type>` | `linux/multiarch/v1/`, `windows/multiarch/v1/` |
Comment on lines +229 to +239

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to document what exists, but we should complete the work and limit to always sscache. Keeping the multiple options was an experiment, and the experiment is over now :)


`dev-bkc` and `nightly-bkc` release builds use the `dev` and `nightly` buckets.

Fork pull requests, and runs outside `ROCm/TheRock`, cannot assume the role, so
[`compute_pytorch_cache_type.py`](/build_tools/github_actions/compute_pytorch_cache_type.py)
switches the CI workflows to `cache_type=none` for them and they build
uncached. Each workflow prints `sccache --show-stats` after the build.

## Running/testing PyTorch

### Prerequisites
Expand Down
Loading