Skip to content

Commit 7d209c8

Browse files
Merge branch 'main' into fix-9550
2 parents b5fa53e + aea6d3f commit 7d209c8

81 files changed

Lines changed: 2585 additions & 357 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cuda-perf.yml

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
- .github/workflows/cuda-perf.yml
1313
- .ci/scripts/cuda_benchmark.py
1414
- .ci/scripts/cuda_perf_prompts/**
15+
- .ci/scripts/export_model_artifact.sh
16+
- .ci/scripts/test_model_e2e.sh
1517
workflow_dispatch:
1618
inputs:
1719
models:
@@ -32,8 +34,33 @@ concurrency:
3234
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
3335
cancel-in-progress: true
3436

37+
permissions:
38+
contents: read
39+
3540
jobs:
41+
changed-files:
42+
name: Get changed files
43+
uses: ./.github/workflows/_get-changed-files.yml
44+
with:
45+
include-push-diff: true
46+
47+
run-decision:
48+
name: CI run decision
49+
uses: ./.github/workflows/_ci-run-decision.yml
50+
3651
set-parameters:
52+
needs: [changed-files, run-decision]
53+
# Path-filtered: mirrors the workflow-level pull_request `paths:`
54+
# filter so push commits that don't touch perf-relevant paths skip
55+
# this whole workflow on non-sampled commits. Sampling preserves
56+
# perf time-series at every 4th commit (vs every commit pre-PR).
57+
if: |
58+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda-perf.yml') ||
59+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/cuda_benchmark.py') ||
60+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/cuda_perf_prompts') ||
61+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/export_model_artifact.sh') ||
62+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test_model_e2e.sh') ||
63+
needs.run-decision.outputs.is-full-run == 'true'
3764
runs-on: ubuntu-22.04
3865
outputs:
3966
benchmark_configs: ${{ steps.set-parameters.outputs.benchmark_configs }}
@@ -145,9 +172,26 @@ jobs:
145172
benchmark-cuda:
146173
name: benchmark-cuda
147174
needs:
175+
- changed-files
176+
- run-decision
148177
- set-parameters
149178
- export-models
150-
if: always()
179+
# Inherit the gate from set-parameters/export-models (they cascade-
180+
# skip when the gate evaluates false). `always()` keeps benchmark-
181+
# cuda running even when some export-models matrix cells fail —
182+
# but only if the gate itself is open. Without the explicit gate
183+
# here, `always()` would fire benchmark-cuda even when set-
184+
# parameters was gated out.
185+
if: |
186+
always() &&
187+
(
188+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda-perf.yml') ||
189+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/cuda_benchmark.py') ||
190+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/cuda_perf_prompts') ||
191+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/export_model_artifact.sh') ||
192+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test_model_e2e.sh') ||
193+
needs.run-decision.outputs.is-full-run == 'true'
194+
)
151195
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
152196
permissions:
153197
id-token: write
@@ -316,8 +360,21 @@ jobs:
316360
317361
upload-benchmark-results:
318362
needs:
363+
- changed-files
364+
- run-decision
319365
- benchmark-cuda
320-
if: always()
366+
# Same gate as benchmark-cuda — skip the upload when the gate
367+
# closed (no benchmarks ran).
368+
if: |
369+
always() &&
370+
(
371+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda-perf.yml') ||
372+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/cuda_benchmark.py') ||
373+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/cuda_perf_prompts') ||
374+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/export_model_artifact.sh') ||
375+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test_model_e2e.sh') ||
376+
needs.run-decision.outputs.is-full-run == 'true'
377+
)
321378
runs-on: ubuntu-22.04
322379
environment: upload-benchmark-results
323380
permissions:

.github/workflows/cuda-windows.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,36 @@ concurrency:
2222
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
2323
cancel-in-progress: false
2424

25+
permissions:
26+
contents: read
27+
2528
jobs:
29+
changed-files:
30+
name: Get changed files
31+
uses: ./.github/workflows/_get-changed-files.yml
32+
with:
33+
include-push-diff: true
34+
35+
run-decision:
36+
name: CI run decision
37+
uses: ./.github/workflows/_ci-run-decision.yml
38+
2639
export-model-cuda-windows-artifact:
2740
name: export-model-cuda-windows-artifact
28-
# Skip this job if the pull request is from a fork (HuggingFace secrets are not available)
29-
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
41+
# Skip this job if the pull request is from a fork (HuggingFace secrets are not available).
42+
# Path-filtered on push: mirrors the workflow-level pull_request `paths:`
43+
# filter so push commits that don't touch CUDA-relevant paths skip
44+
# this job on non-sampled commits. See _ci-run-decision.yml for
45+
# the sampling policy.
46+
needs: [changed-files, run-decision]
47+
if: |
48+
(github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') &&
49+
(
50+
contains(needs.changed-files.outputs.changed-files, 'backends/cuda') ||
51+
contains(needs.changed-files.outputs.changed-files, 'backends/aoti') ||
52+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda-windows.yml') ||
53+
needs.run-decision.outputs.is-full-run == 'true'
54+
)
3055
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
3156
permissions:
3257
id-token: write
@@ -114,7 +139,20 @@ jobs:
114139
115140
test-model-cuda-windows-e2e:
116141
name: test-model-cuda-windows-e2e
117-
needs: export-model-cuda-windows-artifact
142+
# Same path filter as the export job above. Also explicitly gated
143+
# on the export job succeeding — when needs: jobs are *skipped*
144+
# (e.g. fork PR), GitHub still evaluates this if:, so without the
145+
# explicit success-check this job would run and then fail trying
146+
# to download an artifact that was never produced.
147+
needs: [changed-files, export-model-cuda-windows-artifact, run-decision]
148+
if: |
149+
needs.export-model-cuda-windows-artifact.result == 'success' &&
150+
(
151+
contains(needs.changed-files.outputs.changed-files, 'backends/cuda') ||
152+
contains(needs.changed-files.outputs.changed-files, 'backends/aoti') ||
153+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda-windows.yml') ||
154+
needs.run-decision.outputs.is-full-run == 'true'
155+
)
118156
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
119157
strategy:
120158
fail-fast: false

.github/workflows/cuda.yml

Lines changed: 109 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,42 @@ on:
2020
- .github/workflows/cuda.yml
2121
- backends/cuda/**
2222
- backends/aoti/**
23+
- .ci/scripts/test-cuda-build.sh
24+
- .ci/scripts/export_model_artifact.sh
25+
- .ci/scripts/test_model_e2e.sh
2326
workflow_dispatch:
2427

2528
concurrency:
2629
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
2730
cancel-in-progress: false
2831

32+
permissions:
33+
contents: read
34+
2935
jobs:
36+
changed-files:
37+
name: Get changed files
38+
uses: ./.github/workflows/_get-changed-files.yml
39+
with:
40+
include-push-diff: true
41+
42+
run-decision:
43+
name: CI run decision
44+
uses: ./.github/workflows/_ci-run-decision.yml
45+
3046
test-cuda-builds:
47+
needs: [changed-files, run-decision]
48+
# Path-filtered: mirrors the workflow-level pull_request `paths:`
49+
# filter so push commits that don't touch CUDA-relevant paths skip
50+
# this job on non-sampled commits.
51+
if: |
52+
contains(needs.changed-files.outputs.changed-files, 'backends/cuda') ||
53+
contains(needs.changed-files.outputs.changed-files, 'backends/aoti') ||
54+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda.yml') ||
55+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test-cuda-build.sh') ||
56+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/export_model_artifact.sh') ||
57+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test_model_e2e.sh') ||
58+
needs.run-decision.outputs.is-full-run == 'true'
3159
strategy:
3260
fail-fast: false
3361
matrix:
@@ -55,9 +83,22 @@ jobs:
5583
5684
# This job will fail if any of the CUDA versions fail
5785
check-all-cuda-builds:
58-
needs: test-cuda-builds
86+
needs: [changed-files, run-decision, test-cuda-builds]
5987
runs-on: ubuntu-latest
60-
if: always()
88+
# Run only if the test-cuda-builds matrix actually ran (i.e. the same
89+
# path/sample gate as test-cuda-builds itself). Otherwise this job
90+
# would fire on every commit and fail because needs.result == 'skipped'.
91+
if: |
92+
always() &&
93+
(
94+
contains(needs.changed-files.outputs.changed-files, 'backends/cuda') ||
95+
contains(needs.changed-files.outputs.changed-files, 'backends/aoti') ||
96+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda.yml') ||
97+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test-cuda-build.sh') ||
98+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/export_model_artifact.sh') ||
99+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test_model_e2e.sh') ||
100+
needs.run-decision.outputs.is-full-run == 'true'
101+
)
61102
steps:
62103
- name: Check if all CUDA builds succeeded
63104
run: |
@@ -71,6 +112,15 @@ jobs:
71112
72113
test-models-cuda:
73114
name: test-models-cuda
115+
needs: [changed-files, run-decision]
116+
if: |
117+
contains(needs.changed-files.outputs.changed-files, 'backends/cuda') ||
118+
contains(needs.changed-files.outputs.changed-files, 'backends/aoti') ||
119+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda.yml') ||
120+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test-cuda-build.sh') ||
121+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/export_model_artifact.sh') ||
122+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test_model_e2e.sh') ||
123+
needs.run-decision.outputs.is-full-run == 'true'
74124
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
75125
permissions:
76126
id-token: write
@@ -106,6 +156,15 @@ jobs:
106156
107157
unittest-cuda:
108158
name: unittest-cuda
159+
needs: [changed-files, run-decision]
160+
if: |
161+
contains(needs.changed-files.outputs.changed-files, 'backends/cuda') ||
162+
contains(needs.changed-files.outputs.changed-files, 'backends/aoti') ||
163+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda.yml') ||
164+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test-cuda-build.sh') ||
165+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/export_model_artifact.sh') ||
166+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test_model_e2e.sh') ||
167+
needs.run-decision.outputs.is-full-run == 'true'
109168
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
110169
permissions:
111170
id-token: write
@@ -154,8 +213,22 @@ jobs:
154213
155214
export-model-cuda-artifact:
156215
name: export-model-cuda-artifact
157-
# Skip this job if the pull request is from a fork (HuggingFace secrets are not available)
158-
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
216+
# Skip this job if the pull request is from a fork (HuggingFace secrets are not available).
217+
# Path-filtered on push: mirrors the workflow-level pull_request `paths:`
218+
# filter so push commits that don't touch CUDA-relevant paths skip
219+
# this job on non-sampled commits.
220+
needs: [changed-files, run-decision]
221+
if: |
222+
(github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') &&
223+
(
224+
contains(needs.changed-files.outputs.changed-files, 'backends/cuda') ||
225+
contains(needs.changed-files.outputs.changed-files, 'backends/aoti') ||
226+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda.yml') ||
227+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test-cuda-build.sh') ||
228+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/export_model_artifact.sh') ||
229+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test_model_e2e.sh') ||
230+
needs.run-decision.outputs.is-full-run == 'true'
231+
)
159232
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
160233
permissions:
161234
id-token: write
@@ -300,7 +373,23 @@ jobs:
300373
301374
test-model-cuda-e2e:
302375
name: test-model-cuda-e2e
303-
needs: export-model-cuda-artifact
376+
# Same path filter as export-model-cuda-artifact above. Also explicitly
377+
# gated on the export job succeeding — when needs: jobs are *skipped*
378+
# (e.g. fork PR), GitHub still evaluates this if:, so without the
379+
# explicit success-check this job would run and then fail trying
380+
# to download an artifact that was never produced.
381+
needs: [changed-files, export-model-cuda-artifact, run-decision]
382+
if: |
383+
needs.export-model-cuda-artifact.result == 'success' &&
384+
(
385+
contains(needs.changed-files.outputs.changed-files, 'backends/cuda') ||
386+
contains(needs.changed-files.outputs.changed-files, 'backends/aoti') ||
387+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda.yml') ||
388+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test-cuda-build.sh') ||
389+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/export_model_artifact.sh') ||
390+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test_model_e2e.sh') ||
391+
needs.run-decision.outputs.is-full-run == 'true'
392+
)
304393
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
305394
permissions:
306395
id-token: write
@@ -417,8 +506,22 @@ jobs:
417506
418507
test-cuda-pybind:
419508
name: test-cuda-pybind
420-
needs: export-model-cuda-artifact
421509
# This job downloads models exported by export-model-cuda-artifact and runs them using pybind.
510+
# Same gating as test-model-cuda-e2e — explicit success-check on the
511+
# export job so a skipped export (fork PR, non-sampled push, no path
512+
# match) auto-skips this job too.
513+
needs: [changed-files, export-model-cuda-artifact, run-decision]
514+
if: |
515+
needs.export-model-cuda-artifact.result == 'success' &&
516+
(
517+
contains(needs.changed-files.outputs.changed-files, 'backends/cuda') ||
518+
contains(needs.changed-files.outputs.changed-files, 'backends/aoti') ||
519+
contains(needs.changed-files.outputs.changed-files, '.github/workflows/cuda.yml') ||
520+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test-cuda-build.sh') ||
521+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/export_model_artifact.sh') ||
522+
contains(needs.changed-files.outputs.changed-files, '.ci/scripts/test_model_e2e.sh') ||
523+
needs.run-decision.outputs.is-full-run == 'true'
524+
)
422525
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
423526
permissions:
424527
id-token: write

0 commit comments

Comments
 (0)