ttperf 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,170 @@
1
+ Metadata-Version: 2.4
2
+ Name: ttperf
3
+ Version: 0.1.0
4
+ Summary: A streamlined CLI tool for profiling Tenstorrent's TT-Metal tests and extracting device kernel performance metrics
5
+ Author-email: Aswin Z <aswintechie@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Aswintechie/ttperf
8
+ Project-URL: Repository, https://github.com/Aswintechie/ttperf
9
+ Project-URL: Issues, https://github.com/Aswintechie/ttperf/issues
10
+ Project-URL: Documentation, https://github.com/Aswintechie/ttperf/blob/master/README.md
11
+ Keywords: tenstorrent,tt-metal,profiling,performance,cli
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Topic :: Software Development :: Testing
22
+ Classifier: Topic :: System :: Benchmark
23
+ Requires-Python: >=3.7
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: pandas>=1.3.0
27
+ Dynamic: license-file
28
+
29
+ # šŸš€ ttperf - TT-Metal Performance Profiler
30
+
31
+ <div align="center">
32
+
33
+ ![Python](https://img.shields.io/badge/python-3.7+-blue.svg)
34
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
35
+ ![Version](https://img.shields.io/badge/version-0.1.0-orange.svg)
36
+ [![GitHub issues](https://img.shields.io/github/issues/Aswintechie/ttperf)](https://github.com/Aswintechie/ttperf/issues)
37
+ [![GitHub stars](https://img.shields.io/github/stars/Aswintechie/ttperf)](https://github.com/Aswintechie/ttperf/stargazers)
38
+
39
+ **A streamlined CLI tool for profiling Tenstorrent's TT-Metal tests and extracting device kernel performance metrics**
40
+
41
+ </div>
42
+
43
+ ## ✨ Features
44
+
45
+ - šŸ” **Automated Profiling**: Seamlessly runs Tenstorrent's TT-Metal profiler with pytest
46
+ - šŸ“Š **CSV Analysis**: Automatically extracts and parses performance CSV files
47
+ - ⚔ **Real-time Output**: Shows profiling progress in real-time
48
+ - šŸ“ˆ **Performance Metrics**: Calculates total DEVICE KERNEL DURATION
49
+ - šŸŽÆ **Simple CLI**: Easy-to-use command-line interface
50
+ - šŸ› ļø **Flexible**: Supports named profiles and various test paths
51
+
52
+ ## šŸš€ Quick Start
53
+
54
+ ### Installation
55
+
56
+ ```bash
57
+ # Clone the repository
58
+ git clone https://github.com/Aswintechie/ttperf.git
59
+ cd ttperf
60
+
61
+ # Install the package
62
+ pip install -e .
63
+ ```
64
+
65
+ ### Basic Usage
66
+
67
+ ```bash
68
+ # Run profiling on a specific test
69
+ ttperf test_performance.py
70
+
71
+ # Run with a custom profile name
72
+ ttperf my_profile pytest test_performance.py
73
+
74
+ # Run on a specific test method
75
+ ttperf tests/test_ops.py::test_matmul
76
+ ```
77
+
78
+ ## šŸ“‹ Usage Examples
79
+
80
+ ### Simple Test Profiling
81
+ ```bash
82
+ ttperf test_conv.py
83
+ ```
84
+
85
+ ### Named Profile
86
+ ```bash
87
+ ttperf conv_benchmark pytest test_conv.py
88
+ ```
89
+
90
+ ### Specific Test Method
91
+ ```bash
92
+ ttperf tests/ops/test_matmul.py::test_basic_matmul
93
+ ```
94
+
95
+ ### Output Example
96
+ ```
97
+ ā–¶ļø Running: ./tt_metal/tools/profiler/profile_this.py -n conv_benchmark -c "pytest test_conv.py"
98
+
99
+ ... (profiling output) ...
100
+
101
+ šŸ“ Found CSV path: /path/to/profile_results.csv
102
+ ā±ļø DEVICE KERNEL DURATION [ns] total: 1234567.89 ns
103
+ ```
104
+
105
+ ## šŸ› ļø How It Works
106
+
107
+ 1. **Command Parsing**: Analyzes input arguments to determine profile name and test path
108
+ 2. **Profile Execution**: Runs the Tenstorrent's TT-Metal profiler with the specified test
109
+ 3. **Output Monitoring**: Streams profiling output in real-time
110
+ 4. **CSV Extraction**: Parses the output to find the generated CSV file path
111
+ 5. **Performance Analysis**: Reads the CSV and calculates total device kernel duration
112
+
113
+ ## šŸ“Š Performance Metrics
114
+
115
+ The tool extracts the following key metrics:
116
+
117
+ - **DEVICE KERNEL DURATION [ns]**: Total time spent in device kernels
118
+ - **CSV Path**: Location of the detailed profiling results
119
+ - **Real-time Progress**: Live output during profiling
120
+
121
+ ## šŸ”§ Requirements
122
+
123
+ - Python 3.7+
124
+ - pandas
125
+ - Tenstorrent's TT-Metal development environment
126
+ - pytest
127
+
128
+ ## šŸ“ Project Structure
129
+
130
+ ```
131
+ ttperf/
132
+ ā”œā”€ā”€ ttperf.py # Main CLI implementation
133
+ ā”œā”€ā”€ pyproject.toml # Project configuration
134
+ ā”œā”€ā”€ README.md # This file
135
+ └── .gitignore # Git ignore rules
136
+ ```
137
+
138
+ ## šŸ¤ Contributing
139
+
140
+ Contributions are welcome! Please feel free to submit a Pull Request.
141
+
142
+ 1. Fork the repository
143
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
144
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
145
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
146
+ 5. Open a Pull Request
147
+
148
+ ## šŸ“ License
149
+
150
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
151
+
152
+ ## šŸ› Issues
153
+
154
+ If you encounter any issues, please [create an issue](https://github.com/Aswintechie/ttperf/issues) on GitHub.
155
+
156
+ ## šŸ‘Øā€šŸ’» Author
157
+
158
+ **Aswin Z**
159
+ - GitHub: [@Aswintechie](https://github.com/Aswintechie)
160
+
161
+ ## 🌟 Acknowledgments
162
+
163
+ - Tenstorrent's TT-Metal development team for the profiling tools
164
+ - Python community for excellent libraries like pandas
165
+
166
+ ---
167
+
168
+ <div align="center">
169
+ Made with ā¤ļø for the Tenstorrent TT-Metal community
170
+ </div>
@@ -0,0 +1,7 @@
1
+ ttperf.py,sha256=uiR9T3qJDYqF3AOJ4DY_dTmOJDqX_tbT8bBVOwhYglA,2352
2
+ ttperf-0.1.0.dist-info/licenses/LICENSE,sha256=k8fjE_s0-gHSzJ73QSpsYzDjPF6u1HqTDzNAsQdkJNs,1064
3
+ ttperf-0.1.0.dist-info/METADATA,sha256=F36LnUflfaOxjcSP98s7185w2UPgP0-sSQj7fa1BWZ4,5214
4
+ ttperf-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ ttperf-0.1.0.dist-info/entry_points.txt,sha256=Jrp4BUffw61Ry5CIFr7AkfhNveL8WCIsEAO5Tjp3QT4,39
6
+ ttperf-0.1.0.dist-info/top_level.txt,sha256=bqanJsvyzzPeYMBa8QM6JheVAUD0PJulrNPU9sSTqL4,7
7
+ ttperf-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ttperf = ttperf:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Aswin Z
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ ttperf
ttperf.py ADDED
@@ -0,0 +1,94 @@
1
+ # ttperf/cli.py
2
+
3
+ import sys
4
+ import subprocess
5
+ import re
6
+ import pandas as pd
7
+ from pathlib import Path
8
+
9
+
10
+ def extract_csv_path(output: str) -> str:
11
+ match = re.search(r"OPs csv generated at: (.+?\.csv)", output)
12
+ if not match:
13
+ print("āŒ CSV path not found in output.")
14
+ sys.exit(1)
15
+ return match.group(1)
16
+
17
+
18
+ def get_device_kernel_duration(csv_path: str) -> float:
19
+ df = pd.read_csv(csv_path)
20
+ if "DEVICE KERNEL DURATION [ns]" not in df.columns:
21
+ print("āŒ 'DEVICE KERNEL DURATION [ns]' column not found.")
22
+ sys.exit(1)
23
+ return df["DEVICE KERNEL DURATION [ns]"].sum()
24
+
25
+
26
+ def parse_args(argv):
27
+ # Default values
28
+ name = None
29
+ test_cmd = None
30
+
31
+ for arg in argv:
32
+ if arg.endswith(".py") or "::" in arg or Path(arg).exists():
33
+ test_cmd = arg
34
+ elif arg.lower() == "pytest":
35
+ continue
36
+ else:
37
+ name = arg
38
+
39
+ if not test_cmd:
40
+ print("āŒ Test file/path not found in arguments.")
41
+ sys.exit(1)
42
+
43
+ return name, test_cmd
44
+
45
+
46
+ def build_profile_command(name, test_cmd):
47
+ name_arg = f"-n {name}" if name else ""
48
+ return f"./tt_metal/tools/profiler/profile_this.py {name_arg} -c \"pytest {test_cmd}\""
49
+
50
+
51
+ def main():
52
+ if len(sys.argv) < 2:
53
+ print("Usage: ttperf [name] [pytest] <test_path>")
54
+ sys.exit(1)
55
+
56
+ name, test_cmd = parse_args(sys.argv[1:])
57
+ profile_cmd = build_profile_command(name, test_cmd)
58
+
59
+ print(f"ā–¶ļø Running: {profile_cmd}\n")
60
+
61
+ process = subprocess.Popen(
62
+ profile_cmd,
63
+ shell=True,
64
+ stdout=subprocess.PIPE,
65
+ stderr=subprocess.STDOUT,
66
+ universal_newlines=True,
67
+ bufsize=1,
68
+ )
69
+
70
+ output_lines = []
71
+ try:
72
+ for line in process.stdout:
73
+ print(line, end="") # Real-time output
74
+ output_lines.append(line)
75
+ except KeyboardInterrupt:
76
+ process.terminate()
77
+ print("āŒ Aborted.")
78
+ sys.exit(1)
79
+
80
+ process.wait()
81
+
82
+ # Combine all output for post-analysis
83
+ full_output = "".join(output_lines)
84
+
85
+ # Extract CSV path and duration
86
+ csv_path = extract_csv_path(full_output)
87
+ print(f"\nšŸ“ Found CSV path: {csv_path}")
88
+
89
+ duration = get_device_kernel_duration(csv_path)
90
+ print(f"\nā±ļø DEVICE KERNEL DURATION [ns] total: {duration:.2f} ns")
91
+
92
+
93
+ if __name__ == "__main__":
94
+ main()