@@ -132,29 +132,97 @@ jobs:
132132 mkdir -p "$TEST_REPORTS_DIR"
133133 echo "$TEST_REPORTS_DIR"
134134
135- # Do autotuning but do not record the results
136- python benchmarks/run.py \
137- --op $KERNEL_LIST \
138- --metrics speedup,accuracy \
139- --latency-measure-mode triton_do_bench \
140- --cudagraph \
141- --only triton,liger,torch_compile,helion \
142- --only-match-mode prefix-with-baseline \
143- --exit-on-exception
144-
145- # Relax the GPU
146- sleep 5m
147-
148- # Run again with cache and record results
149- python benchmarks/run.py \
150- --op $KERNEL_LIST \
151- --metrics speedup,accuracy \
152- --latency-measure-mode triton_do_bench \
153- --cudagraph \
154- --only triton,liger,torch_compile,helion \
155- --only-match-mode prefix-with-baseline \
156- --output "$TEST_REPORTS_DIR/helionbench.json" \
157- --exit-on-exception
135+ # Run kernels one by one in a for loop
136+ for kernel in "${SHARD_KERNELS[@]}"; do
137+ echo "=========================================="
138+ echo "Running benchmark for kernel: $kernel"
139+ echo "=========================================="
140+
141+ # Get available implementations and baseline for this kernel
142+ KERNEL_INFO=$(python benchmarks/run.py --list-impls-for-benchmark-ci --op $kernel | grep "^$kernel:")
143+ IMPLS=$(echo "$KERNEL_INFO" | sed -n 's/.*impls=\([^ ]*\).*/\1/p')
144+ BASELINE=$(echo "$KERNEL_INFO" | sed -n 's/.*baseline=\([^ ]*\).*/\1/p')
145+
146+ if [[ -z "$IMPLS" ]]; then
147+ echo "Warning: No implementations found for kernel $kernel, skipping..."
148+ continue
149+ fi
150+
151+ if [[ -z "$BASELINE" ]]; then
152+ echo "Warning: No baseline found for kernel $kernel"
153+ else
154+ echo "Using baseline: $BASELINE"
155+ fi
156+ echo "Available implementations for $kernel: $IMPLS"
157+
158+ # Do autotuning but do not record the results
159+ RUN_CMD="python benchmarks/run.py \
160+ --op $kernel \
161+ --metrics speedup,accuracy \
162+ --latency-measure-mode triton_do_bench \
163+ --cudagraph \
164+ --only $IMPLS \
165+ --only-match-mode prefix-with-baseline"
166+
167+ # Add baseline if available
168+ if [[ -n "$BASELINE" ]]; then
169+ RUN_CMD="$RUN_CMD --baseline $BASELINE"
170+ fi
171+
172+ eval "$RUN_CMD --exit-on-exception"
173+
174+ # Relax the GPU
175+ sleep 2m
176+
177+ # Run again with cache and record results
178+ RUN_CMD="python benchmarks/run.py \
179+ --op $kernel \
180+ --metrics speedup,accuracy \
181+ --latency-measure-mode triton_do_bench \
182+ --cudagraph \
183+ --only $IMPLS \
184+ --only-match-mode prefix-with-baseline \
185+ --output \"$TEST_REPORTS_DIR/helionbench_${kernel}.json\""
186+
187+ # Add baseline if available
188+ if [[ -n "$BASELINE" ]]; then
189+ RUN_CMD="$RUN_CMD --baseline $BASELINE"
190+ fi
191+
192+ eval "$RUN_CMD --exit-on-exception"
193+
194+ if [[ ! -s "$TEST_REPORTS_DIR/helionbench_${kernel}.json" ]]; then
195+ echo "❌ helionbench_${kernel}.json is missing or empty"
196+ exit 1
197+ fi
198+ echo "✅ Completed benchmark for kernel: $kernel"
199+ done
200+
201+ # Merge all individual kernel results into a single file
202+ echo "Merging benchmark results..."
203+ python -c "
204+ import json
205+ import glob
206+ import os
207+
208+ test_reports_dir = '$TEST_REPORTS_DIR'
209+ result_files = sorted(glob.glob(os.path.join(test_reports_dir, 'helionbench_*.json')))
210+
211+ if not result_files :
212+ print('❌ No result files found')
213+ exit(1)
214+
215+ merged_results = []
216+ for file in result_files :
217+ with open(file, 'r') as f :
218+ kernel_results = json.load(f)
219+ merged_results.extend(kernel_results)
220+
221+ with open(os.path.join(test_reports_dir, 'helionbench.json'), 'w') as f :
222+ json.dump(merged_results, f, indent=2)
223+
224+ print(f'✅ Merged {len(result_files)} kernel results into helionbench.json')
225+ "
158226
159227 if [[ ! -s " $TEST_REPORTS_DIR/helionbench.json" ]]; then
160228 echo "❌ helionbench.json is missing or empty"
0 commit comments