Context
Debugging compiler regressions requires tracking how specific operations evolve across hundreds of passes (--mlir-print-ir-after-all). Text-based diffs are noisy because unrelated line number changes (loc(...)) obscure the actual logic changes. We need a structural tracer that uses MLIR Python bindings to "sanitize" ops before diffing, paired with a Recursive Language Model (RLM) to explain the transformations.
Objective
- Integrate the
MLIRProvenanceTracer to structurally track operations across history.
- Deploy an RLM Agent to read the generated trace and explain why a transformation occurred.
Scope of Work
- Tracer Implementation (
src/tools/trace_provenance.py):
- Port Existing Logic: Incorporate the
MLIRProvenanceTracer class (provided).
- Robust Imports: Handle
iree.compiler.ir vs mlir.ir fallback.
- Sanitization: Ensure
_sanitize_operation_in_place correctly strips ir.Location and truncates large DenseElementsAttr to prevent context window flooding.
- RLM Integration (
src/tools/rlm_analyst.py):
- Interface: Create a wrapper around the
alexzhang13/rlm library.
- Task: Feed the JSON output from the tracer to the RLM.
- Prompt Strategy: "You are a Compiler Engineer. Here is the lifecycle of operation
quant_epilogue. Identify which pass introduced the arith.sitofp cast and determine if it was fused correctly."
Acceptance Criteria
- Test 1 (Structural Search):
- Input: A trace request for
matmul in input.mlir:50.
- Condition: The operation moves to line 120 in a later pass.
- Success: The tracer finds it via semantic matching, not just line numbers.
- Test 2 (Noise Reduction):
- Input: Two passes where only the
loc("file":line) attributes change.
- Success: The tracer reports
status: "unchanged" (Smart Collapse).
- Test 3 (RLM Explanation):
- Input: A trace showing an op changing from
linalg.generic to flow.dispatch.
- Success: The RLM outputs a summary citing the specific pass (e.g.,
iree-flow-dispatch-workgroups) that caused the change.
Context
Debugging compiler regressions requires tracking how specific operations evolve across hundreds of passes (
--mlir-print-ir-after-all). Text-based diffs are noisy because unrelated line number changes (loc(...)) obscure the actual logic changes. We need a structural tracer that uses MLIR Python bindings to "sanitize" ops before diffing, paired with a Recursive Language Model (RLM) to explain the transformations.Objective
MLIRProvenanceTracerto structurally track operations across history.Scope of Work
src/tools/trace_provenance.py):MLIRProvenanceTracerclass (provided).iree.compiler.irvsmlir.irfallback._sanitize_operation_in_placecorrectly stripsir.Locationand truncates largeDenseElementsAttrto prevent context window flooding.src/tools/rlm_analyst.py):alexzhang13/rlmlibrary.quant_epilogue. Identify which pass introduced thearith.sitofpcast and determine if it was fused correctly."Acceptance Criteria
matmulininput.mlir:50.loc("file":line)attributes change.status: "unchanged"(Smart Collapse).linalg.generictoflow.dispatch.iree-flow-dispatch-workgroups) that caused the change.