-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add perf report for reduce scatter async (#17223)
### Ticket #16648 ### Problem description Provide context for the problem. ### What's changed <img width="1299" alt="Screenshot 2025-01-28 at 5 41 07 PM" src="https://github.com/user-attachments/assets/4c9353a0-d001-470d-8417-56cccb661ddd" /> ### Checklist - [ ] Post commit CI passes - [ ] Blackhole Post commit (if applicable) - [ ] Model regression CI testing passes (if applicable) - [ ] Device performance regression CI testing passes (if applicable) - [ ] **(For models and ops writers)** Full [new models](https://github.com/tenstorrent/tt-metal/actions/workflows/full-new-models-suite.yaml) tests passes - [ ] New/Existing tests provide coverage for changes
- Loading branch information
1 parent
cb581f1
commit b3213e4
Showing
4 changed files
with
195 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
tests/ttnn/unit_tests/operations/ccl/perf/run_async_reduce_scatter_profile.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/bin/sh | ||
MODULE_DIR="tests/ttnn/unit_tests/operations/ccl/perf" | ||
|
||
# Defaults | ||
DEBUG=false | ||
TARGET="n300" | ||
|
||
# Function to display help | ||
show_help() { | ||
echo "Usage: ./tests/ttnn/unit_tests/operations/ccl/perf/run_profile.sh [OPTIONS]" | ||
echo | ||
echo "Options:" | ||
echo " -d, --debug Enable debug mode to show real-time output." | ||
echo " -t, --target Specify the target configuration (t3000 or n300 or tg). Default is n300." | ||
echo " -h, --help Display this help message." | ||
echo | ||
echo "Example:" | ||
echo " ./tests/ttnn/unit_tests/operations/ccl/perf/run_profile.sh --debug --target n300" | ||
echo " ./tests/ttnn/unit_tests/operations/ccl/perf/run_profile.sh -h" | ||
} | ||
|
||
# Parse command-line arguments | ||
while [ $# -gt 0 ]; do | ||
case "$1" in | ||
--debug|-d) | ||
DEBUG=true | ||
shift | ||
;; | ||
--help|-h) | ||
show_help | ||
exit 0 | ||
;; | ||
--target|-t) | ||
# Ensure there is an argument following the target flag | ||
if [ -z "$2" ]; then | ||
echo "Error: No target specified after $1." | ||
show_help | ||
exit 1 | ||
fi | ||
|
||
TARGET="$2" # Set the target configuration | ||
shift 2 | ||
|
||
# Validate the target value | ||
if [ "$TARGET" != "t3000" ] && [ "$TARGET" != "tg" ] && [ "$TARGET" != "n300" ]; then | ||
echo "Error: Invalid target configuration: $TARGET. Must be 't3000' or 'n300' or 'tg'." | ||
exit 1 | ||
fi | ||
;; | ||
*) | ||
echo "Unknown option: $1" | ||
show_help | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Function to run the profiling command and extract the CSV path | ||
run_profile_and_extract_csv() { | ||
command="./tt_metal/tools/profiler/profile_this.py -n reduce_scatter_async_$TARGET -c 'pytest tests/ttnn/unit_tests/operations/ccl/perf/test_ccl_async_perf.py::test_reduce_scatter_async_$TARGET'" | ||
|
||
if [ "$DEBUG" = true ]; then | ||
echo "Running profiling command for target $TARGET in debug mode..." | ||
full_output=$(eval $command 2>&1 | tee /dev/tty) | ||
else | ||
echo "Running profiling command for target $TARGET..." | ||
full_output=$(eval $command 2>&1) | ||
fi | ||
|
||
# Extract the CSV path | ||
csv_path=$(echo "$full_output" | grep -oE 'OPs csv generated at: (.+\.csv)' | sed -E 's/OPs csv generated at: //') | ||
|
||
if [ -n "$csv_path" ]; then | ||
echo "CSV path found: $csv_path" | ||
echo "Generating performance report..." | ||
|
||
tmp_file="/tmp/perf_report_output.log" | ||
PYTHONPATH="$MODULE_DIR" python3 -c " | ||
import sys | ||
import pandas as pd | ||
from async_perf_csv import perf_report | ||
from tabulate import tabulate | ||
try: | ||
# Generate the report and convert it to a DataFrame | ||
average_df = perf_report('$csv_path') | ||
# Print the DataFrame in a pretty table format | ||
print('Min - Avg - Max by Common Runs:') | ||
print(tabulate(average_df, headers='keys', tablefmt='pretty')) | ||
except Exception as e: | ||
print(f'Error in performance report generation: {e}', file=sys.stderr) | ||
sys.exit(1) | ||
" 2>&1 | tee "$tmp_file" | ||
|
||
if grep -q "Error in performance report generation" "$tmp_file"; then | ||
echo "Error: Performance report generation failed." | ||
exit 1 | ||
fi | ||
|
||
else | ||
echo "CSV path not found in the command output." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Run the function | ||
run_profile_and_extract_csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters