Repository navigation
253 lines (236 loc) · 10.3 KB
/
Copy pathsass-diff.yml
File metadata and controls
253 lines (236 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
name: SASS Diff
defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}
on:
workflow_call:
inputs:
id:
description: "Stable SASS comparison config id."
required: true
type: string
project:
description: "Project whose benchmarks ci/sass/sass_diff.sh compares, for example 'cub'."
required: true
type: string
launch_args:
description: "'.devcontainer/launch.sh -d' additional args."
required: true
type: string
preset:
description: "CMake preset passed to ci/sass/sass_diff.sh."
required: true
type: string
archs:
description: "CMAKE_CUDA_ARCHITECTURES, for example '70;80;90'."
required: true
type: string
target_filters_json:
description: "JSON array of regexes matched against the build targets."
required: true
type: string
base_ref:
description: "Baseline ref. Normally the PR merge base."
required: true
type: string
artifact_retention_days:
description: "Artifact retention in days."
required: false
default: 14
type: number
secrets:
inference_api_key:
description: "NVIDIA Inference Hub API key, for the triage of the differences."
required: true
jobs:
run:
name: "SASS diff: ${{ inputs.id }}"
# No GPU is necessary: the benchmarks are compiled and disassembled, not
# run. A CPU runner is enough and is much cheaper.
runs-on: |-
${{ contains(fromJSON('["NVIDIA", "NVIDIA-dev"]'), github.repository_owner) &&
'linux-amd64-cpu32m' || 'ubuntu-latest' }}
permissions:
id-token: write
contents: read
env:
# Every step reads and writes this one directory, so it is defined once
# here instead of being recomputed per step.
ARTIFACT_ROOT: sass-artifacts/${{ inputs.id }}
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
# The comparison adds a worktree for the base ref, so the full
# history is necessary.
fetch-depth: 0
persist-credentials: false
- name: Get AWS credentials for sccache bucket
if: ${{ contains(fromJSON('["NVIDIA", "NVIDIA-dev"]'), github.repository_owner) }}
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: arn:aws:iam::279114543810:role/gha-oidc-NVIDIA
aws-region: us-east-2
role-duration-seconds: 43200 # 12 hours
- name: Prepare AWS config for devcontainer
run: |
# Credentials can be unset when AWS setup is skipped.
# The devcontainer mounts this path to /home/coder/.aws.
aws_dir="${{ github.workspace }}/.aws"
mkdir -p "${aws_dir}"
cat > "${aws_dir}/config" <<EOF
[default]
bucket=rapids-sccache-devs
region=us-east-2
EOF
cat > "${aws_dir}/credentials" <<EOF
[default]
aws_access_key_id=${AWS_ACCESS_KEY_ID:-}
aws_session_token=${AWS_SESSION_TOKEN:-}
aws_secret_access_key=${AWS_SECRET_ACCESS_KEY:-}
EOF
chmod 0600 "${aws_dir}/credentials"
chmod 0664 "${aws_dir}/config"
# A SASS change is a result, not a fault. Thus it does not fail this job. The result
# is in result/report.json, and the comment artifact holds a copy for
# `sass-results`. That job posts the result but does not fail on a change.
- name: Compare SASS
id: compare
env:
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
AWS_REGION: ${{ env.AWS_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ env.AWS_SESSION_TOKEN }}
ARCHS: ${{ inputs.archs }}
BASE_REF: ${{ inputs.base_ref }}
LAUNCH_ARGS: ${{ inputs.launch_args }}
PRESET: ${{ inputs.preset }}
PROJECT: ${{ inputs.project }}
TARGET_FILTERS_JSON: ${{ inputs.target_filters_json }}
run: |
mkdir -p "${ARTIFACT_ROOT}"
# LAUNCH_ARGS intentionally contains multiple launch arguments.
# shellcheck disable=SC2086
.devcontainer/launch.sh \
-d ${LAUNCH_ARGS} \
--env "AWS_ROLE_ARN=" \
--env "AWS_REGION=${AWS_REGION}" \
--env "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" \
--env "AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}" \
--env "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" \
--env "CCCL_BUILD_INFIX=sass-${{ inputs.id }}" \
--env "SCCACHE_REGION=${AWS_REGION}" \
--volume "${GITHUB_WORKSPACE}/${ARTIFACT_ROOT}:/sass-artifacts" \
-- ./ci/sass/sass_diff.sh \
"${PROJECT}" \
"${BASE_REF}" \
HEAD \
-preset "${PRESET}" \
-arch "${ARCHS}" \
-output-dir /sass-artifacts \
-target-filters-json "${TARGET_FILTERS_JSON}"
has_changes="$(jq 'any(.targets[].archs[]; .changed)' "${ARTIFACT_ROOT}/result/report.json")"
echo "has_changes=${has_changes}" >> "${GITHUB_OUTPUT}"
# The disassembly itself is not uploaded, `sass_diff.sh` writes four complete copies
# of it, under base/, test/, result/base/ and result/test/. Over 82 benchmark
# targets and six architectures that reaches several GB per run, while the files
# below are a few MB. To read the SASS itself, run `ci/sass/sass_diff.sh` and open
# the local artifact directory, which keeps every file.
- name: Upload the SASS dumps
id: dumps
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: sass-${{ inputs.id }}-dumps
path: |
${{ env.ARTIFACT_ROOT }}/result/diff
${{ env.ARTIFACT_ROOT }}/result/report.json
${{ env.ARTIFACT_ROOT }}/result/meta.json
if-no-files-found: error
retention-days: ${{ inputs.artifact_retention_days }}
- name: Set up Node for triage
if: ${{ steps.compare.outputs.has_changes == 'true' }}
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
with:
node-version: 24
# The action invokes node through sudo, whose PATH excludes the tool cache.
#
# See https://github.com/openai/codex-action/issues/180
- name: Make Node available to sudo
if: ${{ steps.compare.outputs.has_changes == 'true' }}
run: |
command -v node > "${RUNNER_TEMP}/triage-node-path"
read -r node_path < "${RUNNER_TEMP}/triage-node-path"
sudo -n ln -s "${node_path}" /usr/local/bin/node
sudo -n node --version
# codex-action applies this setup only on GitHub-hosted runners, before dropping
# sudo. https://github.com/openai/codex-action/blob/52fe01ec70a42f454c9d2ebd47598f9fd6893d56/action.yml#L262-L284
#
# Otherwise it errors with:
#
# ERROR codex_core::session: Failed to create session: failed to load AGENTS.md
# instructions for environment `local`: fs sandbox helper failed with status exit
# status: 1: bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted
- name: Enable namespaces for Codex sandbox
if: ${{ steps.compare.outputs.has_changes == 'true' }}
run: |
sudo sysctl -w kernel.unprivileged_userns_clone=1
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
- name: Prepare the triage environment
if: ${{ steps.compare.outputs.has_changes == 'true' }}
run: |
mkdir -p "${RUNNER_TEMP}/codex-home"
cp ci/sass/sass_triage_config.toml "${RUNNER_TEMP}/codex-home/config.toml"
# A triage failure must not hide the comparison, thus this step does not fail the
# job. The collect step below keeps the analysis only when this step wrote a file.
- name: Triage the SASS differences
id: triage
if: ${{ steps.compare.outputs.has_changes == 'true' }}
timeout-minutes: 30
continue-on-error: true
uses: openai/codex-action@52fe01ec70a42f454c9d2ebd47598f9fd6893d56 # v1.11
env:
SASS_RESULT_DIR: ${{ github.workspace }}/${{ env.ARTIFACT_ROOT }}/result
with:
openai-api-key: ${{ secrets.inference_api_key }}
responses-api-endpoint: https://inference-api.nvidia.com/v1/responses
codex-version: 0.149.0
codex-home: ${{ runner.temp }}/codex-home
permission-profile: sass_triage
safety-strategy: drop-sudo
allow-bot-users: "copy-pr-bot[bot]"
model: openai/openai/gpt-5.6-sol
effort: high
codex-args: --strict-config --ephemeral
output-file: ${{ runner.temp }}/sass-analysis.json
output-schema-file: ci/sass/model-output.schema.json
prompt-file: ci/sass/sass_triage_prompt.md
# After the dumps upload, because meta.json gets the URL of that artifact.
- name: Collect the comment inputs
env:
ARTIFACTS_URL: ${{ steps.dumps.outputs.artifact-url }}
ANALYSIS_FILE: ${{ runner.temp }}/sass-analysis.json
TRIAGE_OUTCOME: ${{ steps.triage.outcome }}
run: |
meta="${ARTIFACT_ROOT}/result/meta.json"
jq --arg artifacts_url "${ARTIFACTS_URL}" '. + {artifacts_url: $artifacts_url}' \
"${meta}" > "${RUNNER_TEMP}/meta.json"
mv "${RUNNER_TEMP}/meta.json" "${meta}"
if [[ "${TRIAGE_OUTCOME}" == "success" ]] && [[ -s "${ANALYSIS_FILE}" ]]; then
cp "${ANALYSIS_FILE}" "${ARTIFACT_ROOT}/result/analysis.json"
else
echo "No SASS triage to render (outcome: ${TRIAGE_OUTCOME})."
fi
# `sass-results` downloads this artifact with the `sass-*-comment` pattern. It stays
# separate from the dumps, which are large and which no job reads. analysis.json
# exists only when the triage succeeded.
- name: Upload the SASS comment
uses: actions/upload-artifact@v4
with:
name: sass-${{ inputs.id }}-comment
path: |
${{ env.ARTIFACT_ROOT }}/result/report.json
${{ env.ARTIFACT_ROOT }}/result/meta.json
${{ env.ARTIFACT_ROOT }}/result/analysis.json
if-no-files-found: error
retention-days: ${{ inputs.artifact_retention_days }}