Summary
Add a developer tool that turns PyPTO per-pass IR snapshots into an interactive lowering trace, similar to TileLang IR Lower Trace. The tool should render terminal output and/or a self-contained HTML report with pass navigation, change statistics, and side-by-side before/after IR diffs.
The initial implementation should reuse the snapshots already produced by dump_passes=True under <output_dir>/passes_dump/ rather than introduce a second pass-instrumentation path.
Motivation / Use Case
PyPTO already writes 00_frontend.py followed by <index>_after_<PassName>.py snapshots, and .claude/skills/compare-codegen/scripts/diff_pto.py --include-passes can print unified diffs. However, inspecting a long lowering pipeline remains cumbersome: developers must open many files manually, unchanged passes add noise, and it is difficult to identify the first pass that introduced an unexpected IR change.
The viewer would make it easier to:
- Find the first pass that changes a suspicious expression, type, layout, memory assignment, or control-flow structure.
- Understand and review the effect of an individual pass.
- Navigate pipelines with dozens of passes while filtering changed and no-op stages.
- Share a portable report as a CI artifact or in an issue without requiring a running server.
Proposed API / Behavior
Start with a post-processing CLI over an existing dump directory:
# Generate a self-contained interactive report
pypto-ir-trace build_output/example/passes_dump \
--mode html --output ir_trace.html
# Print compact colored diffs in the terminal
pypto-ir-trace build_output/example/passes_dump --mode terminal
A small Python API may expose the same functionality:
from pypto.tools import ir_trace
ir_trace.render(
"build_output/example/passes_dump",
mode="html",
output="ir_trace.html",
)
Expected behavior for the MVP:
- Discover and order the existing pass snapshots by their numeric prefix.
- Treat
00_frontend.py as the input of the first pass and the previous pass snapshot as the input of each subsequent pass.
- Record the pass name, whether it changed the IR, and insertion/deletion counts.
- Generate a self-contained HTML file with:
- a pass sidebar and changed/no-op status indicators;
- changed/no-op filters and summary counts;
- side-by-side before/after diffs with syntax-aware line highlighting;
- collapsed unchanged context with an expand control;
- copy-before and copy-after actions;
- keyboard navigation and light/dark themes.
- Support a terminal mode for quick inspection.
- Surface matching per-pass warning
.log files when present.
- Handle missing, malformed, or non-contiguous snapshots with clear diagnostics.
- Add focused tests for snapshot discovery/order, change classification, diff statistics, malformed input, and deterministic/self-contained HTML generation.
A follow-up can integrate report generation with the existing compare-codegen workflow so main/current-branch pass dumps can be explored using the same UI.
Alternatives Considered
- Continue using raw
passes_dump/ files and unified terminal diffs. This works for small cases but becomes difficult to navigate and share for long pipelines.
- Build a hosted web application. A self-contained static HTML report is preferable initially because it has no service dependency, opens locally, and can be archived by CI.
Additional Context
Design reference: TileLang IR Lower Trace. Its useful interaction model includes phase/pass navigation, changed/no-op classification, before/after comparison, context expansion, copy controls, keyboard navigation, and a self-contained HTML report.
The reference compares textual IR, so the viewer should clearly describe diffs as textual evidence rather than semantic equivalence.
Summary
Add a developer tool that turns PyPTO per-pass IR snapshots into an interactive lowering trace, similar to TileLang IR Lower Trace. The tool should render terminal output and/or a self-contained HTML report with pass navigation, change statistics, and side-by-side before/after IR diffs.
The initial implementation should reuse the snapshots already produced by
dump_passes=Trueunder<output_dir>/passes_dump/rather than introduce a second pass-instrumentation path.Motivation / Use Case
PyPTO already writes
00_frontend.pyfollowed by<index>_after_<PassName>.pysnapshots, and.claude/skills/compare-codegen/scripts/diff_pto.py --include-passescan print unified diffs. However, inspecting a long lowering pipeline remains cumbersome: developers must open many files manually, unchanged passes add noise, and it is difficult to identify the first pass that introduced an unexpected IR change.The viewer would make it easier to:
Proposed API / Behavior
Start with a post-processing CLI over an existing dump directory:
A small Python API may expose the same functionality:
Expected behavior for the MVP:
00_frontend.pyas the input of the first pass and the previous pass snapshot as the input of each subsequent pass..logfiles when present.A follow-up can integrate report generation with the existing
compare-codegenworkflow so main/current-branch pass dumps can be explored using the same UI.Alternatives Considered
passes_dump/files and unified terminal diffs. This works for small cases but becomes difficult to navigate and share for long pipelines.Additional Context
Design reference: TileLang IR Lower Trace. Its useful interaction model includes phase/pass navigation, changed/no-op classification, before/after comparison, context expansion, copy controls, keyboard navigation, and a self-contained HTML report.
The reference compares textual IR, so the viewer should clearly describe diffs as textual evidence rather than semantic equivalence.