tt-check 0.1.0__tar.gz

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,28 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ push:
7
+ tags:
8
+ - "v*"
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: read
13
+ id-token: write
14
+
15
+ jobs:
16
+ publish:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.x"
23
+ - name: Build distributions
24
+ run: |
25
+ python -m pip install --upgrade build
26
+ python -m build
27
+ - name: Publish to PyPI
28
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,10 @@
1
+ .DS_Store
2
+ *.py[cod]
3
+ __pycache__/
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ .mypy_cache/
7
+ .venv/
8
+ build/
9
+ dist/
10
+ *.egg-info/
@@ -0,0 +1 @@
1
+ 3.10
tt_check-0.1.0/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work, excluding
103
+ those notices that do not pertain to any part of the Derivative
104
+ Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.4
2
+ Name: tt-check
3
+ Version: 0.1.0
4
+ Summary: Small TTNN readiness check for Tenstorrent systems
5
+ Project-URL: Homepage, https://github.com/yieldthought/tt-check
6
+ Project-URL: Repository, https://github.com/yieldthought/tt-check
7
+ Project-URL: Issues, https://github.com/yieldthought/tt-check/issues
8
+ Author: Tenstorrent
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: hardware,readiness,tenstorrent,tt-smi,ttnn
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Testing
21
+ Requires-Python: !=3.11.*,<3.13,>=3.10
22
+ Requires-Dist: torch; platform_system == 'Linux'
23
+ Requires-Dist: tt-smi>=3.1.1; platform_system == 'Linux'
24
+ Requires-Dist: ttnn; platform_system == 'Linux'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # tt-check
28
+
29
+ `tt-check` is a small command-line readiness test for a Tenstorrent system with
30
+ `tt-smi` and the public `ttnn` Python package installed.
31
+
32
+ It performs the following checks:
33
+
34
+ 1. Resets devices with `tt-smi -r`.
35
+ 2. Collects system information from `tt-smi -s --snapshot_no_tty`.
36
+ 3. Opens a TTNN device.
37
+ 4. Runs a simulated tensor-parallel three-weight gated MLP 100 times in both
38
+ prefill and decode shapes:
39
+ - BF16 activations
40
+ - BFP8 weights
41
+ - 1024 activation width per device shard
42
+ - prefill rows: 1024
43
+ - decode rows: 1
44
+ 5. Warms each MLP shape once, captures one dynamic TTNN trace per shape, then
45
+ executes each trace for the requested run count.
46
+ 6. Compares each trace replay against a PyTorch reference with PCC >= 0.99 and
47
+ requires TTNN output tensors to be identical across all replays.
48
+
49
+ ## Install
50
+
51
+ Preferred:
52
+
53
+ ```bash
54
+ uv tool install --python 3.10 .
55
+ ```
56
+
57
+ Or run directly from a checkout:
58
+
59
+ ```bash
60
+ uv run tt-check
61
+ ```
62
+
63
+ `uv` uses the PyTorch CPU wheel index for this project; the check only needs
64
+ Torch for reference math. The project pins a Python version compatible with the
65
+ current public `ttnn` wheels.
66
+
67
+ Pip also works:
68
+
69
+ ```bash
70
+ python3 -m pip install .
71
+ ```
72
+
73
+ ## Run
74
+
75
+ ```bash
76
+ tt-check
77
+ ```
78
+
79
+ The command exits `0` if all checks pass. It exits `1` and writes the failure to
80
+ stderr otherwise.
81
+
82
+ Useful options:
83
+
84
+ ```bash
85
+ tt-check --device-id 0 --runs 100 --pcc-threshold 0.99
86
+ tt-check --prefill-rows 1024 --decode-rows 1 --activation-width-per-device 1024
87
+ ```
@@ -0,0 +1,61 @@
1
+ # tt-check
2
+
3
+ `tt-check` is a small command-line readiness test for a Tenstorrent system with
4
+ `tt-smi` and the public `ttnn` Python package installed.
5
+
6
+ It performs the following checks:
7
+
8
+ 1. Resets devices with `tt-smi -r`.
9
+ 2. Collects system information from `tt-smi -s --snapshot_no_tty`.
10
+ 3. Opens a TTNN device.
11
+ 4. Runs a simulated tensor-parallel three-weight gated MLP 100 times in both
12
+ prefill and decode shapes:
13
+ - BF16 activations
14
+ - BFP8 weights
15
+ - 1024 activation width per device shard
16
+ - prefill rows: 1024
17
+ - decode rows: 1
18
+ 5. Warms each MLP shape once, captures one dynamic TTNN trace per shape, then
19
+ executes each trace for the requested run count.
20
+ 6. Compares each trace replay against a PyTorch reference with PCC >= 0.99 and
21
+ requires TTNN output tensors to be identical across all replays.
22
+
23
+ ## Install
24
+
25
+ Preferred:
26
+
27
+ ```bash
28
+ uv tool install --python 3.10 .
29
+ ```
30
+
31
+ Or run directly from a checkout:
32
+
33
+ ```bash
34
+ uv run tt-check
35
+ ```
36
+
37
+ `uv` uses the PyTorch CPU wheel index for this project; the check only needs
38
+ Torch for reference math. The project pins a Python version compatible with the
39
+ current public `ttnn` wheels.
40
+
41
+ Pip also works:
42
+
43
+ ```bash
44
+ python3 -m pip install .
45
+ ```
46
+
47
+ ## Run
48
+
49
+ ```bash
50
+ tt-check
51
+ ```
52
+
53
+ The command exits `0` if all checks pass. It exits `1` and writes the failure to
54
+ stderr otherwise.
55
+
56
+ Useful options:
57
+
58
+ ```bash
59
+ tt-check --device-id 0 --runs 100 --pcc-threshold 0.99
60
+ tt-check --prefill-rows 1024 --decode-rows 1 --activation-width-per-device 1024
61
+ ```
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "tt-check"
7
+ version = "0.1.0"
8
+ description = "Small TTNN readiness check for Tenstorrent systems"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10,<3.13,!=3.11.*"
11
+ license = "Apache-2.0"
12
+ authors = [
13
+ { name = "Tenstorrent" },
14
+ ]
15
+ keywords = ["tenstorrent", "ttnn", "tt-smi", "readiness", "hardware"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: Apache Software License",
21
+ "Operating System :: POSIX :: Linux",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Topic :: Software Development :: Testing",
26
+ ]
27
+ dependencies = [
28
+ "torch; platform_system == 'Linux'",
29
+ "tt-smi>=3.1.1; platform_system == 'Linux'",
30
+ "ttnn; platform_system == 'Linux'",
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/yieldthought/tt-check"
35
+ Repository = "https://github.com/yieldthought/tt-check"
36
+ Issues = "https://github.com/yieldthought/tt-check/issues"
37
+
38
+ [project.scripts]
39
+ tt-check = "tt_check.cli:main"
40
+
41
+ [tool.uv.sources]
42
+ torch = [
43
+ { index = "pytorch-cpu", marker = "platform_system == 'Linux'" },
44
+ ]
45
+
46
+ [[tool.uv.index]]
47
+ name = "pytorch-cpu"
48
+ url = "https://download.pytorch.org/whl/cpu"
49
+ explicit = true
50
+
51
+ [tool.hatch.build.targets.wheel]
52
+ packages = ["src/tt_check"]
@@ -0,0 +1,5 @@
1
+ """TTNN readiness check package."""
2
+
3
+ __all__ = ["__version__"]
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,680 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ import math
6
+ import os
7
+ import shutil
8
+ import subprocess
9
+ import sys
10
+ import tempfile
11
+ import time
12
+ from collections.abc import Iterable
13
+ from dataclasses import dataclass
14
+ from pathlib import Path
15
+ from typing import Any
16
+
17
+
18
+ class CheckError(RuntimeError):
19
+ """Expected readiness-check failure."""
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class CommandResult:
24
+ stdout: str
25
+ stderr: str
26
+
27
+
28
+ def main(argv: list[str] | None = None) -> int:
29
+ raw_argv = list(sys.argv[1:] if argv is None else argv)
30
+ args = _parse_args(raw_argv)
31
+ if args._worker_json:
32
+ return _main_worker(args)
33
+ return _main_parent(raw_argv, args)
34
+
35
+
36
+ def _main_worker(args: argparse.Namespace) -> int:
37
+ try:
38
+ result = run_check(args)
39
+ Path(args._worker_json).write_text(json.dumps(result, indent=2, sort_keys=True), encoding="utf-8")
40
+ except CheckError as exc:
41
+ print(f"ERROR: {exc}", file=sys.stderr)
42
+ return 1
43
+ except KeyboardInterrupt:
44
+ print("ERROR: interrupted", file=sys.stderr)
45
+ return 1
46
+ except Exception as exc:
47
+ print(f"ERROR: unexpected failure: {type(exc).__name__}: {exc}", file=sys.stderr)
48
+ return 1
49
+ return 0
50
+
51
+
52
+ def _main_parent(raw_argv: list[str], args: argparse.Namespace) -> int:
53
+ with tempfile.TemporaryDirectory(prefix="tt-check-") as tmp_dir:
54
+ result_path = Path(tmp_dir) / "result.json"
55
+ stdout_path = Path(tmp_dir) / "stdout.txt"
56
+ stderr_path = Path(tmp_dir) / "stderr.txt"
57
+ worker_argv = [*raw_argv, "--_worker-json", str(result_path)]
58
+ env = os.environ.copy()
59
+ env.setdefault("TT_LOGGER_LEVEL", "FATAL")
60
+ env.setdefault("LOGURU_LEVEL", "ERROR")
61
+
62
+ with stdout_path.open("w", encoding="utf-8") as stdout_file, stderr_path.open(
63
+ "w", encoding="utf-8"
64
+ ) as stderr_file:
65
+ process = subprocess.Popen(
66
+ [sys.executable, "-m", "tt_check.cli", *worker_argv],
67
+ stdout=stdout_file,
68
+ stderr=stderr_file,
69
+ text=True,
70
+ env=env,
71
+ )
72
+ try:
73
+ _wait_with_progress(process, enabled=not args.json)
74
+ except KeyboardInterrupt:
75
+ process.terminate()
76
+ try:
77
+ process.wait(timeout=5)
78
+ except subprocess.TimeoutExpired:
79
+ process.kill()
80
+ print("ERROR: interrupted", file=sys.stderr)
81
+ return 1
82
+
83
+ stdout = _read_text(stdout_path)
84
+ stderr = _read_text(stderr_path)
85
+ if process.returncode != 0:
86
+ print(_format_failure(stdout, stderr), file=sys.stderr)
87
+ return 1
88
+ if not result_path.exists():
89
+ print(_format_failure(stdout, stderr, fallback="ERROR: tt-check did not produce a result"), file=sys.stderr)
90
+ return 1
91
+
92
+ try:
93
+ result = json.loads(result_path.read_text(encoding="utf-8"))
94
+ except json.JSONDecodeError as exc:
95
+ print(f"ERROR: invalid result JSON: {exc}", file=sys.stderr)
96
+ return 1
97
+
98
+ if args.json:
99
+ print(json.dumps(result, indent=2, sort_keys=True))
100
+ else:
101
+ print(_format_human_result(result))
102
+ return 0
103
+
104
+
105
+ def _parse_args(argv: list[str] | None) -> argparse.Namespace:
106
+ parser = argparse.ArgumentParser(description="Run a small TTNN readiness check.")
107
+ parser.add_argument("--device-id", type=int, default=0, help="TTNN device id to open.")
108
+ parser.add_argument("--runs", type=int, default=100, help="Number of identical MLP runs per mode.")
109
+ parser.add_argument("--pcc-threshold", type=float, default=0.99, help="Minimum PCC against PyTorch reference.")
110
+ parser.add_argument(
111
+ "--activation-width-per-device",
112
+ type=int,
113
+ default=1024,
114
+ help="Activation shard width used for the simulated tensor-parallel MLP.",
115
+ )
116
+ parser.add_argument("--prefill-rows", type=int, default=1024, help="Input rows for prefill mode.")
117
+ parser.add_argument("--decode-rows", type=int, default=1, help="Input rows for decode mode.")
118
+ parser.add_argument(
119
+ "--intermediate-multiplier",
120
+ type=int,
121
+ default=4,
122
+ help="MLP intermediate width multiplier relative to the activation width.",
123
+ )
124
+ parser.add_argument("--seed", type=int, default=0, help="Random seed for deterministic inputs and weights.")
125
+ parser.add_argument("--tt-smi-timeout", type=float, default=120.0, help="Timeout for each tt-smi command.")
126
+ parser.add_argument("--json", action="store_true", help="Print final result as JSON.")
127
+ parser.add_argument("--_worker-json", dest="_worker_json", default=None, help=argparse.SUPPRESS)
128
+ return parser.parse_args(argv)
129
+
130
+
131
+ def run_check(args: argparse.Namespace) -> dict[str, Any]:
132
+ _validate_args(args)
133
+ _require_executable("tt-smi")
134
+
135
+ reset_result = _run_command(["tt-smi", "-r"], timeout=args.tt_smi_timeout)
136
+ snapshot = collect_tt_smi_snapshot(timeout=args.tt_smi_timeout)
137
+ system_info = summarize_system(snapshot)
138
+
139
+ mlp_results = run_ttnn_mlp_check(
140
+ device_id=args.device_id,
141
+ runs=args.runs,
142
+ pcc_threshold=args.pcc_threshold,
143
+ activation_width=args.activation_width_per_device,
144
+ prefill_rows=args.prefill_rows,
145
+ decode_rows=args.decode_rows,
146
+ intermediate_multiplier=args.intermediate_multiplier,
147
+ seed=args.seed,
148
+ )
149
+
150
+ return {
151
+ "status": "pass",
152
+ "reset": {"stdout": reset_result.stdout.strip(), "stderr": reset_result.stderr.strip()},
153
+ "system": system_info,
154
+ "mlp": mlp_results,
155
+ }
156
+
157
+
158
+ def _validate_args(args: argparse.Namespace) -> None:
159
+ if args.runs < 1:
160
+ raise CheckError("--runs must be >= 1")
161
+ if not 0.0 <= args.pcc_threshold <= 1.0:
162
+ raise CheckError("--pcc-threshold must be between 0 and 1")
163
+ for name in ("activation_width_per_device", "prefill_rows", "decode_rows", "intermediate_multiplier"):
164
+ if getattr(args, name) < 1:
165
+ raise CheckError(f"--{name.replace('_', '-')} must be >= 1")
166
+ if args.activation_width_per_device % 32 != 0:
167
+ raise CheckError("--activation-width-per-device must be divisible by 32 for tiled matmuls")
168
+ if (args.activation_width_per_device * args.intermediate_multiplier) % 32 != 0:
169
+ raise CheckError("intermediate width must be divisible by 32 for tiled matmuls")
170
+
171
+
172
+ def _require_executable(name: str) -> None:
173
+ if shutil.which(name) is None:
174
+ raise CheckError(f"{name} not found on PATH")
175
+
176
+
177
+ def _run_command(command: list[str], *, timeout: float) -> CommandResult:
178
+ try:
179
+ result = subprocess.run(command, capture_output=True, text=True, timeout=timeout, check=False)
180
+ except FileNotFoundError:
181
+ raise CheckError(f"{command[0]} not found on PATH") from None
182
+ except subprocess.TimeoutExpired as exc:
183
+ raise CheckError(f"{' '.join(command)} timed out after {timeout:g}s") from exc
184
+ if result.returncode != 0:
185
+ details = _command_output_summary(result.stdout, result.stderr)
186
+ raise CheckError(f"{' '.join(command)} failed with exit code {result.returncode}{details}")
187
+ return CommandResult(stdout=result.stdout, stderr=result.stderr)
188
+
189
+
190
+ def _command_output_summary(stdout: str, stderr: str) -> str:
191
+ combined = "\n".join(part.strip() for part in (stdout, stderr) if part.strip())
192
+ if not combined:
193
+ return ""
194
+ return f": {combined[-2000:]}"
195
+
196
+
197
+ def _wait_with_progress(process: subprocess.Popen[str], *, enabled: bool) -> None:
198
+ start = time.monotonic()
199
+ drew_progress = False
200
+ while process.poll() is None:
201
+ elapsed = time.monotonic() - start
202
+ if enabled and sys.stdout.isatty() and elapsed >= 10:
203
+ drew_progress = True
204
+ sys.stdout.write(f"\rtt-check {_moving_bar(elapsed)} {elapsed:4.0f}s")
205
+ sys.stdout.flush()
206
+ time.sleep(0.2)
207
+ if drew_progress:
208
+ sys.stdout.write("\r" + " " * 48 + "\r")
209
+ sys.stdout.flush()
210
+
211
+
212
+ def _moving_bar(elapsed: float, *, width: int = 24) -> str:
213
+ position = int(elapsed * 8) % (width * 2)
214
+ if position >= width:
215
+ position = width * 2 - position - 1
216
+ cells = ["-"] * width
217
+ for offset in range(5):
218
+ index = position - offset
219
+ if 0 <= index < width:
220
+ cells[index] = "#"
221
+ return "[" + "".join(cells) + "]"
222
+
223
+
224
+ def _read_text(path: Path) -> str:
225
+ try:
226
+ return path.read_text(encoding="utf-8", errors="replace")
227
+ except FileNotFoundError:
228
+ return ""
229
+
230
+
231
+ def _format_failure(stdout: str, stderr: str, *, fallback: str = "ERROR: tt-check failed") -> str:
232
+ combined = "\n".join(part.strip() for part in (stderr, stdout) if part.strip())
233
+ if not combined:
234
+ return fallback
235
+
236
+ lines = [line.rstrip() for line in combined.splitlines() if line.strip()]
237
+ error_lines = [line for line in lines if line.startswith("ERROR:")]
238
+ if error_lines:
239
+ return error_lines[-1]
240
+
241
+ tail = "\n".join(lines[-20:])
242
+ return f"{fallback}\n\nLast diagnostics:\n{tail}"
243
+
244
+
245
+ def collect_tt_smi_snapshot(*, timeout: float) -> dict[str, Any]:
246
+ for command in (["tt-smi", "-s", "--snapshot_no_tty"], ["tt-smi", "-s"]):
247
+ try:
248
+ result = _run_command(command, timeout=timeout)
249
+ return _parse_json_from_output(result.stdout)
250
+ except CheckError:
251
+ if command[-1] != "-s":
252
+ continue
253
+ raise
254
+ raise CheckError("unable to collect tt-smi snapshot")
255
+
256
+
257
+ def _parse_json_from_output(output: str) -> dict[str, Any]:
258
+ text = output.strip()
259
+ start = text.find("{")
260
+ end = text.rfind("}")
261
+ if start < 0 or end < start:
262
+ raise CheckError("tt-smi snapshot did not contain JSON")
263
+ try:
264
+ parsed = json.loads(text[start : end + 1])
265
+ except json.JSONDecodeError as exc:
266
+ raise CheckError(f"failed to parse tt-smi JSON snapshot: {exc}") from exc
267
+ if not isinstance(parsed, dict):
268
+ raise CheckError("tt-smi snapshot JSON root was not an object")
269
+ return parsed
270
+
271
+
272
+ def summarize_system(snapshot: dict[str, Any]) -> dict[str, Any]:
273
+ devices = _devices_from_snapshot(snapshot)
274
+ if not devices:
275
+ raise CheckError("tt-smi snapshot reported no devices")
276
+
277
+ architectures = sorted(_compact(_architecture_for_device(d) for d in devices))
278
+ board_types = sorted(
279
+ _compact(
280
+ _value_from_paths(d, ("board_type", "type"))
281
+ or _value_from_paths(d.get("board_info", {}), ("board_type", "type"))
282
+ for d in devices
283
+ )
284
+ )
285
+ device_series = sorted(
286
+ _compact(
287
+ _value_from_paths(d, ("device_series", "series", "board_name", "product_name"))
288
+ or _value_from_paths(d.get("board_info", {}), ("device_series", "series", "board_name", "product_name"))
289
+ for d in devices
290
+ )
291
+ )
292
+ board_numbers = sorted(_compact(_board_identity(d) for d in devices))
293
+ coordinates = sorted(
294
+ _compact(
295
+ _value_from_paths(d, ("coords", "coordinate", "coordinates"))
296
+ or _value_from_paths(d.get("board_info", {}), ("coords", "coordinate", "coordinates"))
297
+ for d in devices
298
+ )
299
+ )
300
+
301
+ return {
302
+ "architecture": architectures or ["unknown"],
303
+ "board_types": board_types or ["unknown"],
304
+ "device_series": device_series or board_types or ["unknown"],
305
+ "device_count": len(devices),
306
+ "card_count": len(board_numbers) if board_numbers else len(devices),
307
+ "board_numbers": board_numbers,
308
+ "device_coordinates": coordinates,
309
+ "mesh_topology": _infer_mesh_topology(snapshot, len(devices), len(board_numbers) if board_numbers else len(devices)),
310
+ }
311
+
312
+
313
+ def _devices_from_snapshot(snapshot: dict[str, Any]) -> list[dict[str, Any]]:
314
+ raw = snapshot.get("device_info", [])
315
+ if isinstance(raw, dict):
316
+ values = raw.values()
317
+ elif isinstance(raw, list):
318
+ values = raw
319
+ else:
320
+ values = []
321
+ return [item for item in values if isinstance(item, dict)]
322
+
323
+
324
+ def _value_from_paths(data: Any, names: Iterable[str]) -> str | None:
325
+ if not isinstance(data, dict):
326
+ return None
327
+ lowered = {str(key).lower(): value for key, value in data.items()}
328
+ for name in names:
329
+ value = lowered.get(name.lower())
330
+ if value is not None:
331
+ text = str(value).strip()
332
+ if text and text.upper() != "N/A":
333
+ return text
334
+ return None
335
+
336
+
337
+ def _board_identity(device: dict[str, Any]) -> str | None:
338
+ names = (
339
+ "board_number",
340
+ "board_id",
341
+ "board_serial",
342
+ "serial_number",
343
+ "serial",
344
+ "card_id",
345
+ "card_serial",
346
+ )
347
+ return _value_from_paths(device, names) or _value_from_paths(device.get("board_info", {}), names)
348
+
349
+
350
+ def _architecture_for_device(device: dict[str, Any]) -> str | None:
351
+ explicit = _value_from_paths(device, ("arch", "architecture", "device_arch"))
352
+ if explicit:
353
+ return explicit
354
+
355
+ text = " ".join(
356
+ str(value).lower()
357
+ for key, value in _walk_key_values(device)
358
+ if any(token in key.lower() for token in ("arch", "board_type", "device_series", "product", "name"))
359
+ )
360
+ if any(token in text for token in ("wormhole", "n150", "n300", "nebula")):
361
+ return "wormhole_b0"
362
+ if any(token in text for token in ("blackhole", "p100", "p150", "p300", "p150a", "p150b")):
363
+ return "blackhole"
364
+ return None
365
+
366
+
367
+ def _compact(values: Iterable[str | None]) -> set[str]:
368
+ return {value for value in values if value}
369
+
370
+
371
+ def _infer_mesh_topology(snapshot: dict[str, Any], device_count: int, card_count: int) -> str:
372
+ reported = []
373
+ for key, value in _walk_key_values(snapshot):
374
+ lowered = key.lower()
375
+ if any(token in lowered for token in ("mesh", "topology", "cluster")):
376
+ text = str(value).strip()
377
+ if text and text.upper() != "N/A" and len(text) < 160:
378
+ reported.append(f"{key}={text}")
379
+ if reported:
380
+ return "; ".join(sorted(set(reported))[:6])
381
+
382
+ series_text = " ".join(
383
+ str(value).lower()
384
+ for key, value in _walk_key_values(snapshot)
385
+ if key.lower() in {"device_series", "series", "board_type", "board_name", "product_name"}
386
+ )
387
+ if any(token in series_text for token in ("quietbox", "loudbox", " t3000", "qb", "lb")):
388
+ return "mesh system inferred from board series"
389
+ if card_count >= 32 or device_count >= 32:
390
+ return "galaxy-scale system inferred from device/card count"
391
+ if card_count in {4, 8}:
392
+ return f"{card_count}-card mesh inferred from card count; explicit topology not reported by tt-smi snapshot"
393
+ if card_count <= 1:
394
+ return "single-card/non-mesh inferred from card count"
395
+ return "unknown; not reported by tt-smi snapshot"
396
+
397
+
398
+ def _walk_key_values(value: Any, prefix: str = "") -> Iterable[tuple[str, Any]]:
399
+ if isinstance(value, dict):
400
+ for key, nested in value.items():
401
+ name = f"{prefix}.{key}" if prefix else str(key)
402
+ yield from _walk_key_values(nested, name)
403
+ elif isinstance(value, list):
404
+ for index, nested in enumerate(value):
405
+ yield from _walk_key_values(nested, f"{prefix}[{index}]")
406
+ else:
407
+ yield prefix, value
408
+
409
+
410
+ def run_ttnn_mlp_check(
411
+ *,
412
+ device_id: int,
413
+ runs: int,
414
+ pcc_threshold: float,
415
+ activation_width: int,
416
+ prefill_rows: int,
417
+ decode_rows: int,
418
+ intermediate_multiplier: int,
419
+ seed: int,
420
+ ) -> list[dict[str, Any]]:
421
+ try:
422
+ import torch
423
+ import ttnn
424
+ except ModuleNotFoundError as exc:
425
+ raise CheckError(f"missing Python dependency: {exc.name}") from exc
426
+
427
+ torch.manual_seed(seed)
428
+ device = None
429
+ try:
430
+ device = ttnn.open_device(device_id=device_id, trace_region_size=0)
431
+ results = []
432
+ for mode, rows in (("prefill", prefill_rows), ("decode", decode_rows)):
433
+ results.append(
434
+ _run_mlp_mode(
435
+ torch=torch,
436
+ ttnn=ttnn,
437
+ device=device,
438
+ mode=mode,
439
+ rows=rows,
440
+ activation_width=activation_width,
441
+ intermediate_width=activation_width * intermediate_multiplier,
442
+ runs=runs,
443
+ pcc_threshold=pcc_threshold,
444
+ )
445
+ )
446
+ return results
447
+ finally:
448
+ if device is not None:
449
+ try:
450
+ ttnn.close_device(device)
451
+ except Exception as exc:
452
+ raise CheckError(f"ttnn.close_device failed: {type(exc).__name__}: {exc}") from exc
453
+
454
+
455
+ def _run_mlp_mode(
456
+ *,
457
+ torch: Any,
458
+ ttnn: Any,
459
+ device: Any,
460
+ mode: str,
461
+ rows: int,
462
+ activation_width: int,
463
+ intermediate_width: int,
464
+ runs: int,
465
+ pcc_threshold: float,
466
+ ) -> dict[str, Any]:
467
+ shape = (1, 1, rows, activation_width)
468
+ x = (torch.randn(shape, dtype=torch.float32) * 0.5).to(torch.bfloat16)
469
+ w1 = torch.randn((activation_width, intermediate_width), dtype=torch.float32) / math.sqrt(activation_width)
470
+ w3 = torch.randn((activation_width, intermediate_width), dtype=torch.float32) / math.sqrt(activation_width)
471
+ w2 = torch.randn((intermediate_width, activation_width), dtype=torch.float32) / math.sqrt(intermediate_width)
472
+
473
+ tt_x = ttnn.from_torch(x, dtype=ttnn.bfloat16, layout=ttnn.TILE_LAYOUT, device=device)
474
+ tt_w1 = ttnn.from_torch(w1, dtype=ttnn.bfloat8_b, layout=ttnn.TILE_LAYOUT, device=device)
475
+ tt_w3 = ttnn.from_torch(w3, dtype=ttnn.bfloat8_b, layout=ttnn.TILE_LAYOUT, device=device)
476
+ tt_w2 = ttnn.from_torch(w2, dtype=ttnn.bfloat8_b, layout=ttnn.TILE_LAYOUT, device=device)
477
+
478
+ try:
479
+ qw1 = ttnn.to_torch(tt_w1).to(torch.float32)
480
+ qw3 = ttnn.to_torch(tt_w3).to(torch.float32)
481
+ qw2 = ttnn.to_torch(tt_w2).to(torch.float32)
482
+ reference = torch.matmul(torch.nn.functional.silu(torch.matmul(x.to(torch.float32), qw1)) * torch.matmul(x.to(torch.float32), qw3), qw2)
483
+
484
+ mode_start = time.perf_counter()
485
+ pcc_values = []
486
+
487
+ warmup_start = time.perf_counter()
488
+ warmup_output, _ = _ttnn_mlp_forward(ttnn, tt_x, tt_w1, tt_w3, tt_w2)
489
+ warmup_torch = ttnn.to_torch(warmup_output).to(torch.float32)
490
+ _deallocate(ttnn, warmup_output)
491
+ warmup_elapsed = time.perf_counter() - warmup_start
492
+ first_output = warmup_torch
493
+ pcc_values.append(_validate_mlp_output(torch, reference, warmup_torch, pcc_threshold, mode, "warmup", None))
494
+
495
+ _synchronize_device(ttnn, device)
496
+ trace_id = None
497
+ trace_output = None
498
+ trace_intermediates = ()
499
+ try:
500
+ capture_start = time.perf_counter()
501
+ trace_id = ttnn.begin_trace_capture(device, cq_id=0)
502
+ trace_output, trace_intermediates = _ttnn_mlp_forward(
503
+ ttnn, tt_x, tt_w1, tt_w3, tt_w2, keep_intermediates=True
504
+ )
505
+ ttnn.end_trace_capture(device, trace_id, cq_id=0)
506
+ capture_elapsed = time.perf_counter() - capture_start
507
+ _synchronize_device(ttnn, device)
508
+
509
+ capture_torch = ttnn.to_torch(trace_output).to(torch.float32)
510
+ pcc_values.append(
511
+ _validate_mlp_output(torch, reference, capture_torch, pcc_threshold, mode, "capture", first_output)
512
+ )
513
+
514
+ replay_start = time.perf_counter()
515
+ for run_index in range(runs):
516
+ ttnn.execute_trace(device, trace_id, cq_id=0, blocking=True)
517
+ output_torch = ttnn.to_torch(trace_output).to(torch.float32)
518
+ pcc_values.append(
519
+ _validate_mlp_output(
520
+ torch, reference, output_torch, pcc_threshold, mode, f"trace replay {run_index}", first_output
521
+ )
522
+ )
523
+ replay_elapsed = time.perf_counter() - replay_start
524
+ finally:
525
+ if trace_id is not None:
526
+ _release_trace(ttnn, device, trace_id)
527
+ for tensor in (trace_output, *trace_intermediates):
528
+ _deallocate(ttnn, tensor)
529
+
530
+ unique_pcc_values = {f"{pcc:.12g}" for pcc in pcc_values}
531
+ if len(unique_pcc_values) != 1:
532
+ raise CheckError(f"{mode}: PCC values were not identical across runs: {sorted(unique_pcc_values)}")
533
+
534
+ return {
535
+ "mode": mode,
536
+ "shape": list(shape),
537
+ "runs": runs,
538
+ "execution": "trace",
539
+ "warmup_runs": 1,
540
+ "captured_runs": 1,
541
+ "pcc": pcc_values[0],
542
+ "pcc_threshold": pcc_threshold,
543
+ "outputs_identical": True,
544
+ "timing": {
545
+ "warmup_s": warmup_elapsed,
546
+ "capture_s": capture_elapsed,
547
+ "replay_s": replay_elapsed,
548
+ "total_s": time.perf_counter() - mode_start,
549
+ },
550
+ }
551
+ finally:
552
+ for tensor in (tt_x, tt_w1, tt_w3, tt_w2):
553
+ _deallocate(ttnn, tensor)
554
+
555
+
556
+ def _ttnn_mlp_forward(
557
+ ttnn: Any, x: Any, w1: Any, w3: Any, w2: Any, *, keep_intermediates: bool = False
558
+ ) -> tuple[Any, tuple[Any, ...]]:
559
+ w1_out = ttnn.linear(x, w1, dtype=ttnn.bfloat16)
560
+ w3_out = ttnn.linear(x, w3, dtype=ttnn.bfloat16)
561
+ activated = ttnn.silu(w1_out)
562
+ hidden = ttnn.mul(activated, w3_out, dtype=ttnn.bfloat16)
563
+ output = ttnn.linear(hidden, w2, dtype=ttnn.bfloat16)
564
+
565
+ intermediates = (hidden, activated, w3_out, w1_out)
566
+ if keep_intermediates:
567
+ return output, intermediates
568
+ for tensor in intermediates:
569
+ _deallocate(ttnn, tensor)
570
+ return output, ()
571
+
572
+
573
+ def _validate_mlp_output(
574
+ torch: Any,
575
+ reference: Any,
576
+ actual: Any,
577
+ pcc_threshold: float,
578
+ mode: str,
579
+ run_label: str,
580
+ expected_identical: Any | None,
581
+ ) -> float:
582
+ if not torch.isfinite(actual).all():
583
+ raise CheckError(f"{mode} {run_label}: TTNN output contains non-finite values")
584
+
585
+ pcc = _pearson_corrcoef(torch, reference, actual)
586
+ if pcc < pcc_threshold:
587
+ raise CheckError(f"{mode} {run_label}: PCC {pcc:.8f} < {pcc_threshold:.8f}")
588
+
589
+ if expected_identical is not None and not torch.equal(expected_identical, actual):
590
+ max_abs = torch.max(torch.abs(expected_identical - actual)).item()
591
+ differing = torch.count_nonzero(expected_identical != actual).item()
592
+ raise CheckError(
593
+ f"{mode} {run_label}: output differs from warmup "
594
+ f"({differing} elements differ, max_abs_diff={max_abs:.8g})"
595
+ )
596
+ return pcc
597
+
598
+
599
+ def _synchronize_device(ttnn: Any, device: Any) -> None:
600
+ try:
601
+ ttnn.synchronize_device(device)
602
+ except AttributeError:
603
+ return
604
+
605
+
606
+ def _release_trace(ttnn: Any, device: Any, trace_id: Any) -> None:
607
+ try:
608
+ ttnn.release_trace(device, trace_id)
609
+ except Exception:
610
+ pass
611
+
612
+
613
+ def _deallocate(ttnn: Any, tensor: Any) -> None:
614
+ if tensor is None:
615
+ return
616
+ try:
617
+ ttnn.deallocate(tensor)
618
+ except Exception:
619
+ pass
620
+
621
+
622
+ def _pearson_corrcoef(torch: Any, expected: Any, actual: Any) -> float:
623
+ expected_flat = expected.reshape(-1).to(torch.float64)
624
+ actual_flat = actual.reshape(-1).to(torch.float64)
625
+ if expected_flat.numel() != actual_flat.numel():
626
+ raise CheckError(f"shape mismatch: expected {tuple(expected.shape)}, actual {tuple(actual.shape)}")
627
+
628
+ expected_centered = expected_flat - torch.mean(expected_flat)
629
+ actual_centered = actual_flat - torch.mean(actual_flat)
630
+ denominator = torch.linalg.norm(expected_centered) * torch.linalg.norm(actual_centered)
631
+ if denominator.item() == 0.0:
632
+ return 1.0 if torch.equal(expected_flat, actual_flat) else 0.0
633
+ return (torch.dot(expected_centered, actual_centered) / denominator).item()
634
+
635
+
636
+ def _format_human_result(result: dict[str, Any]) -> str:
637
+ system = result["system"]
638
+ mlp_by_mode = {item["mode"]: item for item in result["mlp"]}
639
+ prefill = mlp_by_mode["prefill"]
640
+ decode = mlp_by_mode["decode"]
641
+ runs = max(item["runs"] for item in result["mlp"])
642
+ cards = system["card_count"]
643
+ lines = [
644
+ "tt-check passed",
645
+ "",
646
+ "reset ok",
647
+ f"system {_join_short(system['architecture'])} | {_join_short(system['device_series'])} | {cards} {_plural(cards, 'card')} | {_short_topology(system['mesh_topology'])}",
648
+ f"mlp prefill pcc {prefill['pcc']:.8f} | decode pcc {decode['pcc']:.8f} | trace x{runs}",
649
+ "ready.",
650
+ ]
651
+ return "\n".join(lines)
652
+
653
+
654
+ def _join_short(values: list[str]) -> str:
655
+ return ",".join(values) if values else "unknown"
656
+
657
+
658
+ def _plural(count: int, noun: str) -> str:
659
+ return noun if count == 1 else f"{noun}s"
660
+
661
+
662
+ def _short_topology(topology: str) -> str:
663
+ lowered = topology.lower()
664
+ if lowered.startswith("single-card"):
665
+ return "single-card"
666
+ if "galaxy" in lowered:
667
+ return "galaxy"
668
+ if "4-card mesh" in lowered:
669
+ return "4-card mesh"
670
+ if "8-card mesh" in lowered:
671
+ return "8-card mesh"
672
+ if "mesh system" in lowered:
673
+ return "mesh"
674
+ if "unknown" in lowered:
675
+ return "topology unknown"
676
+ return topology
677
+
678
+
679
+ if __name__ == "__main__":
680
+ sys.exit(main())
@@ -0,0 +1,62 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import unittest
5
+
6
+ from tt_check import cli
7
+
8
+
9
+ class CliHelpersTest(unittest.TestCase):
10
+ def test_validate_runs(self) -> None:
11
+ args = argparse.Namespace(
12
+ runs=0,
13
+ pcc_threshold=0.99,
14
+ activation_width_per_device=1024,
15
+ prefill_rows=1024,
16
+ decode_rows=1,
17
+ intermediate_multiplier=4,
18
+ )
19
+
20
+ with self.assertRaisesRegex(cli.CheckError, "--runs must be >= 1"):
21
+ cli._validate_args(args)
22
+
23
+ def test_system_summary_from_blackhole_snapshot(self) -> None:
24
+ snapshot = {
25
+ "device_info": [
26
+ {
27
+ "arch": "blackhole",
28
+ "board_type": "p150b",
29
+ "board_number": "0000041100000000",
30
+ }
31
+ ]
32
+ }
33
+
34
+ summary = cli.summarize_system(snapshot)
35
+
36
+ self.assertEqual(summary["architecture"], ["blackhole"])
37
+ self.assertEqual(summary["board_types"], ["p150b"])
38
+ self.assertEqual(summary["card_count"], 1)
39
+ self.assertIn("single-card", summary["mesh_topology"])
40
+
41
+ def test_human_result_mentions_trace(self) -> None:
42
+ result = {
43
+ "system": {
44
+ "architecture": ["blackhole"],
45
+ "device_series": ["p150b"],
46
+ "card_count": 1,
47
+ "mesh_topology": "single-card/non-mesh inferred from card count",
48
+ },
49
+ "mlp": [
50
+ {"mode": "prefill", "runs": 100, "pcc": 0.9998160161456406},
51
+ {"mode": "decode", "runs": 100, "pcc": 0.999871423156057},
52
+ ],
53
+ }
54
+
55
+ text = cli._format_human_result(result)
56
+
57
+ self.assertIn("trace x100", text)
58
+ self.assertIn("ready.", text)
59
+
60
+
61
+ if __name__ == "__main__":
62
+ unittest.main()