[Debug][TIR] Drive Pass Visualizer with PassInstrument - #2866
Conversation
|
👋 Hi! Thank you for contributing to the TileLang project. Please remember to run We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe pass visualizer now observes the canonical CUDA lowering prologue through TVM ChangesPass visualizer instrumentation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant build_pass_data
participant CUDAPassPipelineBodyPrologue
participant StructureTreePassInstrument
participant HTMLReport
CLI->>build_pass_data: request CUDA pass visualization
build_pass_data->>CUDAPassPipelineBodyPrologue: run configured lowering prologue
CUDAPassPipelineBodyPrologue->>StructureTreePassInstrument: emit pass callbacks
StructureTreePassInstrument->>build_pass_data: return ordered pass records and snapshots
build_pass_data->>HTMLReport: render pass names and structure diffs
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR refactors the TIR Pass Visualizer to observe the real CUDA lowering prologue via a TVM PassInstrument, eliminating the need to maintain a duplicate prologue pass list and keeping pass ordering/conditionality aligned with target and pass-config behavior.
Changes:
- Introduces
StructureTreePassInstrumentto capture before/after structure-tree snapshots for top-level passes (folding nested implementation passes). - Updates the visualizer CLI to run the canonical
CUDAPassPipelineBodyPrologueunder instrumentedPassContext, including normalized pass configs and semantic checks. - Stabilizes Python-defined pass naming via explicit
prim_func_pass(..., name=...), and updates docs/exports/tests accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tilelang/transform/decouple_type_cast.py | Assigns a stable PassInfo name for the PrimFunc pass to improve instrumented reporting. |
| tilelang/transform/add_bufstore_wrapper.py | Assigns a stable PassInfo name for the PrimFunc pass to improve instrumented reporting. |
| tilelang/analysis/layout_visual.py | Assigns a stable PassInfo name for the analysis PrimFunc pass. |
| tilelang/tools/pass_visualizer/core.py | Adds structure-tree capture helper + StructureTreePassInstrument, removes duplicate prologue pass list builder. |
| tilelang/tools/pass_visualizer/viewer.py | Switches from a locally-built pass list to instrumenting the canonical CUDA prologue and emitting diffs from instrument snapshots. |
| tilelang/tools/pass_visualizer/init.py | Updates public exports to reflect the new instrument-based API and removes build_pass_stages. |
| tilelang/tools/pass_visualizer/README.md | Updates documentation to describe instrumented real-prologue observation and nested-pass folding. |
| testing/python/debug/test_pass_visualizer.py | Reworks tests to validate instrument behavior, config precedence, injected passes, and end-to-end HTML/text emission. |
| docs/tutorials/debug_tools_for_tilelang.md | Updates tutorial text to match the new PassInstrument-based behavior. |
Suppressed comments (1)
tilelang/tools/pass_visualizer/core.py:453
PassStructureRecord.after_iris currently set tostr(mod), which can be very large and can cause thechangedflag to disagree with the structure-tree diff shown in the UI. Prefer reusing the captured structure lines forafter_irsochangedreflects the structure-tree snapshot and avoids holding full TVMScript strings.
self.records.append(
PassStructureRecord(
name=name,
sequence=frame.sequence,
before_ir=frame.before_ir,
after_ir=str(mod),
before_lines=frame.before_lines,
after_lines=capture_structure(mod),
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SiriusNEO
left a comment
There was a problem hiding this comment.
Generally I think it's good to replace the original impl with the PassInstrument approach. Left some comments
Summary
PassInstrumentattached to the canonical prologue.Changes
PassInfonames for Python-defined passes visible in the instrumented report.build_pass_stageshelper and update the public exports, documentation, and regression coverage.Validation
./format.shpython -m pytest testing/python/debug/test_pass_visualizer.py testing/python/transform/test_tilelang_transform_decouple_type_cast.py -x -q(26 passed, 1 skipped)python -m pytest testing/python/debug/test_lower_trace.py testing/python/debug/test_pass_diff.py -x -q(76 passed)Notes
CUDAPassPipelineBodyPrologue; full-pipeline tracing remains available throughTL_LOWER_TRACE.Summary
StructureTreePassInstrumenton the canonicalCUDAPassPipelineBodyPrologue.PrimFuncpass configurations from the analyzed kernel.build_pass_stages.capture_structure,PassStructureRecord, andStructureTreePassInstrumentexports.Validation