tritonparse 0.3.1.dev20251030071508__py3-none-any.whl → 0.3.1.dev20251101071506__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 +0 -1
- tritonparse/structured_logging.py +81 -8
- {tritonparse-0.3.1.dev20251030071508.dist-info → tritonparse-0.3.1.dev20251101071506.dist-info}/METADATA +1 -1
- {tritonparse-0.3.1.dev20251030071508.dist-info → tritonparse-0.3.1.dev20251101071506.dist-info}/RECORD +8 -8
- {tritonparse-0.3.1.dev20251030071508.dist-info → tritonparse-0.3.1.dev20251101071506.dist-info}/WHEEL +0 -0
- {tritonparse-0.3.1.dev20251030071508.dist-info → tritonparse-0.3.1.dev20251101071506.dist-info}/entry_points.txt +0 -0
- {tritonparse-0.3.1.dev20251030071508.dist-info → tritonparse-0.3.1.dev20251101071506.dist-info}/licenses/LICENSE +0 -0
- {tritonparse-0.3.1.dev20251030071508.dist-info → tritonparse-0.3.1.dev20251101071506.dist-info}/top_level.txt +0 -0
tritonparse/cli.py
CHANGED
|
@@ -48,6 +48,14 @@ TRITON_TRACE_LAUNCH = os.getenv("TRITON_TRACE_LAUNCH", None) in ["1", "true", "T
|
|
|
48
48
|
TRITONPARSE_MORE_TENSOR_INFORMATION = os.getenv(
|
|
49
49
|
"TRITONPARSE_MORE_TENSOR_INFORMATION", None
|
|
50
50
|
) in ["1", "true", "True"]
|
|
51
|
+
# Enable full Python source file extraction instead of just the function definition
|
|
52
|
+
TRITON_FULL_PYTHON_SOURCE = os.getenv("TRITON_FULL_PYTHON_SOURCE", "0") in [
|
|
53
|
+
"1",
|
|
54
|
+
"true",
|
|
55
|
+
"True",
|
|
56
|
+
]
|
|
57
|
+
# Maximum file size for full source extraction (default 10MB)
|
|
58
|
+
TRITON_MAX_SOURCE_SIZE = int(os.getenv("TRITON_MAX_SOURCE_SIZE", str(10 * 1024 * 1024)))
|
|
51
59
|
# Inductor compiled kernel's launch tracing needs this flag to be set.
|
|
52
60
|
# If TRITON_TRACE_LAUNCH is enabled, also enable TORCHINDUCTOR_RUN_JIT_POST_COMPILE_HOOK
|
|
53
61
|
TORCHINDUCTOR_RUN_JIT_POST_COMPILE_HOOK = (
|
|
@@ -727,6 +735,17 @@ def extract_python_source_info(trace_data: Dict[str, Any], source):
|
|
|
727
735
|
from the provided source object (typically an ASTSource or IRSource instance).
|
|
728
736
|
It adds file path, line numbers, and the actual source code to the trace_data.
|
|
729
737
|
|
|
738
|
+
By default, only the function definition is extracted. Set TRITON_FULL_PYTHON_SOURCE=1
|
|
739
|
+
to extract the entire Python source file.
|
|
740
|
+
@TODO: we should enable it by default in next diff and track the compilation time regression
|
|
741
|
+
|
|
742
|
+
Environment Variables:
|
|
743
|
+
TRITON_FULL_PYTHON_SOURCE: If set to "1", extract the full Python file
|
|
744
|
+
instead of just the function definition.
|
|
745
|
+
TRITON_MAX_SOURCE_SIZE: Maximum file size in bytes for full source extraction
|
|
746
|
+
(default: 10MB). Files larger than this will fall back
|
|
747
|
+
to function-only mode.
|
|
748
|
+
|
|
730
749
|
Args:
|
|
731
750
|
trace_data (Dict[str, Any]): Dictionary to store extracted information
|
|
732
751
|
source (Union[ASTSource, IRSource]): Source object containing kernel function information
|
|
@@ -738,23 +757,77 @@ def extract_python_source_info(trace_data: Dict[str, Any], source):
|
|
|
738
757
|
if isinstance(source, IRSource):
|
|
739
758
|
return
|
|
740
759
|
|
|
741
|
-
# Get the
|
|
760
|
+
# Get the function reference
|
|
761
|
+
if isinstance(fn := source.fn, JITFunction):
|
|
762
|
+
fn_ref = fn.fn
|
|
763
|
+
else:
|
|
764
|
+
fn_ref = source.fn
|
|
765
|
+
|
|
766
|
+
python_source_file = inspect.getfile(fn_ref)
|
|
767
|
+
|
|
768
|
+
# Get function range information
|
|
742
769
|
if (
|
|
743
770
|
isinstance(fn := source.fn, JITFunction)
|
|
744
771
|
and hasattr(fn, "starting_line_number")
|
|
745
772
|
and hasattr(fn, "raw_src")
|
|
746
773
|
):
|
|
747
|
-
|
|
774
|
+
function_start_line = fn.starting_line_number
|
|
748
775
|
source_lines = fn.raw_src
|
|
749
776
|
else:
|
|
750
|
-
source_lines,
|
|
777
|
+
source_lines, function_start_line = inspect.getsourcelines(fn_ref)
|
|
778
|
+
|
|
779
|
+
function_end_line = function_start_line + len(source_lines) - 1
|
|
780
|
+
|
|
781
|
+
if TRITON_FULL_PYTHON_SOURCE:
|
|
782
|
+
# Full file mode: read the entire Python file
|
|
783
|
+
try:
|
|
784
|
+
# Check file size before reading
|
|
785
|
+
file_size = os.path.getsize(python_source_file)
|
|
786
|
+
except OSError as e:
|
|
787
|
+
log.warning(
|
|
788
|
+
f"Failed to check file size for {python_source_file}: {e}. "
|
|
789
|
+
f"Falling back to function-only mode."
|
|
790
|
+
)
|
|
791
|
+
use_full_source = False
|
|
792
|
+
else:
|
|
793
|
+
if file_size > TRITON_MAX_SOURCE_SIZE:
|
|
794
|
+
log.warning(
|
|
795
|
+
f"Source file {python_source_file} is too large ({file_size} bytes, "
|
|
796
|
+
f"limit: {TRITON_MAX_SOURCE_SIZE} bytes). Falling back to function-only mode."
|
|
797
|
+
)
|
|
798
|
+
use_full_source = False
|
|
799
|
+
else:
|
|
800
|
+
use_full_source = True
|
|
801
|
+
|
|
802
|
+
if use_full_source:
|
|
803
|
+
try:
|
|
804
|
+
with open(python_source_file, "r", encoding="utf-8") as f:
|
|
805
|
+
file_content = f.read()
|
|
806
|
+
|
|
807
|
+
# Calculate total lines
|
|
808
|
+
total_lines = len(file_content.split("\n"))
|
|
809
|
+
|
|
810
|
+
trace_data["python_source"] = {
|
|
811
|
+
"file_path": python_source_file,
|
|
812
|
+
"start_line": 1,
|
|
813
|
+
"end_line": total_lines,
|
|
814
|
+
"code": file_content,
|
|
815
|
+
# Add function range for frontend highlighting and scrolling
|
|
816
|
+
"function_start_line": function_start_line,
|
|
817
|
+
"function_end_line": function_end_line,
|
|
818
|
+
}
|
|
819
|
+
return
|
|
820
|
+
except (OSError, UnicodeDecodeError) as e:
|
|
821
|
+
log.warning(
|
|
822
|
+
f"Failed to read full source file {python_source_file}: {e}. "
|
|
823
|
+
f"Falling back to function-only mode."
|
|
824
|
+
)
|
|
751
825
|
|
|
752
|
-
|
|
753
|
-
end_line_number = start_line_number + len(source_lines)
|
|
826
|
+
# Default behavior: only extract function definition
|
|
754
827
|
trace_data["python_source"] = {
|
|
755
828
|
"file_path": python_source_file,
|
|
756
|
-
"start_line":
|
|
757
|
-
"end_line":
|
|
829
|
+
"start_line": function_start_line,
|
|
830
|
+
"end_line": function_end_line,
|
|
758
831
|
"code": "".join(source_lines),
|
|
759
832
|
}
|
|
760
833
|
|
|
@@ -910,7 +983,7 @@ class TritonTraceHandler(logging.StreamHandler):
|
|
|
910
983
|
)
|
|
911
984
|
elif not os.access(TRACE_LOG_DIR, os.W_OK):
|
|
912
985
|
log.info(
|
|
913
|
-
"TritonTraceHandler: disabled because %s is not
|
|
986
|
+
"TritonTraceHandler: disabled because %s is not writable",
|
|
914
987
|
TRACE_LOG_DIR,
|
|
915
988
|
)
|
|
916
989
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tritonparse
|
|
3
|
-
Version: 0.3.1.
|
|
3
|
+
Version: 0.3.1.dev20251101071506
|
|
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=RXbkALBewcb1xlJBnsQl9IaBRUNln7U8NuRZKT8UdIk,117
|
|
3
|
-
tritonparse/cli.py,sha256=
|
|
3
|
+
tritonparse/cli.py,sha256=CBGwJWGMkctenid-DUoqmguO5gCGd0xWw5D9RlBdqNQ,2792
|
|
4
4
|
tritonparse/common.py,sha256=MJo9bVCgSKkwXpEoUkUczPo_5jOYpJgXLq4UsWYqN3c,13924
|
|
5
5
|
tritonparse/context_manager.py,sha256=OdMn11qbApYL2c9IlbUpcT27r04ZSa4DfvrY2mLA958,2243
|
|
6
6
|
tritonparse/event_diff.py,sha256=USCjfjYr-7Ie-EfZgtCFMZMA1KRzFRDe7yDFy98zYI4,4962
|
|
@@ -11,7 +11,7 @@ tritonparse/mapper.py,sha256=QBCUMHM9pu3x3ahFp0wyXJbmv9TFGVPdkcLULok1E-k,4205
|
|
|
11
11
|
tritonparse/shared_vars.py,sha256=RifXq55KisHgspYAmGcaCWY6ZHX8iejFHvwIewvcWZE,707
|
|
12
12
|
tritonparse/source_type.py,sha256=nmYEQS8rfkIN9BhNhQbkmEvKnvS-3zAxRGLY4TaZdi8,1676
|
|
13
13
|
tritonparse/sourcemap_utils.py,sha256=uI02n5Sgnlx7Nc15QAX5N6_tZZMips0PyJuo1n3eouY,2654
|
|
14
|
-
tritonparse/structured_logging.py,sha256=
|
|
14
|
+
tritonparse/structured_logging.py,sha256=aBTfRVuZzd7YJV-Fgg513SPlbEceyWosONLqaTZS69k,63319
|
|
15
15
|
tritonparse/tp_logger.py,sha256=vXzY7hMDmVnRBGBhIjFZe3nHZzG5NKKPONGUszJhGgU,242
|
|
16
16
|
tritonparse/trace_processor.py,sha256=AW4YDrPDayURtmePkFi5m5p6P7OTi1UlTPbbrPzujwY,14418
|
|
17
17
|
tritonparse/utils.py,sha256=Jnlptcd79llSDev-_1XyyOnv2izUqv0PEL74A8GF2tc,4565
|
|
@@ -34,9 +34,9 @@ tritonparse/tools/format_fix.py,sha256=ISalg_N_L7Xktag3mLr-G9T6Opxv793s1WG6A9wUt
|
|
|
34
34
|
tritonparse/tools/load_tensor.py,sha256=7-LbpboKDNJFBLNhiKS3enoqRlVAb55OjPc70PwHXAw,2789
|
|
35
35
|
tritonparse/tools/prettify_ndjson.py,sha256=kR8hmBCv-iJeuzpi2_6CZv9T4_edRQbBOSOPpMm6wrw,11117
|
|
36
36
|
tritonparse/tools/readme.md,sha256=w6PWYfYnRgoPArLjxG9rVrpcLUkoVMGuRlbpF-o0IQM,110
|
|
37
|
-
tritonparse-0.3.1.
|
|
38
|
-
tritonparse-0.3.1.
|
|
39
|
-
tritonparse-0.3.1.
|
|
40
|
-
tritonparse-0.3.1.
|
|
41
|
-
tritonparse-0.3.1.
|
|
42
|
-
tritonparse-0.3.1.
|
|
37
|
+
tritonparse-0.3.1.dev20251101071506.dist-info/licenses/LICENSE,sha256=4ZciugpyN7wcM4L-9pyDh_etvMUeIfBhDTyH1zeZlQM,1515
|
|
38
|
+
tritonparse-0.3.1.dev20251101071506.dist-info/METADATA,sha256=XavQSRG05Q5AlaCXfrfPN0BWcD8aUg2yIhOwmrs8e1M,8282
|
|
39
|
+
tritonparse-0.3.1.dev20251101071506.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
40
|
+
tritonparse-0.3.1.dev20251101071506.dist-info/entry_points.txt,sha256=wEXdaieDoRRCCdhEv2p_C68iytnaXU_2pwt5CqjfbWY,56
|
|
41
|
+
tritonparse-0.3.1.dev20251101071506.dist-info/top_level.txt,sha256=ITcTKgp3vf_bXV9vixuQU9IrZa3L1EfDSZwvRzRaoJU,12
|
|
42
|
+
tritonparse-0.3.1.dev20251101071506.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|