tritonparse 0.3.1.dev20251023071548__py3-none-any.whl → 0.3.1.dev20251024071516__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.
Potentially problematic release.
This version of tritonparse might be problematic. Click here for more details.
- tritonparse/ir_analysis.py +72 -0
- tritonparse/sourcemap_utils.py +22 -0
- tritonparse/trace_processor.py +11 -13
- {tritonparse-0.3.1.dev20251023071548.dist-info → tritonparse-0.3.1.dev20251024071516.dist-info}/METADATA +1 -1
- {tritonparse-0.3.1.dev20251023071548.dist-info → tritonparse-0.3.1.dev20251024071516.dist-info}/RECORD +9 -8
- {tritonparse-0.3.1.dev20251023071548.dist-info → tritonparse-0.3.1.dev20251024071516.dist-info}/WHEEL +0 -0
- {tritonparse-0.3.1.dev20251023071548.dist-info → tritonparse-0.3.1.dev20251024071516.dist-info}/entry_points.txt +0 -0
- {tritonparse-0.3.1.dev20251023071548.dist-info → tritonparse-0.3.1.dev20251024071516.dist-info}/licenses/LICENSE +0 -0
- {tritonparse-0.3.1.dev20251023071548.dist-info → tritonparse-0.3.1.dev20251024071516.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from .sourcemap_utils import load_ir_contents
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("IRAnalysis")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def process_amd_bufferop(ir_content: str, io_keys: list[str]) -> dict[str, int]:
|
|
10
|
+
def make_key(prefix: str) -> str:
|
|
11
|
+
return f"{prefix}_count"
|
|
12
|
+
|
|
13
|
+
io_keys = [(make_key(prefix), prefix) for prefix in io_keys]
|
|
14
|
+
output: dict[str, int] = {}
|
|
15
|
+
for dict_key, _ in io_keys:
|
|
16
|
+
output[dict_key] = 0
|
|
17
|
+
if ir_content:
|
|
18
|
+
for line in ir_content.split("\n"):
|
|
19
|
+
for dict_key, code_key in io_keys:
|
|
20
|
+
if code_key in line:
|
|
21
|
+
output[dict_key] += 1
|
|
22
|
+
return output
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def process_amd_ttgir_bufferops(
|
|
26
|
+
key: str,
|
|
27
|
+
file_content: dict[str, str],
|
|
28
|
+
file_path: dict[str, str],
|
|
29
|
+
) -> dict[str, int]:
|
|
30
|
+
ir_content = load_ir_contents(key, file_content, file_path)
|
|
31
|
+
# TODO: Add atomics
|
|
32
|
+
io_keys = ["tt.load", "tt.store", "amdgpu.buffer_load", "amdgpu.buffer_store"]
|
|
33
|
+
return process_amd_bufferop(ir_content, io_keys)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def process_amd_gcn_bufferops(
|
|
37
|
+
key: str,
|
|
38
|
+
file_content: dict[str, str],
|
|
39
|
+
file_path: dict[str, str],
|
|
40
|
+
) -> dict[str, int]:
|
|
41
|
+
ir_content = load_ir_contents(key, file_content, file_path)
|
|
42
|
+
# TODO: Add atomics
|
|
43
|
+
io_keys = ["global_load_", "global_store_", "buffer_load_", "buffer_store_"]
|
|
44
|
+
return process_amd_bufferop(ir_content, io_keys)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _generate_ir_analysis(entry: str):
|
|
48
|
+
payload = entry.setdefault("payload", {})
|
|
49
|
+
file_content = payload.get("file_content", {})
|
|
50
|
+
file_path = payload.get("file_path", {})
|
|
51
|
+
|
|
52
|
+
# Find the IR file keys
|
|
53
|
+
ttgir_key = next((k for k in file_content if k.endswith(".ttgir")), None)
|
|
54
|
+
amdgcn_key = next((k for k in file_content if k.endswith(".amdgcn")), None)
|
|
55
|
+
# Skip if no IR files found
|
|
56
|
+
if not (ttgir_key or amdgcn_key):
|
|
57
|
+
logger.debug("No AMD IR found")
|
|
58
|
+
return {}
|
|
59
|
+
ir_analysis = {}
|
|
60
|
+
if amdgcn_key:
|
|
61
|
+
ttgir_bufferops_info = process_amd_ttgir_bufferops(
|
|
62
|
+
ttgir_key, file_content, file_path
|
|
63
|
+
)
|
|
64
|
+
gcn_bufferops_info = process_amd_gcn_bufferops(
|
|
65
|
+
amdgcn_key, file_content, file_path
|
|
66
|
+
)
|
|
67
|
+
# NDJSON format requires a newline at the end of each line
|
|
68
|
+
if ttgir_bufferops_info:
|
|
69
|
+
ir_analysis["amd_ttgir_bufferops_count"] = ttgir_bufferops_info
|
|
70
|
+
if gcn_bufferops_info:
|
|
71
|
+
ir_analysis["amd_gcn_bufferops_count"] = gcn_bufferops_info
|
|
72
|
+
return {"ir_analysis": ir_analysis}
|
tritonparse/sourcemap_utils.py
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
from typing import Any, Dict, List
|
|
2
3
|
|
|
4
|
+
logger = logging.getLogger("SourceMapping")
|
|
5
|
+
|
|
3
6
|
|
|
4
7
|
def get_file_extension(filename: str) -> str:
|
|
5
8
|
"""
|
|
@@ -70,3 +73,22 @@ def _to_ranges(indices: List[int]) -> List[Dict[str, int]]:
|
|
|
70
73
|
|
|
71
74
|
ranges.append({"start": start, "end": end})
|
|
72
75
|
return ranges
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def load_ir_contents(
|
|
79
|
+
key: str,
|
|
80
|
+
file_content: dict[str, str],
|
|
81
|
+
file_path: dict[str, str],
|
|
82
|
+
):
|
|
83
|
+
if not key:
|
|
84
|
+
return {}
|
|
85
|
+
logger.debug(f"Processing {key}")
|
|
86
|
+
ir_content = file_content.get(key, None)
|
|
87
|
+
if not ir_content:
|
|
88
|
+
ir_file_path = file_path.get(key, None)
|
|
89
|
+
if not ir_file_path:
|
|
90
|
+
logger.warning(f"No content found for {key}")
|
|
91
|
+
return {}
|
|
92
|
+
with open(ir_file_path, "r") as f:
|
|
93
|
+
ir_content = f.read()
|
|
94
|
+
return ir_content
|
tritonparse/trace_processor.py
CHANGED
|
@@ -6,6 +6,7 @@ from collections import defaultdict
|
|
|
6
6
|
from typing import Any, Dict, List
|
|
7
7
|
|
|
8
8
|
from .event_diff import _generate_launch_diff
|
|
9
|
+
from .ir_analysis import _generate_ir_analysis
|
|
9
10
|
|
|
10
11
|
from .ir_parser import (
|
|
11
12
|
extract_code_locations,
|
|
@@ -13,7 +14,7 @@ from .ir_parser import (
|
|
|
13
14
|
extract_ptx_amdgcn_mappings,
|
|
14
15
|
)
|
|
15
16
|
from .mapper import create_bidirectional_mapping, create_python_mapping
|
|
16
|
-
from .sourcemap_utils import get_file_extension
|
|
17
|
+
from .sourcemap_utils import get_file_extension, load_ir_contents
|
|
17
18
|
|
|
18
19
|
logger = logging.getLogger("SourceMapping")
|
|
19
20
|
|
|
@@ -84,19 +85,9 @@ def process_ir(
|
|
|
84
85
|
file_path: Dict[str, str],
|
|
85
86
|
other_mappings: List[Any] = None,
|
|
86
87
|
):
|
|
87
|
-
|
|
88
|
-
# the key should be the full file name with extension for the IR files
|
|
89
|
-
if not key:
|
|
90
|
-
return {}
|
|
91
|
-
logger.debug(f"Processing {key}")
|
|
92
|
-
ir_content = file_content.get(key, None)
|
|
88
|
+
ir_content = load_ir_contents(key, file_content, file_path)
|
|
93
89
|
if not ir_content:
|
|
94
|
-
|
|
95
|
-
if not ir_file_path:
|
|
96
|
-
logger.warning(f"No content found for {key}")
|
|
97
|
-
return {}
|
|
98
|
-
with open(ir_file_path, "r") as f:
|
|
99
|
-
ir_content = f.read()
|
|
90
|
+
return {}
|
|
100
91
|
mapping = generate_source_mappings(ir_content, key.split(".")[1], other_mappings)
|
|
101
92
|
logger.debug(f"Generated source mapping for {key}")
|
|
102
93
|
return mapping
|
|
@@ -307,6 +298,13 @@ def parse_single_file(
|
|
|
307
298
|
json.dumps(launch_event, separators=(",", ":")) + "\n"
|
|
308
299
|
)
|
|
309
300
|
|
|
301
|
+
if compilation_event:
|
|
302
|
+
ir_analysis_event = _generate_ir_analysis(compilation_event)
|
|
303
|
+
if ir_analysis_event:
|
|
304
|
+
all_output_lines[output_file].append(
|
|
305
|
+
json.dumps(ir_analysis_event, separators=(",", ":")) + "\n"
|
|
306
|
+
)
|
|
307
|
+
|
|
310
308
|
if compilation_event and launches_with_indices:
|
|
311
309
|
sames, diffs, launch_index_map = _generate_launch_diff(
|
|
312
310
|
launches_with_indices
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tritonparse
|
|
3
|
-
Version: 0.3.1.
|
|
3
|
+
Version: 0.3.1.dev20251024071516
|
|
4
4
|
Summary: TritonParse: A Compiler Tracer, Visualizer, and mini-Reproducer Generator for Triton Kernels
|
|
5
5
|
Author-email: Yueming Hao <yhao@meta.com>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -5,14 +5,15 @@ tritonparse/common.py,sha256=MJo9bVCgSKkwXpEoUkUczPo_5jOYpJgXLq4UsWYqN3c,13924
|
|
|
5
5
|
tritonparse/context_manager.py,sha256=R6zKoixi8aXF2yK8pN1EUVPPmldhhXMdEK_PgKZjaX4,2188
|
|
6
6
|
tritonparse/event_diff.py,sha256=yOD6uNxLJroatfx2nEGr-erw24ObOrHU9P6V5pzr8do,4907
|
|
7
7
|
tritonparse/extract_source_mappings.py,sha256=Z6UxFj2cCE5NCWLQTYPKqUpLfbYhqP8xgCl5mvud9KI,1451
|
|
8
|
+
tritonparse/ir_analysis.py,sha256=ERu6EWotqcW99ZGNEH-mxGyYej45yt0IXx0OCab_bfw,2427
|
|
8
9
|
tritonparse/ir_parser.py,sha256=1j1tP9jpUN7wH3e01bKUkUPgTMlNXUdp8LKRCC-WTro,9324
|
|
9
10
|
tritonparse/mapper.py,sha256=prrczfi13P7Aa042OrEBsmRF1HW3jDhwxicANgPkWIM,4150
|
|
10
11
|
tritonparse/shared_vars.py,sha256=fCAW24mx9nENYoNbTy-tZjiN5-w6oGTO_av-Pw1J1TY,653
|
|
11
12
|
tritonparse/source_type.py,sha256=nmYEQS8rfkIN9BhNhQbkmEvKnvS-3zAxRGLY4TaZdi8,1676
|
|
12
|
-
tritonparse/sourcemap_utils.py,sha256=
|
|
13
|
+
tritonparse/sourcemap_utils.py,sha256=f36lKjc23qx4aOgpHOOo2lxPF4rwgSrOcULZqyUKxn0,2599
|
|
13
14
|
tritonparse/structured_logging.py,sha256=L1xkkCx8Jr9YQbM0Kgtf2g6L3aWMkYOEeFFEOSo8Lkk,60306
|
|
14
15
|
tritonparse/tp_logger.py,sha256=vXzY7hMDmVnRBGBhIjFZe3nHZzG5NKKPONGUszJhGgU,242
|
|
15
|
-
tritonparse/trace_processor.py,sha256=
|
|
16
|
+
tritonparse/trace_processor.py,sha256=DMY03eqQbM1oUbQuMkfHV_rlaKmW4ggJ048FMCbOH3c,12926
|
|
16
17
|
tritonparse/utils.py,sha256=Jnlptcd79llSDev-_1XyyOnv2izUqv0PEL74A8GF2tc,4565
|
|
17
18
|
tritonparse/reproducer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
19
|
tritonparse/reproducer/cli.py,sha256=MqYuuAP-uAIWWLQxixwyyBHJGSaQdG3xXGaVjERTLX8,1522
|
|
@@ -32,9 +33,9 @@ tritonparse/tools/format_fix.py,sha256=Ol0Sjui8D7OzHwbamAfGnq8V5Y63uwNaFTKSORN5H
|
|
|
32
33
|
tritonparse/tools/load_tensor.py,sha256=94-TiSYlpXJx4MPmGK1ovmZlTt56Q_B3KQeCPaA6Cnw,2734
|
|
33
34
|
tritonparse/tools/prettify_ndjson.py,sha256=r2YlHwFDTHgML7KljRmMsHaDg29q8gOQAgyDKWJhxRM,11062
|
|
34
35
|
tritonparse/tools/readme.md,sha256=w6PWYfYnRgoPArLjxG9rVrpcLUkoVMGuRlbpF-o0IQM,110
|
|
35
|
-
tritonparse-0.3.1.
|
|
36
|
-
tritonparse-0.3.1.
|
|
37
|
-
tritonparse-0.3.1.
|
|
38
|
-
tritonparse-0.3.1.
|
|
39
|
-
tritonparse-0.3.1.
|
|
40
|
-
tritonparse-0.3.1.
|
|
36
|
+
tritonparse-0.3.1.dev20251024071516.dist-info/licenses/LICENSE,sha256=4ZciugpyN7wcM4L-9pyDh_etvMUeIfBhDTyH1zeZlQM,1515
|
|
37
|
+
tritonparse-0.3.1.dev20251024071516.dist-info/METADATA,sha256=zSXJHPi5BEV2zS_aiZBVSEGQXY8_xLp1f6YoC2NHFgQ,8278
|
|
38
|
+
tritonparse-0.3.1.dev20251024071516.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
39
|
+
tritonparse-0.3.1.dev20251024071516.dist-info/entry_points.txt,sha256=wEXdaieDoRRCCdhEv2p_C68iytnaXU_2pwt5CqjfbWY,56
|
|
40
|
+
tritonparse-0.3.1.dev20251024071516.dist-info/top_level.txt,sha256=ITcTKgp3vf_bXV9vixuQU9IrZa3L1EfDSZwvRzRaoJU,12
|
|
41
|
+
tritonparse-0.3.1.dev20251024071516.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|