tritonparse 0.3.1.dev20251026071454__tar.gz → 0.3.1.dev20251028071524__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.

Potentially problematic release.


This version of tritonparse might be problematic. Click here for more details.

Files changed (118) hide show
  1. {tritonparse-0.3.1.dev20251026071454/tritonparse.egg-info → tritonparse-0.3.1.dev20251028071524}/PKG-INFO +2 -2
  2. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/README.md +1 -1
  3. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tests/test_tritonparse.py +64 -0
  4. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/cli.py +1 -1
  5. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/ir_analysis.py +7 -4
  6. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/ir_parser.py +93 -2
  7. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/ingestion/ndjson.py +2 -2
  8. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/orchestrator.py +1 -1
  9. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/trace_processor.py +34 -3
  10. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524/tritonparse.egg-info}/PKG-INFO +2 -2
  11. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse.egg-info/SOURCES.txt +1 -0
  12. tritonparse-0.3.1.dev20251028071524/website/index.html +24 -0
  13. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/App.tsx +28 -2
  14. tritonparse-0.3.1.dev20251028071524/website/src/pages/IRAnalysis.tsx +98 -0
  15. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/utils/dataLoader.ts +16 -0
  16. tritonparse-0.3.1.dev20251026071454/website/index.html +0 -14
  17. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.ci/README.md +0 -0
  18. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.ci/install-project.sh +0 -0
  19. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.ci/install-triton.sh +0 -0
  20. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.ci/run-tests.sh +0 -0
  21. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.ci/setup.sh +0 -0
  22. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.github/PAGES_SETUP.md +0 -0
  23. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.github/workflows/deploy-pages-standalone.yml +0 -0
  24. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.github/workflows/deploy-pages.yml +0 -0
  25. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.github/workflows/nightly-pypi.yml +0 -0
  26. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.github/workflows/test.yml +0 -0
  27. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/.gitignore +0 -0
  28. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/CHANGELOG.md +0 -0
  29. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/CODE_OF_CONDUCT.md +0 -0
  30. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/CONTRIBUTING.md +0 -0
  31. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/LICENSE +0 -0
  32. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/Makefile +0 -0
  33. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/__init__.py +0 -0
  34. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/pyproject.toml +0 -0
  35. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/run.py +0 -0
  36. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/setup.cfg +0 -0
  37. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tests/README.md +0 -0
  38. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tests/__init__.py +0 -0
  39. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tests/example_output/logs/dedicated_log_triton_trace_findhao_.ndjson +0 -0
  40. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tests/example_output/parsed_output/dedicated_log_triton_trace_findhao__mapped.ndjson.gz +0 -0
  41. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tests/example_output/parsed_output/f0_fc0_a0_cai-.ndjson.gz +0 -0
  42. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tests/example_output/parsed_output/log_file_list.json +0 -0
  43. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tests/example_output/parsed_output_complex/dedicated_log_triton_trace_findhao__mapped.ndjson.gz +0 -0
  44. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tests/example_output/parsed_output_complex/log_file_list.json +0 -0
  45. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tests/test_add.py +0 -0
  46. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/__init__.py +0 -0
  47. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/__main__.py +0 -0
  48. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/common.py +0 -0
  49. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/context_manager.py +0 -0
  50. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/event_diff.py +0 -0
  51. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/extract_source_mappings.py +0 -0
  52. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/mapper.py +0 -0
  53. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/__init__.py +0 -0
  54. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/cli.py +0 -0
  55. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/function_extractor.py +0 -0
  56. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/placeholder_replacer.py +0 -0
  57. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/templates/__init__.py +0 -0
  58. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/templates/example.py +0 -0
  59. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/templates/loader.py +0 -0
  60. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/types.py +0 -0
  61. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/reproducer/utils.py +0 -0
  62. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/shared_vars.py +0 -0
  63. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/source_type.py +0 -0
  64. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/sourcemap_utils.py +0 -0
  65. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/structured_logging.py +0 -0
  66. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/tools/__init__.py +0 -0
  67. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/tools/decompress_bin_ndjson.py +0 -0
  68. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/tools/disasm.py +0 -0
  69. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/tools/format_fix.py +0 -0
  70. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/tools/load_tensor.py +0 -0
  71. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/tools/prettify_ndjson.py +0 -0
  72. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/tools/readme.md +0 -0
  73. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/tp_logger.py +0 -0
  74. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse/utils.py +0 -0
  75. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse.egg-info/dependency_links.txt +0 -0
  76. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse.egg-info/entry_points.txt +0 -0
  77. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse.egg-info/requires.txt +0 -0
  78. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/tritonparse.egg-info/top_level.txt +0 -0
  79. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/eslint.config.js +0 -0
  80. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/package-lock.json +0 -0
  81. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/package.json +0 -0
  82. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/public/dedicated_log_triton_trace_findhao__mapped.ndjson.gz +0 -0
  83. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/public/f0_fc0_a0_cai-.ndjson +0 -0
  84. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/public/favicon.ico +0 -0
  85. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/public/logo.svg +0 -0
  86. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/scripts/inline-html.js +0 -0
  87. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/scripts/update_deps.sh +0 -0
  88. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/App.css +0 -0
  89. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/assets/react.svg +0 -0
  90. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/ArgumentViewer.tsx +0 -0
  91. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/Callstack.tsx +0 -0
  92. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/CodeComparisonView.tsx +0 -0
  93. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/CodeViewer.tsx +0 -0
  94. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/CompilationInfo.tsx +0 -0
  95. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/CopyCodeButton.tsx +0 -0
  96. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/DataSourceSelector.tsx +0 -0
  97. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/DiffComparisonView.tsx +0 -0
  98. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/DiffViewer.tsx +0 -0
  99. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/ExternalLink.tsx +0 -0
  100. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/SingleCodeViewer.tsx +0 -0
  101. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/StackDiffViewer.tsx +0 -0
  102. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/ToggleSwitch.tsx +0 -0
  103. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/TritonIRs.tsx +0 -0
  104. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/components/WelcomeScreen.tsx +0 -0
  105. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/context/FileDiffSession.tsx +0 -0
  106. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/index.css +0 -0
  107. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/main.tsx +0 -0
  108. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/pages/CodeView.tsx +0 -0
  109. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/pages/FileDiffView.tsx +0 -0
  110. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/pages/KernelOverview.tsx +0 -0
  111. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/utils/fbDetection.ts +0 -0
  112. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/utils/safeImport.ts +0 -0
  113. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/utils/tensor.ts +0 -0
  114. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/src/vite-env.d.ts +0 -0
  115. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/tsconfig.app.json +0 -0
  116. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/tsconfig.json +0 -0
  117. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/tsconfig.node.json +0 -0
  118. {tritonparse-0.3.1.dev20251026071454 → tritonparse-0.3.1.dev20251028071524}/website/vite.config.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tritonparse
