diff --git a/.github/scripts/op_tune.sh b/.github/scripts/op_tune.sh index cbde287bb2..68e17d1cc4 100755 --- a/.github/scripts/op_tune.sh +++ b/.github/scripts/op_tune.sh @@ -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" diff --git a/.github/workflows/operators-tuning.yaml b/.github/workflows/operators-tuning.yaml index 3b1a0d199c..6563a33b4c 100644 --- a/.github/workflows/operators-tuning.yaml +++ b/.github/workflows/operators-tuning.yaml @@ -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: @@ -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: | @@ -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: | @@ -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 diff --git a/docs/autotuning_pipeline.md b/docs/autotuning_pipeline.md new file mode 100644 index 0000000000..45c3416723 --- /dev/null +++ b/docs/autotuning_pipeline.md @@ -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.