Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/scripts/op_tune.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,22 @@ declare -a tune_jobs=(

for job in "${tune_jobs[@]}"; do
IFS=':' read -r shape dir test_path tune_cmd <<< "$job"
if [ -n "$shape_filter" ] && [ "$shape" != "$shape_filter" ]; then
continue
# If shape_filter is not empty, check if the current shape exists in the filter list.
# shape_filter is a comma-separated list, e.g. "ck_gemm_a8w8,ck_batched_gemm_a8w8"
if [ -n "$shape_filter" ]; then
# Remove all whitespace from the shape_filter string
shape_filter_no_space="${shape_filter//[[:space:]]/}"
IFS=',' read -ra filter_shapes <<< "$shape_filter_no_space"
found_match=false
for filter_shape in "${filter_shapes[@]}"; do
if [[ "$shape" == "$filter_shape" ]]; then
found_match=true
break
fi
done
if [ "$found_match" = false ]; then
continue
fi
fi
echo "============================================================"
echo "🧪 Processing shape: $shape under directory: $dir"
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/operators-tuning.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: Operators Tuning

on:
pull_request:
paths:
- 'aiter/configs/*untuned*.csv'
workflow_dispatch:
inputs:
shapes:
description: 'Comma separated shape names to run (leave empty for all)'
description: 'Comma separated shape names to run, e.g. ck_batched_gemm_a8w8, ck_gemm_a8w8, ck_gemm_a8w8_blockscale, ck_gemm_a8w8_blockscale_bpreshuffle, ck_gemm_a8w8_bpreshuffle etc. (leave empty for all)'
required: false
default: ''
arguments:
Expand Down Expand Up @@ -81,7 +78,7 @@ jobs:
docker exec \
-w /workspace \
operators_tuning_test \
./.github/scripts/op_tune.sh test "${{ github.event.inputs.shapes }}"
./.github/scripts/op_tune.sh test "ck_batched_gemm_a8w8, ck_gemm_a8w8, ck_gemm_a8w8_blockscale"

- name: Operators tuning Tests
run: |
Expand All @@ -90,7 +87,7 @@ jobs:
docker exec \
-w /workspace \
operators_tuning_test \
./.github/scripts/op_tune.sh tune "${{ github.event.inputs.shapes }}" "${{ github.event.inputs.arguments }}"
./.github/scripts/op_tune.sh tune "ck_batched_gemm_a8w8, ck_gemm_a8w8, ck_gemm_a8w8_blockscale" "${{ github.event.inputs.arguments }}"

- name: Show the difference after tuning
run: |
Expand All @@ -103,7 +100,7 @@ jobs:
docker exec \
-w /workspace \
operators_tuning_test \
./.github/scripts/op_tune.sh test "${{ github.event.inputs.shapes }}"
./.github/scripts/op_tune.sh test "ck_batched_gemm_a8w8, ck_gemm_a8w8, ck_gemm_a8w8_blockscale"

- name: Upload tuned CSVs
uses: actions/upload-artifact@v4
Expand Down
17 changes: 17 additions & 0 deletions docs/autotuning_pipeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Autotuning Pipelines in Aiter CI

## What is the tuning pipeline workflow?

An automated tuning system that ingests and benchmarks a volume of inputs, then records the best operator for each input in a database based on test results, so that future identical inputs can directly return the optimal operator.

## Implementation

In the Aiter repository, there are tuning scripts designed for various shapes, such as `aiter/csrc/ck_batched_gemm_a8w8` (see: [ROCm/aiter](https://github.com/ROCm/aiter)).

Running these scripts generates tuned results, which are stored in the `aiter/configs` directory, for example: `aiter/configs/a8w8_tuned_batched_gemm.csv`. These CSV files are compiled during the Aiter installation process and are referenced when using Aiter operators.

Based on this, we provide CI pipelines to generate and use these tuned CSV files:

- [Manual Pipeline](https://github.com/ROCm/aiter/actions/workflows/operators-tuning.yaml): Allows users to select specific shapes to tune and choose whether to upload the results to the Aiter repository.

- Scheduled Pipeline: Runs nightly or weekly to generate all tuned CSV files and automatically upload the results to the Aiter repository.