3
- Version: 0.3.1.dev20251026071454
3
+ Version: 0.3.1.dev20251028071524
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
@@ -134,7 +134,7 @@ from tritonparse.reproducer.orchestrator import reproduce
134
134
 
135
135
  result = reproduce(
136
136
  input_path="./parsed_output/trace.ndjson.gz",
137
- line_index=1, # Which launch event (1-based)
137
+ line_index=0, # 0-based index (first event is 0)
138
138
  out_dir="repro_output"
139
139
  )
140
140
  ```
@@ -116,7 +116,7 @@ from tritonparse.reproducer.orchestrator import reproduce
116
116
 
117
117
  result = reproduce(
118
118
  input_path="./parsed_output/trace.ndjson.gz",
119
- line_index=1, # Which launch event (1-based)
119
+ line_index=0, # 0-based index (first event is 0)
120
120
  out_dir="repro_output"
121
121
  )
122
122
  ```
@@ -187,6 +187,70 @@ class TestTritonparseCPU(unittest.TestCase):
187
187
 
188
188
  assert convert(nested_structure) == expected_nested
189
189
 
190
+ def test_loc_alias_parsing(self):
191
+ """Test parsing of location aliases in TTIR/TTGIR"""
192
+ from tritonparse.ir_parser import extract_loc_definitions
193
+
194
+ # Test case 1: Bare #loc reference (no number)
195
+ ir_with_bare_loc = """
196
+ module {
197
+ #loc = loc("/tmp/test.py":10:5)
198
+ #loc13 = loc("x_ptr"(#loc))
199
+ func @kernel(%arg0: !tt.ptr<f32> loc(#loc13)) {
200
+ return loc(#loc)
201
+ }
202
+ }
203
+ """
204
+ locs = extract_loc_definitions(ir_with_bare_loc)
205
+ # Main #loc should be stored with "" key
206
+ assert "" in locs, "Main #loc not found"
207
+ assert locs[""]["file"] == "/tmp/test.py"
208
+ assert locs[""]["line"] == 10
209
+ # Alias #loc13 should resolve to same location
210
+ assert "13" in locs, "#loc13 not found"
211
+ assert locs["13"]["file"] == "/tmp/test.py"
212
+ assert locs["13"]["line"] == 10
213
+ assert locs["13"]["alias_name"] == "x_ptr"
214
+ assert locs["13"]["alias_of"] == ""
215
+
216
+ # Test case 2: Named alias with numbered reference
217
+ ir_with_numbered_alias = """
218
+ #loc = loc("/tmp/test.py":5:0)
219
+ #loc2 = loc("/tmp/test.py":20:28)
220
+ #loc16 = loc("pid"(#loc2))
221
+ %0 = tt.get_program_id x : i32 loc(#loc16)
222
+ """
223
+ locs = extract_loc_definitions(ir_with_numbered_alias)
224
+ assert "2" in locs
225
+ assert locs["2"]["line"] == 20
226
+ assert "16" in locs
227
+ assert locs["16"]["file"] == "/tmp/test.py"
228
+ assert locs["16"]["line"] == 20
229
+ assert locs["16"]["alias_name"] == "pid"
230
+ assert locs["16"]["alias_of"] == "2"
231
+
232
+ # Test case 3: Simple alias (no name)
233
+ ir_with_simple_alias = """
234
+ #loc = loc("/tmp/test.py":1:1)
235
+ #loc1 = loc("/tmp/test.py":15:10)
236
+ #loc20 = loc(#loc1)
237
+ %1 = arith.constant 0 : i32 loc(#loc20)
238
+ """
239
+ locs = extract_loc_definitions(ir_with_simple_alias)
240
+ assert "1" in locs
241
+ assert "20" in locs
242
+ assert locs["20"]["file"] == "/tmp/test.py"
243
+ assert locs["20"]["line"] == 15
244
+ assert locs["20"]["alias_of"] == "1"
245
+ assert "alias_name" not in locs["20"]
246
+
247
+ # Test case 4: Definition line tracking
248
+ assert "def_line" in locs[""]
249
+ assert "def_line" in locs["1"]
250
+ assert "def_line" in locs["20"]
251
+
252
+ print("✓ All loc alias parsing tests passed")
253
+
190
254
 
