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
2528concurrency :
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+
2935jobs :
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 :
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