tritonparse 0.2.4.dev20251012071503__py3-none-any.whl → 0.2.4.dev20251014071550__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/cli.py +1 -0
- tritonparse/reproducer/cli.py +14 -0
- tritonparse/reproducer/orchestrator.py +7 -1
- tritonparse/reproducer/placeholder_replacer.py +48 -4
- tritonparse/reproducer/types.py +15 -0
- {tritonparse-0.2.4.dev20251012071503.dist-info → tritonparse-0.2.4.dev20251014071550.dist-info}/METADATA +1 -1
- {tritonparse-0.2.4.dev20251012071503.dist-info → tritonparse-0.2.4.dev20251014071550.dist-info}/RECORD +11 -10
- {tritonparse-0.2.4.dev20251012071503.dist-info → tritonparse-0.2.4.dev20251014071550.dist-info}/WHEEL +0 -0
- {tritonparse-0.2.4.dev20251012071503.dist-info → tritonparse-0.2.4.dev20251014071550.dist-info}/entry_points.txt +0 -0
- {tritonparse-0.2.4.dev20251012071503.dist-info → tritonparse-0.2.4.dev20251014071550.dist-info}/licenses/LICENSE +0 -0
- {tritonparse-0.2.4.dev20251012071503.dist-info → tritonparse-0.2.4.dev20251014071550.dist-info}/top_level.txt +0 -0
tritonparse/cli.py
CHANGED
tritonparse/reproducer/cli.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
|
|
3
|
+
from tritonparse.reproducer.types import KernelImportMode
|
|
4
|
+
|
|
3
5
|
|
|
4
6
|
def _add_reproducer_args(parser: argparse.ArgumentParser) -> None:
|
|
5
7
|
"""Add common arguments for the reproducer to a parser."""
|
|
@@ -29,3 +31,15 @@ def _add_reproducer_args(parser: argparse.ArgumentParser) -> None:
|
|
|
29
31
|
"Defaults to 'example'."
|
|
30
32
|
),
|
|
31
33
|
)
|
|
34
|
+
parser.add_argument(
|
|
35
|
+
"--kernel-import",
|
|
36
|
+
type=KernelImportMode,
|
|
37
|
+
choices=list(KernelImportMode),
|
|
38
|
+
default=KernelImportMode.DEFAULT,
|
|
39
|
+
help=(
|
|
40
|
+
"Kernel import strategy:\n"
|
|
41
|
+
" default: Import kernel from original file (current behavior)\n"
|
|
42
|
+
" copy: Embed kernel source code directly in reproducer\n"
|
|
43
|
+
"Defaults to 'default'."
|
|
44
|
+
),
|
|
45
|
+
)
|
|
@@ -7,6 +7,7 @@ from tritonparse.reproducer.placeholder_replacer import (
|
|
|
7
7
|
PlaceholderReplacer,
|
|
8
8
|
)
|
|
9
9
|
from tritonparse.reproducer.templates.loader import load_template_code
|
|
10
|
+
from tritonparse.reproducer.types import KernelImportMode
|
|
10
11
|
from tritonparse.reproducer.utils import determine_output_paths
|
|
11
12
|
|
|
12
13
|
from tritonparse.tools.prettify_ndjson import load_ndjson, save_prettified_json
|
|
@@ -19,6 +20,7 @@ def reproduce(
|
|
|
19
20
|
out_dir: str,
|
|
20
21
|
template: str,
|
|
21
22
|
replacer: Optional[PlaceholderReplacer] = None,
|
|
23
|
+
kernel_import: KernelImportMode = KernelImportMode.DEFAULT,
|
|
22
24
|
) -> dict[str, Path]:
|
|
23
25
|
"""
|
|
24
26
|
Generate a reproducer script from NDJSON trace file.
|
|
@@ -29,6 +31,7 @@ def reproduce(
|
|
|
29
31
|
out_dir: Output directory for reproducer files.
|
|
30
32
|
template: Template name to use for the reproducer.
|
|
31
33
|
replacer: Optional custom PlaceholderReplacer instance. If None, uses DefaultPlaceholderReplacer.
|
|
34
|
+
kernel_import: Kernel import mode (DEFAULT or COPY).
|
|
32
35
|
"""
|
|
33
36
|
logger.debug(f"Building bundle from {input_path} at line {line_index}")
|
|
34
37
|
events = load_ndjson(Path(input_path))
|
|
@@ -51,7 +54,10 @@ def reproduce(
|
|
|
51
54
|
if replacer is None:
|
|
52
55
|
replacer = DefaultPlaceholderReplacer()
|
|
53
56
|
final_code = replacer.replace(
|
|
54
|
-
template_code,
|
|
57
|
+
template_code,
|
|
58
|
+
context_bundle,
|
|
59
|
+
temp_json_path=temp_json_path,
|
|
60
|
+
kernel_import=kernel_import,
|
|
55
61
|
)
|
|
56
62
|
|
|
57
63
|
out_py_path.write_text(final_code, encoding="utf-8")
|
|
@@ -3,6 +3,7 @@ from abc import ABC
|
|
|
3
3
|
from typing import Any, Dict, Protocol
|
|
4
4
|
|
|
5
5
|
from tritonparse.reproducer.ingestion.ndjson import ContextBundle
|
|
6
|
+
from tritonparse.reproducer.types import KernelImportMode
|
|
6
7
|
from tritonparse.reproducer.utils import (
|
|
7
8
|
_generate_import_statements,
|
|
8
9
|
_generate_invocation_snippet,
|
|
@@ -95,15 +96,58 @@ class DefaultPlaceholderReplacer(PlaceholderReplacer):
|
|
|
95
96
|
self, code: str, context_bundle: ContextBundle, **kwargs
|
|
96
97
|
) -> str:
|
|
97
98
|
"""Replace the kernel sys.path placeholder."""
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
kernel_import = kwargs.get("kernel_import", KernelImportMode.DEFAULT)
|
|
100
|
+
|
|
101
|
+
if kernel_import == KernelImportMode.DEFAULT:
|
|
102
|
+
sys_stmt, _ = _generate_import_statements(context_bundle.kernel_info)
|
|
103
|
+
return code.replace("# {{KERNEL_SYSPATH_PLACEHOLDER}}", sys_stmt)
|
|
104
|
+
elif kernel_import == KernelImportMode.COPY:
|
|
105
|
+
comment = (
|
|
106
|
+
"# Kernel sys.path setup skipped - kernel source code embedded below"
|
|
107
|
+
)
|
|
108
|
+
return code.replace("# {{KERNEL_SYSPATH_PLACEHOLDER}}", comment)
|
|
109
|
+
else:
|
|
110
|
+
raise ValueError(f"Unknown kernel_import mode: {kernel_import}")
|
|
100
111
|
|
|
101
112
|
def _replace_kernel_import(
|
|
102
113
|
self, code: str, context_bundle: ContextBundle, **kwargs
|
|
103
114
|
) -> str:
|
|
104
115
|
"""Replace the kernel import placeholder."""
|
|
105
|
-
|
|
106
|
-
|
|
116
|
+
kernel_import = kwargs.get("kernel_import", KernelImportMode.DEFAULT)
|
|
117
|
+
|
|
118
|
+
if kernel_import == KernelImportMode.DEFAULT:
|
|
119
|
+
_, import_statement = _generate_import_statements(
|
|
120
|
+
context_bundle.kernel_info
|
|
121
|
+
)
|
|
122
|
+
return code.replace("# {{KERNEL_IMPORT_PLACEHOLDER}}", import_statement)
|
|
123
|
+
elif kernel_import == KernelImportMode.COPY:
|
|
124
|
+
source_code = context_bundle.kernel_info.source_code
|
|
125
|
+
func_name = context_bundle.kernel_info.function_name
|
|
126
|
+
|
|
127
|
+
if not source_code or not source_code.strip():
|
|
128
|
+
raise ValueError("Kernel source code is empty, cannot use 'copy' mode")
|
|
129
|
+
if not func_name:
|
|
130
|
+
raise ValueError(
|
|
131
|
+
"Cannot determine kernel function name for 'copy' mode"
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
# Add common imports needed for most Triton kernels
|
|
135
|
+
import_lines = [
|
|
136
|
+
"import torch",
|
|
137
|
+
"import numpy as np",
|
|
138
|
+
"import triton",
|
|
139
|
+
"import triton.language as tl",
|
|
140
|
+
"",
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
# Combine: imports + kernel source code + alias
|
|
144
|
+
embedded_code = "\n".join(import_lines)
|
|
145
|
+
embedded_code += "\n" + source_code
|
|
146
|
+
embedded_code += f"\n\n# Use kernel function directly\nimported_kernel_function = {func_name}"
|
|
147
|
+
|
|
148
|
+
return code.replace("# {{KERNEL_IMPORT_PLACEHOLDER}}", embedded_code)
|
|
149
|
+
else:
|
|
150
|
+
raise ValueError(f"Unknown kernel_import mode: {kernel_import}")
|
|
107
151
|
|
|
108
152
|
def _replace_kernel_invocation(
|
|
109
153
|
self, code: str, context_bundle: ContextBundle, **kwargs
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class KernelImportMode(str, Enum):
|
|
5
|
+
"""
|
|
6
|
+
Kernel import strategy for reproducer generation.
|
|
7
|
+
|
|
8
|
+
Inherits from str to allow direct string comparison and use in argparse.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
DEFAULT = "default" # Import kernel from original file (current behavior)
|
|
12
|
+
COPY = "copy" # Embed kernel source code directly in reproducer
|
|
13
|
+
|
|
14
|
+
# Future modes can be added here:
|
|
15
|
+
# OVERRIDE_TTIR = "override-ttir" # Use TTIR from compilation event with monkeypatch
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tritonparse
|
|
3
|
-
Version: 0.2.4.
|
|
3
|
+
Version: 0.2.4.dev20251014071550
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
tritonparse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
tritonparse/__main__.py,sha256=wu5N2wk8mvBgyvr2ghmQf4prezAe0_i-p123VVreyYc,62
|
|
3
|
-
tritonparse/cli.py,sha256=
|
|
3
|
+
tritonparse/cli.py,sha256=w_sCIv1NlcGDzoflsYuTvtQis92_YuZEC51ZlTVsYCU,2517
|
|
4
4
|
tritonparse/common.py,sha256=9coQbzpyHWAAdv6lx2YQTualiIH49ULJuZTA7VB_V7A,13946
|
|
5
5
|
tritonparse/context_manager.py,sha256=MqAWI8uD1uCeCbmkcEWPejc5_IeY---BdajhsSR9T_E,2221
|
|
6
6
|
tritonparse/event_diff.py,sha256=yOD6uNxLJroatfx2nEGr-erw24ObOrHU9P6V5pzr8do,4907
|
|
@@ -15,9 +15,10 @@ tritonparse/tp_logger.py,sha256=vXzY7hMDmVnRBGBhIjFZe3nHZzG5NKKPONGUszJhGgU,242
|
|
|
15
15
|
tritonparse/trace_processor.py,sha256=brQBt26jdB6-quJXP5-warp2j31JSjOOFJa5ayiUZ5k,12963
|
|
16
16
|
tritonparse/utils.py,sha256=Jnlptcd79llSDev-_1XyyOnv2izUqv0PEL74A8GF2tc,4565
|
|
17
17
|
tritonparse/reproducer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
tritonparse/reproducer/cli.py,sha256=
|
|
19
|
-
tritonparse/reproducer/orchestrator.py,sha256=
|
|
20
|
-
tritonparse/reproducer/placeholder_replacer.py,sha256=
|
|
18
|
+
tritonparse/reproducer/cli.py,sha256=xV3HZdNiWF44JCfJOGKHpoF8TErqbm4ohuLAK0pXcRw,1432
|
|
19
|
+
tritonparse/reproducer/orchestrator.py,sha256=AtfR78HAsqDYMF-C00-jH6jVWs3aQ0bt74RBCakoqyc,2767
|
|
20
|
+
tritonparse/reproducer/placeholder_replacer.py,sha256=0dtnfuaVqj_aX2fH4omMPFeIz6673Vc4yeQcZCLr5UA,6425
|
|
21
|
+
tritonparse/reproducer/types.py,sha256=3cwVzWe4wRJXtR_KCta8hYtIwNQOxL5SJDocLnMQNgg,485
|
|
21
22
|
tritonparse/reproducer/utils.py,sha256=UTclw48vH49g6Z2ljJL5DOZ6Rl4UDudyr0PeUySa3p8,13857
|
|
22
23
|
tritonparse/reproducer/ingestion/ndjson.py,sha256=pEujTl5xXW2E2DEW8ngxXQ8qP9oawb90wBVTWHDs1jk,7372
|
|
23
24
|
tritonparse/reproducer/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -30,9 +31,9 @@ tritonparse/tools/format_fix.py,sha256=Ol0Sjui8D7OzHwbamAfGnq8V5Y63uwNaFTKSORN5H
|
|
|
30
31
|
tritonparse/tools/load_tensor.py,sha256=94-TiSYlpXJx4MPmGK1ovmZlTt56Q_B3KQeCPaA6Cnw,2734
|
|
31
32
|
tritonparse/tools/prettify_ndjson.py,sha256=r2YlHwFDTHgML7KljRmMsHaDg29q8gOQAgyDKWJhxRM,11062
|
|
32
33
|
tritonparse/tools/readme.md,sha256=w6PWYfYnRgoPArLjxG9rVrpcLUkoVMGuRlbpF-o0IQM,110
|
|
33
|
-
tritonparse-0.2.4.
|
|
34
|
-
tritonparse-0.2.4.
|
|
35
|
-
tritonparse-0.2.4.
|
|
36
|
-
tritonparse-0.2.4.
|
|
37
|
-
tritonparse-0.2.4.
|
|
38
|
-
tritonparse-0.2.4.
|
|
34
|
+
tritonparse-0.2.4.dev20251014071550.dist-info/licenses/LICENSE,sha256=4ZciugpyN7wcM4L-9pyDh_etvMUeIfBhDTyH1zeZlQM,1515
|
|
35
|
+
tritonparse-0.2.4.dev20251014071550.dist-info/METADATA,sha256=NRX3WAhjKHGcj7dw72sUFiiKzuAhiqgWDwRxaKvoXiM,8278
|
|
36
|
+
tritonparse-0.2.4.dev20251014071550.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
37
|
+
tritonparse-0.2.4.dev20251014071550.dist-info/entry_points.txt,sha256=wEXdaieDoRRCCdhEv2p_C68iytnaXU_2pwt5CqjfbWY,56
|
|
38
|
+
tritonparse-0.2.4.dev20251014071550.dist-info/top_level.txt,sha256=ITcTKgp3vf_bXV9vixuQU9IrZa3L1EfDSZwvRzRaoJU,12
|
|
39
|
+
tritonparse-0.2.4.dev20251014071550.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|