Skip to content
Yueming Hao edited this page Jun 18, 2025 · 4 revisions

1. Generate Triton Trace Files

First, integrate TritonParse with your Triton/PyTorch code to generate trace files:

# === TritonParse init ===
import tritonparse.structured_logging
# Initialize structured logging to capture Triton compilation events
# This will generate NDJSON trace logs in ./logs/
log_path = "./logs/"
tritonparse.structured_logging.init(log_path)
# === TritonParse init end ===

# The below is your original Triton/PyTorch 2 code
...

# === TritonParse parse ===
import tritonparse.utils
tritonparse.utils.unified_parse(log_path)
# === TritonParse parse end ===

The final .gz files should be in /tmp/a_temp_hash/ printed in the terminal. See a full example in tests/test_add.py.

Exampled output:

% TORCHINDUCTOR_FX_GRAPH_CACHE=0 python test_add.py
Triton kernel executed successfully
Torch compiled function executed successfully
WARNING:SourceMapping:No frame_id or frame_compile_id found in the payload.
WARNING:SourceMapping:No frame_id or frame_compile_id found in the payload.
tritonparse log file list: /tmp/tmpl1tp9fto/log_file_list.json

In our test example, it has two triton kernels: one is a pure triton kernel and the other is a PT2 compiled triton kernel. TORCHINDUCTOR_FX_GRAPH_CACHE=0 is used to disable FX graph cache to let PT2 compiler compile the kernel every time. Otherwise, the final parsed log files will only contain the first triton kernel. The final parsed gz files are stored in the /tmp/tmpl1tp9fto/ directory. The ./logs directory contains the raw NDJSON logs without source code mapping.

2. Analyze with Web Interface

Option A: Online Interface (Recommended)

Visit https://pytorch-labs.github.io/tritonparse/ to use the tool directly in your browser:

  1. Open your local trace file (NDJSON or .gz format) directly in the browser
  2. Explore the visualization using the Overview and Code Comparison tabs

Supported File Formats:

  • .ndjson - Newline Delimited JSON trace files
  • .gz - Gzip compressed trace files

By default, ndjson format doesn't have source code mappings.

Interface Overview

Once you load a trace file, you'll see the main interface with several key components:

Kernel Overview & Details:

Kernel Overview

The main interface showing the kernel list, compilation metadata, call stack, and navigation links to different IR representations.

Code Comparison View:

Code Comparison

Side-by-side comparison of different IR stages (e.g., TTGIR and PTX) with synchronized line highlighting and interactive navigation.

Option B: Local Development (For Contributors)

For contributors working on the website:

cd website
npm install
npm run dev

Access the application at http://localhost:5173

Available Scripts:

  • npm run build - Standard build
  • npm run build:single - Standalone HTML file
  • npm run preview - Preview production build