191
255
  class TestTritonparseCUDA(unittest.TestCase):
192
256
  """CUDA tests (require GPU)"""
@@ -70,7 +70,7 @@ def main():
70
70
  elif args.func == "reproduce":
71
71
  reproduce(
72
72
  input_path=args.input,
73
- line_index=args.line,
73
+ line_index=args.line - 1, # Convert 1-based line number to 0-based index
74
74
  out_dir=args.out_dir,
75
75
  template=args.template,
76
76
  kernel_import=args.kernel_import,
@@ -42,7 +42,7 @@ def process_amd_gcn_bufferops(
42
42
  ) -> dict[str, int]:
43
43
  ir_content = load_ir_contents(key, file_content, file_path)
44
44
  # TODO: Add atomics
45
- io_keys = ["global_load_", "global_store_", "buffer_load_", "buffer_store_"]
45
+ io_keys = ["global_load", "global_store", "buffer_load", "buffer_store"]
46
46
  return process_amd_bufferop(ir_content, io_keys)
47
47
 
48
48
 
@@ -66,9 +66,12 @@ def _generate_ir_analysis(entry: str):
66
66
  gcn_bufferops_info = process_amd_gcn_bufferops(
67
67
  amdgcn_key, file_content, file_path
68
68
  )
69
+ io_counts = {}
69
70
  # NDJSON format requires a newline at the end of each line
70
71
  if ttgir_bufferops_info:
71
- ir_analysis["amd_ttgir_bufferops_count"] = ttgir_bufferops_info
72
+ io_counts["amd_ttgir_bufferops_count"] = ttgir_bufferops_info
72
73
  if gcn_bufferops_info:
73
- ir_analysis["amd_gcn_bufferops_count"] = gcn_bufferops_info
74
- return {"ir_analysis": ir_analysis}
74
+ io_counts["amd_gcn_bufferops_count"] = gcn_bufferops_info
75
+ if io_counts:
76
+ ir_analysis["io_counts"] = io_counts
77
+ return ir_analysis
@@ -10,7 +10,8 @@ logger = logging.getLogger("SourceMapping")
10
10
 
11
11
  # the definition of the #loc directive. they are in the bottom of the IR files
12
12
  # Example:#loc2 = loc("/tmp/torchinductor_yhao/yp/abcdef.py":20:28)
13
- LOC_PATTERN = re.compile(r'#loc(\d*) = loc\("([^"]+)":(\d+):(\d+)\)')
13
+ # Note: This should only match numbered locs like #loc1, #loc2, not bare #loc
14
+ LOC_PATTERN = re.compile(r'#loc(\d+) = loc\("([^"]+)":(\d+):(\d+)\)')
14
15
 
15
16
  # the reference to the #loc directive. they are in the end of lines of the IR files
16
17
  # Example: loc(#loc2)
@@ -33,6 +34,17 @@ AMDGCN_LOC_PATTERN = re.compile(
33
34
  )
34
35
 
35
36
 
37
+ # alias loc definitions in TTGIR/TTIR
38
+ # Example: #loc16 = loc("pid"(#loc2))
39
+ # Example: #loc13 = loc("x_ptr"(#loc)) - bare #loc without number
40
+ ALIAS_WITH_NAME_PATTERN = re.compile(
41
+ r'#loc(\d+)\s*=\s*loc\("([^"]+)"\s*\(\s*#loc(\d*)\s*\)\s*\)'
42
+ )
43
+
44
+ # Example: #loc20 = loc(#loc16)
45
+ ALIAS_SIMPLE_PATTERN = re.compile(r"#loc(\d+)\s*=\s*loc\(\s*#loc(\d*)\s*\)")
46
+
47
+
36
48
  def extract_loc_definitions(ir_content: str) -> Dict[str, Dict[str, Any]]:
37
49
  """
38
50
  Extracts location definitions from the given IR content.
@@ -50,9 +62,10 @@ def extract_loc_definitions(ir_content: str) -> Dict[str, Dict[str, Any]]:
50
62
  """
51
63
  locations = {}
52
64
  # The first #loc directive is a special case. It locates at the top of the IR files
65
+ # Store it with empty string "" as key to avoid conflict with #loc1
53
66
  main_match = re.search(r'#loc = loc\("([^"]+)":(\d+):(\d+)\)', ir_content)
54
67
  if main_match:
55
- locations["1"] = {
68
+ locations[""] = {
56
69
  "file": main_match.group(1),
57
70
  "line": int(main_match.group(2)),
58
71
  "column": int(main_match.group(3)),
@@ -61,6 +74,84 @@ def extract_loc_definitions(ir_content: str) -> Dict[str, Dict[str, Any]]:
61
74
  for loc_id, filename, line, col in LOC_PATTERN.findall(ir_content):
62
75
  key = loc_id
63
76
  locations[key] = {"file": filename, "line": int(line), "column": int(col)}
77
+
78
+ # Handle alias-style loc definitions that reference another #loc
79
+ # Build alias map first: alias_id -> target_id
80
+ alias_map: Dict[str, str] = {}
81
+ for m in ALIAS_WITH_NAME_PATTERN.finditer(ir_content):
82
+ alias_id, _name, target_id = m.groups()
83
+ # Empty target_id means bare #loc, map to "" (main loc key)
84
+ alias_map[alias_id] = target_id or ""
85
+ for m in ALIAS_SIMPLE_PATTERN.finditer(ir_content):
86
+ alias_id, target_id = m.groups()
87
+ # Empty target_id means bare #loc, map to "" (main loc key)
88
+ alias_map[alias_id] = target_id or ""
89
+
90
+ # Build definition line map and alias name map by scanning lines
91
+ def_line_map: Dict[str, int] = {}
92
+ alias_name_map: Dict[str, str] = {}
93
+ main_loc_line: int = 0
94
+ for i, line in enumerate(ir_content.split("\n"), start=1):
95
+ if m := ALIAS_WITH_NAME_PATTERN.search(line):
96
+ alias_id, name, target_id = m.groups()
97
+ def_line_map[alias_id] = i
98
+ alias_name_map[alias_id] = name
99
+ # ensure alias map is populated even if only found in line scan
100
+ # Empty target_id means bare #loc, map to "" (main loc key)
101
+ alias_map.setdefault(alias_id, target_id or "")
102
+ elif m := ALIAS_SIMPLE_PATTERN.search(line):
103
+ alias_id, target_id = m.groups()
104
+ def_line_map[alias_id] = i
105
+ # Empty target_id means bare #loc, map to "" (main loc key)
106
+ alias_map.setdefault(alias_id, target_id or "")
107
+ if m2 := LOC_PATTERN.search(line):
108
+ base_id, _fn, _ln, _col = m2.groups()
109
+ def_line_map[base_id] = i
110
+ if re.search(r'#loc\s*=\s*loc\("[^"]+":\d+:\d+\)', line):
111
+ # main #loc = loc("file":line:col) without id
112
+ main_loc_line = main_loc_line or i
113
+
114
+ # Resolve aliases to base locations (file/line/column)
115
+ resolving_stack = set()
116
+
117
+ def resolve_alias(current_id: str) -> Dict[str, Any]:
118
+ # Already a concrete location
119
+ if current_id in locations:
120
+ return locations[current_id]
121
+ # Detect cycles
122
+ if current_id in resolving_stack:
123
+ return {}
124
+ resolving_stack.add(current_id)
125
+ parent_id = alias_map.get(current_id)
126
+ result: Dict[str, Any] = {}
127
+ if parent_id is not None:
128
+ base = resolve_alias(parent_id)
129
+ if base:
130
+ # copy to avoid sharing the same dict by reference
131
+ result = {
132
+ "file": base.get("file"),
133
+ "line": base.get("line"),
134
+ "column": base.get("column"),
135
+ }
136
+ locations[current_id] = result
137
+ resolving_stack.remove(current_id)
138
+ return result
139
+
140
+ # Resolve aliases and attach alias metadata
141
+ for alias_id, target_id in alias_map.items():
142
+ if alias_id not in locations:
143
+ resolve_alias(alias_id)
144
+ if alias_id in locations:
145
+ locations[alias_id]["alias_of"] = target_id
146
+ if alias_id in alias_name_map:
147
+ locations[alias_id]["alias_name"] = alias_name_map[alias_id]
148
+
149
+ # Attach definition line metadata
150
+ for k, v in def_line_map.items():
151
+ if k in locations:
152
+ locations[k]["def_line"] = v
153
+ if main_loc_line and "" in locations:
154
+ locations[""]["def_line"] = main_loc_line
64
155
  return locations
65
156
 
66
157
 
@@ -40,7 +40,7 @@ def get_launch_and_compilation_events(
40
40
 
41
41
  Args:
42
42
  events: List of parsed event dictionaries.
43
- line_index: Index of the launch event to process.
43
+ line_index: 0-based index of the launch event to process.
44
44
 
45
45
  Returns:
46
46
  Tuple of (launch_event, compilation_event).
@@ -179,7 +179,7 @@ def build_context_bundle(
179
179
 
180
180
  Args:
181
181
  events: List of parsed event dictionaries.
182
- line_index: Index of the launch event to process.
182
+ line_index: 0-based index of the launch event to process.
183
183
 
184
184
  Returns:
185
185
  ContextBundle containing all information needed to reproduce the kernel launch.
@@ -29,7 +29,7 @@ def reproduce(
29
29
 
30
30
  Args:
31
31
  input_path: Path to the NDJSON trace file.
32
- line_index: Line index of the launch event to reproduce.
32
+ line_index: 0-based index of the launch event to reproduce in the events list.
33
33
  out_dir: Output directory for reproducer files.
34
34
  template: Template name to use for the reproducer.
35
35
  replacer: Optional custom PlaceholderReplacer instance. If None, uses DefaultPlaceholderReplacer.
@@ -71,12 +71,38 @@ def generate_source_mappings(
71
71
  }
72
72
  elif loc_id in loc_defs:
73
73
  info = loc_defs[loc_id]
74
- mappings[str(ln)] = {
74
+ entry = {
75
75
  "file": info["file"],
76
76
  "line": info["line"],
77
77
  "column": info["column"],
78
78
  f"{ir_type}_line": ln,
79
79
  }
80
+ # Propagate alias metadata if present
81
+ if "alias_name" in info:
82
+ entry["alias_name"] = info["alias_name"]
83
+ if "alias_of" in info:
84
+ entry["loc_id"] = loc_id
85
+ mappings[str(ln)] = entry
86
+
87
+ # Add separate entries for loc definition lines
88
+ for loc_id, info in loc_defs.items():
89
+ if "def_line" not in info:
90
+ continue
91
+ def_ln = info["def_line"]
92
+ # Only create mapping if this line doesn't already have one
93
+ if str(def_ln) not in mappings:
94
+ entry = {
95
+ "file": info["file"],
96
+ "line": info["line"],
97
+ "column": info["column"],
98
+ f"{ir_type}_line": def_ln,
99
+ "kind": "loc_def",
100
+ }
101
+ if "alias_name" in info:
102
+ entry["alias_name"] = info["alias_name"]
103
+ if "alias_of" in info:
104
+ entry["loc_id"] = loc_id
105
+ mappings[str(def_ln)] = entry
80
106
 
81
107
  return mappings
82
108
 
@@ -301,8 +327,13 @@ def parse_single_file(
301
327
  )
302
328
 
303
329
  if compilation_event:
304
- ir_analysis_event = _generate_ir_analysis(compilation_event)
305
- if ir_analysis_event:
330
+ ir_analysis = _generate_ir_analysis(compilation_event)
331
+ if ir_analysis:
332
+ ir_analysis_event = {
333
+ "event_type": "ir_analysis",
334
+ "hash": _kernel_hash,
335
+ "ir_analysis": ir_analysis,
336
+ }
306
337
  all_output_lines[output_file].append(
307
338
  json.dumps(ir_analysis_event, separators=(",", ":")) + "\n"
308
339
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tritonparse
3
- Version: 0.3.1.dev20251026071454
3
+ Version: 0.3.1.dev20251028071524
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
@@ -134,7 +134,7 @@ from tritonparse.reproducer.orchestrator import reproduce
134
134
 
135
135
  result = reproduce(
136
136
  input_path="./parsed_output/trace.ndjson.gz",
137
- line_index=1, # Which launch event (1-based)
137
+ line_index=0, # 0-based index (first event is 0)
138
138
  out_dir="repro_output"
139
139
  )
140
140
  ```
@@ -107,6 +107,7 @@ website/src/components/WelcomeScreen.tsx
107
107
  website/src/context/FileDiffSession.tsx
108
108
  website/src/pages/CodeView.tsx
109
109
  website/src/pages/FileDiffView.tsx
110
+ website/src/pages/IRAnalysis.tsx
110
111
  website/src/pages/KernelOverview.tsx
111
112
  website/src/utils/dataLoader.ts
112
113
  website/src/utils/fbDetection.ts
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/logo.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>TritonParse</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+
13
+ <!-- Static footer for SEO and tools that need to detect content in HTML source -->
14
+ <footer hidden>
15
+ <div>
16
+ Copyright © 2025 Meta Platforms, Inc
17
+ <span>|</span>
18
+ <a href="https://opensource.fb.com/legal/terms">Terms of Use</a>
19
+ <span>|</span>
20
+ <a href="https://opensource.fb.com/legal/privacy">Privacy Policy</a>
21
+ </div>
22
+ </footer>
23
+ </body>
24
+ </html>
@@ -12,6 +12,7 @@ import CodeView from "./pages/CodeView";
12
12
  import FileDiffView from "./pages/FileDiffView";
13
13
  import SingleCodeViewer from "./components/SingleCodeViewer";
14
14
  import KernelOverview from "./pages/KernelOverview";
15
+ import IRAnalysis from "./pages/IRAnalysis";
15
16
  import DataSourceSelector from "./components/DataSourceSelector";
16
17
  import WelcomeScreen from "./components/WelcomeScreen";
17
18
  import ExternalLink from "./components/ExternalLink";
@@ -409,7 +410,7 @@ function App() {
409
410
  </div>
410
411
  );
411
412
  } else {
412
- // Show either overview, IR code, or file diff based on active tab
413
+ // Show either overview, IR code, IR analysis, or file diff based on active tab
413
414
  if (activeTab === "overview") {
414
415
  return (
415
416
  <KernelOverview
@@ -420,6 +421,14 @@ function App() {
420
421
  />
421
422
  );
422
423
  }
424
+ if (activeTab === "ir_analysis") {
425
+ return (
426
+ <IRAnalysis
427
+ kernels={kernels}
428
+ selectedKernel={selectedKernel}
429
+ />
430
+ );
431
+ }
423
432
  if (activeTab === "comparison") {
424
433
  return (
425
434
  <CodeView
@@ -550,7 +559,6 @@ function App() {
550
559
  </button>
551
560
  </>
552
561
  )}
553
-
554
562
  <button
555
563
  className={`px-3 py-2 text-sm font-medium rounded-md ${activeTab === "file_diff" ? "bg-blue-700 text-white shadow-md" : "bg-blue-100 text-blue-700 hover:bg-blue-200"
556
564
  }`}
@@ -561,6 +569,24 @@ function App() {
561
569
  >
562
570
  File Diff
563
571
  </button>
572
+ {dataLoaded && kernels.length > 0 && (
573
+ <button
574
+ className={`px-3 py-2 text-sm font-medium rounded-md ${activeTab === "ir_analysis" ? "bg-blue-700 text-white shadow-md" : "bg-blue-100 text-blue-700 hover:bg-blue-200"
575
+ }`}
576
+ onClick={() => {
577
+ if (sess.preview?.active) sess.clearPreview();
578
+ setActiveTab("ir_analysis");
579
+
580
+ if (loadedUrl) {
581
+ const newUrl = new URL(window.location.href);
582
+ newUrl.searchParams.set("view", "ir_analysis");
583
+ window.history.replaceState({}, "", newUrl.toString());
584
+ }
585
+ }}
586
+ >
587
+ IR Analysis (Beta)
588
+ </button>
589
+ )}
564
590
  </div>
565
591
  </div>
566
592
  </div>
@@ -0,0 +1,98 @@
1
+ import React from "react";
2
+ import { ProcessedKernel } from "../utils/dataLoader";
3
+
4
+ interface IRAnalysisProps {
5
+ kernels: ProcessedKernel[];
6
+ selectedKernel: number;
7
+ }
8
+
9
+ const IRAnalysis: React.FC<IRAnalysisProps> = ({ kernels, selectedKernel }) => {
10
+ if (kernels.length === 0) {
11
+ return (
12
+ <div className="flex items-center justify-center h-screen">
13
+ <div className="text-gray-800">No kernel data available</div>
14
+ </div>
15
+ );
16
+ }
17
+
18
+ const kernel = kernels[selectedKernel];
19
+ if (kernel.ir_analysis === null) {
20
+ return (
21
+ <div className="flex items-center justify-center h-screen">
22
+ <div className="text-gray-800">No IR Analysis available</div>
23
+ </div>
24
+ );
25
+ }
26
+
27
+ const io_counts = kernel.ir_analysis?.io_counts;
28
+ const ttgir_info = io_counts?.["amd_ttgir_bufferops_count"];
29
+ const amdgcn_info = io_counts?.["amd_gcn_bufferops_count"];
30
+ const getCount = (info: Record<string, number> | undefined, key: string): string => { return info?.[key]?.toString() ?? "N/A"; };
31
+
32
+ return (
33
+ <div className="p-6">
34
+ <h1 className="text-2xl font-bold text-gray-800 mb-6">Triton Kernel IR Analysis</h1>
35
+
36
+ <div className="bg-white rounded-lg p-4 mb-4 shadow-sm border border-gray-200">
37
+ <h2 className="text-xl font-semibold mb-4 text-gray-800">
38
+ Kernel: {kernel.name}
39
+ </h2>
40
+
41
+ {io_counts && (ttgir_info || amdgcn_info) && (
42
+ <>
43
+ <h3 className="text-lg font-medium mb-3 text-gray-800">
44
+ AMD BufferOps Information
45
+ </h3>
46
+
47
+ <div className="bg-gray-50 p-4 rounded-md border border-gray-200">
48
+ <div className="grid grid-cols-[repeat(auto-fit,_minmax(180px,_1fr))] gap-3">
49
+ {ttgir_info && (
50
+ <>
51
+ <div className="flex flex-col">
52
+ <span className="text-sm font-medium text-gray-500">Tiled Buffer Load Count</span>
53
+ <span className="font-mono text-sm break-words">{getCount(ttgir_info, "tt.load_count")}</span>
54
+ </div>
55
+ <div className="flex flex-col">
56
+ <span className="text-sm font-medium text-gray-500">Tiled Buffer Store Count</span>
57
+ <span className="font-mono text-sm break-words">{getCount(ttgir_info, "tt.store_count")}</span>
58
+ </div>
59
+ <div className="flex flex-col">
60
+ <span className="text-sm font-medium text-gray-500">Tiled Global Load Count</span>
61
+ <span className="font-mono text-sm break-words">{getCount(ttgir_info, "amdgpu.buffer_load_count")}</span>
62
+ </div>
63
+ <div className="flex flex-col">
64
+ <span className="text-sm font-medium text-gray-500">Tiled Global Store Count</span>
65
+ <span className="font-mono text-sm break-words">{getCount(ttgir_info, "amdgpu.buffer_store_count")}</span>
66
+ </div>
67
+ </>
68
+ )}
69
+ {amdgcn_info && (
70
+ <>
71
+ <div className="flex flex-col">
72
+ <span className="text-sm font-medium text-gray-500">AMDGCN Global Load Instruction Count</span>
73
+ <span className="font-mono text-sm break-words">{getCount(amdgcn_info, "global_load_count")}</span>
74
+ </div>
75
+ <div className="flex flex-col">
76
+ <span className="text-sm font-medium text-gray-500">AMDGCN Global Store Instruction Count</span>
77
+ <span className="font-mono text-sm break-words">{getCount(amdgcn_info, "global_store_count")}</span>
78
+ </div>
79
+ <div className="flex flex-col">
80
+ <span className="text-sm font-medium text-gray-500">AMDGCN Buffer Load Instruction Count</span>
81
+ <span className="font-mono text-sm break-words">{getCount(amdgcn_info, "buffer_load_count")}</span>
82
+ </div>
83
+ <div className="flex flex-col">
84
+ <span className="text-sm font-medium text-gray-500">AMDGCN Buffer Store Instruction Count</span>
85
+ <span className="font-mono text-sm break-words">{getCount(amdgcn_info, "buffer_store_count")}</span>
86
+ </div>
87
+ </>
88
+ )}
89
+ </div>
90
+ </div>
91
+ </>
92
+ )}
93
+ </div>
94
+ </div>
95
+ );
96
+ };
97
+
98
+ export default IRAnalysis;
@@ -167,6 +167,11 @@ export interface CompilationMetadata {
167
167
  [key: string]: any; // Allow additional unknown fields
168
168
  }
169
169
 
170
+ export interface IRAnalysisData {
171
+ // Mapping from IR stage -> <IO type -> count>
172
+ io_counts?: Record<string, Record<string, number>>;
173
+ }
174
+
170
175
  /**
171
176
  * Extracted argument information
172
177
  */
@@ -224,6 +229,7 @@ export interface LogEntry {
224
229
  launch_index_map?: LaunchRange[];
225
230
  diffs?: LaunchDiffData;
226
231
  sames?: LaunchSamesData;
232
+ ir_analysis?: IRAnalysisData; // Stored IR Analysis information.
227
233
  }
228
234
 
229
235
  /**
@@ -239,6 +245,7 @@ export interface ProcessedKernel {
239
245
  pythonSourceInfo?: PythonSourceCodeInfo; // Python source code information
240
246
  metadata?: KernelMetadata; // Compilation metadata
241
247
  launchDiff?: LogEntry; // Aggregated launch event differences
248
+ ir_analysis?: IRAnalysisData; // Stored IR Analysis information.
242
249
  }
243
250
 
244
251
  /**
@@ -503,6 +510,15 @@ export function processKernelData(logEntries: LogEntry[]): ProcessedKernel[] {
503
510
  console.warn(`Could not find matching kernel for launch_diff hash: ${hash}`);
504
511
  }
505
512
  }
513
+ if (entry.event_type === "ir_analysis") {
514
+ const hash = entry.hash;
515
+ if (hash && kernelsByHash.has(hash)) {
516
+ const kernel = kernelsByHash.get(hash)!;
517
+ kernel.ir_analysis = entry.ir_analysis!; // Attach the ir_analysis
518
+ } else {
519
+ console.warn(`Could not find matching kernel for ir_analysis hash: ${hash}`);
520
+ }
521
+ }
506
522
  }
507
523
 
508
524
  const finalKernels = Array.from(kernelsByHash.values());
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/logo.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>TritonParse</title>
8
- </head>
9
- <body>
10
- <div id="root"></div>
11
- <script type="module" src="/src/main.tsx"></script>
12
- </body>
13
- </html>
14
-