Skip to content

[Tools][Debug] MLIR Provenance Tracer & RLM analysis #10

@copparihollmann

Description

@copparihollmann

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

  1. Integrate the MLIRProvenanceTracer to structurally track operations across history.
  2. Deploy an RLM Agent to read the generated trace and explain why a transformation occurred.

Scope of Work

  1. 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.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions