[Feature] Add Callsite Location Support in TTIR/TTGIR #190
+120
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds support for parsing MLIR callsite locations in Triton IR (TTIR/TTGIR), enabling tritonparse to capture and preserve call stack information for inlined functions.
Problem
Previously, tritonparse could not parse callsite location definitions like:
This caused incomplete source code mappings, losing critical information about:
Solution
Implemented a hybrid approach that:
Key Design Decisions
Implementation Details
1. Added Callsite Pattern (
ir_parser.py)2. Enhanced
extract_loc_definitions()(ir_parser.py)is_callsite,callsite_callee,callsite_caller3. Updated
generate_source_mappings()(trace_processor.py)loc_defsto finalmappingsData Structure Example
For a nested callsite like:
The resulting mapping for line 131 (where
tt.loadis):{ "file": "file.py", "line": 421, // From callee (loc57) - actual code executing "column": 16, "ttir_line": 131, "is_callsite": true, "callsite_callee": "57", // Reference to called code "callsite_caller": "190" // Reference to caller (can traverse chain) }Call chain represented:
_ragged_hstu_attn_fwd(1091:8) →_ragged_hstu_attn_fwd_compute(853:16) →_ragged_hstu_attn_fwd_one_block(421:16) ← executing hereTesting
Added comprehensive unit tests in
tests/test_tritonparse.py:TestTritonparseCPU::test_callsite_parsingAll tests pass ✅
Impact
Benefits
No Breaking Changes
Files Changed
tritonparse/ir_parser.py- Added callsite parsing logictritonparse/trace_processor.py- Propagate callsite metadatatests/test_tritonparse.py- Added unit testsCALLSITE_IMPLEMENTATION.md- Detailed implementation documentationFuture Work
Potential enhancements (not in this PR):