Skip to content

Commit

Permalink
Use the build environment as sccache prefix instead of workflow name (p…
Browse files Browse the repository at this point in the history
…ytorch#144112)

This is an attempt to improve cache usage for jobs in non-pull workflows like periodic, slow, or inductor as we are seeing build timeout there from time to time, for example https://github.com/pytorch/pytorch/actions/runs/12553928804.  The build timeout never happens in pull or trunk AFAICT because they are more up to date with the cache content coming from the PR itself.

Logically, the same build should use the same cache regardless of the workflows.  We have many examples where the same build, for example [linux-focal-cuda12.4-py3.10-gcc9-sm86](https://github.com/search?q=repo%3Apytorch%2Fpytorch+linux-focal-cuda12.4-py3.10-gcc9-sm86&type=code), is split between different workflows and, thus, uses different caches.

I could gather some sccache stats from CH in the meantime to try to prove the improvement before and after this lands.
Pull Request resolved: pytorch#144112
Approved by: https://github.com/malfet
  • Loading branch information
huydhn authored and pytorchmergebot committed Jan 3, 2025
1 parent b9fbd65 commit cbdc70a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/_linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ jobs:
SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
SCCACHE_BUCKET: ossci-compiler-cache-circleci-v2
SCCACHE_REGION: us-east-1
SCCACHE_S3_KEY_PREFIX: ${{ github.workflow }}
# Use the build environment here to make sure that all build jobs in the same environment
# will share the same cache regardless of which workflow they belong. This should improve
# the cache usage for jobs in non-pull workflows like periodic, slow, or inductor
SCCACHE_S3_KEY_PREFIX: ${{ inputs.build-environment || github.workflow }}
XLA_CLANG_CACHE_S3_BUCKET_NAME: ossci-compiler-clang-cache-circleci-xla
PR_LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
TORCH_CUDA_ARCH_LIST: ${{ inputs.cuda-arch-list }}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/_linux-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ jobs:
TD_DISTRIBUTED: ${{ steps.keep-going.outputs.ci-td-distributed }}
SCCACHE_BUCKET: ossci-compiler-cache-circleci-v2
SCCACHE_REGION: us-east-1
SCCACHE_S3_KEY_PREFIX: ${{ github.workflow }}
# Use the build environment here to make sure that all build jobs in the same environment
# will share the same cache regardless of which workflow they belong. This should improve
# the cache usage for jobs in non-pull workflows like periodic, slow, or inductor
SCCACHE_S3_KEY_PREFIX: ${{ inputs.build-environment || github.workflow }}
SHM_SIZE: ${{ contains(inputs.build-environment, 'cuda') && '2g' || '1g' }}
DOCKER_IMAGE: ${{ inputs.docker-image }}
XLA_CUDA: ${{ contains(inputs.build-environment, 'xla') && '0' || '' }}
Expand Down

0 comments on commit cbdc70a

Please sign in to comment.