2626 description : " Ref (branch/sha) to checkout"
2727 required : false
2828 type : string
29+ # Label-triggered profiling: add the 'profile-enabled' label to a PR and this
30+ # workflow profiles the target declared in .github/profile-target.env
31+ # (CONFIG_KEY / CONFIG_FILE / CONC), emitting a Perfetto trace as an artifact
32+ # plus a relay link. Gated in the get-jobs `if` below so only labelled PRs run.
33+ pull_request :
34+ types : [labeled, synchronize, reopened]
2935
3036permissions :
3137 contents : read
4046
4147jobs :
4248 get-jobs :
49+ # Run for manual dispatch, or for a PR carrying the 'profile-enabled' label.
50+ if : >-
51+ ${{ github.event_name == 'workflow_dispatch' ||
52+ (github.event_name == 'pull_request' &&
53+ contains(github.event.pull_request.labels.*.name, 'profile-enabled')) }}
4354 runs-on : ubuntu-latest
4455 outputs :
4556 filtered-matrix : ${{ steps.filter.outputs.filtered }}
4657 count : ${{ steps.filter.outputs.count }}
58+ ref : ${{ steps.preref.outputs.ref }}
59+ moe-debug : ${{ steps.target.outputs.moe_debug }}
4760 steps :
61+ - name : Resolve checkout ref
62+ id : preref
63+ run : |
64+ if [ "${{ github.event_name }}" = "pull_request" ]; then
65+ echo "ref=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
66+ else
67+ echo "ref=${{ inputs.ref || github.sha }}" >> "$GITHUB_OUTPUT"
68+ fi
69+
4870 - name : Checkout code
4971 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5072 with :
51- ref : ${{ inputs.ref || github.sha }}
73+ ref : ${{ steps.preref.outputs.ref }}
74+
75+ - name : Resolve profile target (dispatch inputs or PR target file)
76+ id : target
77+ run : |
78+ set -euo pipefail
79+ if [ "${{ github.event_name }}" = "pull_request" ]; then
80+ f=.github/profile-target.env
81+ if [ ! -f "$f" ]; then
82+ echo "::error::$f is required for label-triggered profiling" >&2
83+ exit 1
84+ fi
85+ ck=$(grep -E '^CONFIG_KEY=' "$f" | head -1 | cut -d= -f2-)
86+ cf=$(grep -E '^CONFIG_FILE=' "$f" | head -1 | cut -d= -f2-)
87+ cc=$(grep -E '^CONC=' "$f" | head -1 | cut -d= -f2-)
88+ md=$(grep -E '^MOE_DEBUG=' "$f" | head -1 | cut -d= -f2- || true)
89+ if [ -z "$ck" ]; then echo "::error::CONFIG_KEY missing in $f" >&2; exit 1; fi
90+ echo "config_key=${ck}" >> "$GITHUB_OUTPUT"
91+ echo "config_file=${cf:-.github/configs/nvidia-master.yaml}" >> "$GITHUB_OUTPUT"
92+ echo "conc=${cc:-64}" >> "$GITHUB_OUTPUT"
93+ echo "moe_debug=${md:-false}" >> "$GITHUB_OUTPUT"
94+ else
95+ echo "config_key=${{ inputs.config-key }}" >> "$GITHUB_OUTPUT"
96+ echo "config_file=${{ inputs.config-file }}" >> "$GITHUB_OUTPUT"
97+ echo "conc=${{ inputs.conc }}" >> "$GITHUB_OUTPUT"
98+ echo "moe_debug=${{ inputs.moe-debug }}" >> "$GITHUB_OUTPUT"
99+ fi
52100
53101 - id : gen
54102 name : Generate matrix via script
55103 run : |
56104 pip install pydantic
57- CLI_ARGS="test-config --config-files ${{ inputs.config-file }} --config-keys ${{ inputs.config-key }} --conc ${{ inputs .conc }}"
105+ CLI_ARGS="test-config --config-files ${{ steps.target.outputs.config_file }} --config-keys ${{ steps.target.outputs.config_key }} --conc ${{ steps.target.outputs .conc }}"
58106 CONFIG_JSON=$(python3 ${GITHUB_WORKSPACE}/utils/matrix_logic/generate_sweep_configs.py $CLI_ARGS)
59107 echo "raw=$CONFIG_JSON" >> $GITHUB_OUTPUT
60108
61109 - id : filter
62- name : Take first generated job
110+ name : Select one job per concurrency
63111 shell : python
64112 run : |
65113 import json, os, sys
@@ -78,7 +126,16 @@ jobs:
78126 f.write("filtered=[]\ncount=0\n")
79127 raise SystemExit(1)
80128
81- filt = data[:1]
129+ # One job per (concurrency, tp): the first config generated for each
130+ # (conc, tp) pair — i.e. the leading 1k1k search-space row of each TP —
131+ # ordered by (conc, tp). This profiles both TP4 and TP8 at every conc.
132+ # A single conc/tp still yields one job (backward compatible).
133+ by_key = {}
134+ for job in data:
135+ k = (job.get("conc"), job.get("tp"))
136+ if k not in by_key:
137+ by_key[k] = job
138+ filt = [by_key[k] for k in sorted(by_key)]
82139
83140 out = json.dumps(filt)
84141 print(out)
@@ -115,8 +172,14 @@ jobs:
115172 CONC : ${{ matrix.config.conc }}
116173 SPEC_DECODING : ${{ matrix.config.spec-decoding }}
117174 DISAGG : ${{ matrix.config.disagg }}
175+ # The single-node launchers resolve the recipe path as
176+ # benchmarks/single_node/${SCENARIO_SUBDIR}<exp>_<prec>_<hw>.sh and run
177+ # under `set -u`; the sweep's benchmark-tmpl.yml sets this, so profile.yml
178+ # must too. Profiling is fixed-seq-len (mi325x/mi300x launchers don't
179+ # default it the way mi355x does).
180+ SCENARIO_SUBDIR : fixed_seq_len/
118181 MOE_DEBUG : ' 0'
119- MOE_DEBUG_LOG : ${{ (inputs. moe-debug) && '/workspace/moe_debug.tp0.log' || '' }}
182+ MOE_DEBUG_LOG : ${{ needs.get-jobs.outputs. moe-debug == 'true' && '/workspace/moe_debug.tp0.log' || '' }}
120183 steps :
121184 - name : Resource cleanup
122185 run : |
@@ -145,7 +208,7 @@ jobs:
145208 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
146209 with :
147210 fetch-depth : 0
148- ref : ${{ inputs.ref || github.sha }}
211+ ref : ${{ needs.get-jobs.outputs.ref }}
149212 clean : false
150213
151214 - name : Launch + Profile (single-node sglang/vllm)
@@ -261,7 +324,17 @@ jobs:
261324 git config user.email "github-actions@github.com"
262325 git add -A
263326 git commit -m "Add profile: ${GITHUB_SHA} ${{ matrix.config['exp-name'] }} tp${{ matrix.config.tp }} ep${{ matrix.config.ep || 1 }} conc${{ matrix.config.conc }}" || echo "Nothing to commit"
264- git push
327+ # Parallel matrix jobs (one per conc) all push to this same repo, so a
328+ # plain push races and is rejected non-fast-forward. Rebase onto the
329+ # latest remote and retry with jitter until it lands.
330+ for attempt in 1 2 3 4 5 6 7 8; do
331+ if git push; then break; fi
332+ echo "push rejected (attempt ${attempt}); rebasing on origin/master"
333+ git fetch origin master --quiet
334+ git rebase origin/master
335+ if [ "$attempt" = 8 ]; then echo "push failed after ${attempt} attempts" >&2; exit 1; fi
336+ sleep $(( (RANDOM % 6) + 2 ))
337+ done
265338 STORAGE_SHA="$(git rev-parse HEAD)"
266339 popd >/dev/null
267340
0 commit comments