Skip to content

Add support for choosing decomposition rules in decompose-lowering#2973

Merged
kipawaa merged 16 commits into
mainfrom
dl-driver-restructure
Jul 7, 2026
Merged

Add support for choosing decomposition rules in decompose-lowering#2973
kipawaa merged 16 commits into
mainfrom
dl-driver-restructure

Conversation

@kipawaa

@kipawaa kipawaa commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Context:
decompose-lowering always applies all (applicable) decomposition rules in the IR, and removes all decomposition rules on cleanup.

Description of the Change:
Introduces a target-rules option to apply only a subset of the rules available in the IR. Rules are now applied by aligning the target_op's operands with the decomposition functions body and cloning the function body inline, to avoid the inconsistencies/heuristics of the built-in inliner. Rules are no longer removed after the decompose-lowering pass to allow use throughout the pipeline in graph-decomposition passes. Decomposition functions will be removed by the symbol-dce pass at the end of the default pipeline.

Benefits:
Provides a more versatile decompose-lowering pass, and will support a more efficient graph-decomposition pass.

Possible Drawbacks:

Related GitHub Issues:

[sc-122013]

@kipawaa kipawaa marked this pull request as ready for review June 23, 2026 19:13
@kipawaa kipawaa marked this pull request as draft June 23, 2026 19:20
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.96%. Comparing base (ce5eefa) to head (d8a8b7c).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2973      +/-   ##
==========================================
- Coverage   96.98%   96.96%   -0.03%     
==========================================
  Files         166      167       +1     
  Lines       19249    19349     +100     
  Branches     1791     1799       +8     
==========================================
+ Hits        18668    18761      +93     
- Misses        429      433       +4     
- Partials      152      155       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread mlir/lib/Quantum/Transforms/decompose_lowering.cpp
@kipawaa kipawaa marked this pull request as ready for review June 25, 2026 13:47
@Alex-Preciado Alex-Preciado requested a review from maliasadi June 30, 2026 19:13
Comment thread mlir/lib/Quantum/Transforms/decompose_lowering.cpp
Comment thread mlir/lib/Quantum/Transforms/graph_decomposition.cpp
Comment thread mlir/lib/Quantum/Transforms/decompose_lowering.cpp
Comment thread mlir/lib/Quantum/Transforms/decompose_lowering.cpp
Comment thread mlir/lib/Quantum/Transforms/DecomposeLoweringPatterns.cpp
Comment thread mlir/lib/Quantum/Transforms/DecomposeLoweringPatterns.cpp
Comment thread mlir/lib/Quantum/Transforms/DecomposeLoweringPatterns.cpp
Comment thread mlir/test/Quantum/DecomposeLoweringTest.mlir
Comment thread mlir/test/Quantum/DecomposeLoweringTest.mlir

@paul0403 paul0403 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 💯

@maliasadi maliasadi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor @kipawaa!

Comment thread doc/releases/changelog-dev.md
Comment thread mlir/lib/Quantum/Transforms/graph_decomposition.cpp
Comment thread mlir/test/Quantum/DecomposeLoweringTargetRulesTest.mlir
Comment thread mlir/lib/Quantum/Transforms/DecomposeLoweringPatterns.cpp Outdated
Comment thread mlir/lib/Quantum/Transforms/DecomposeLoweringPatterns.cpp Outdated
Comment thread mlir/lib/Quantum/Transforms/DecomposeLoweringPatterns.cpp
@dime10

dime10 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Maybe a general design question, but is there a use case to having a separate decompose-lowering pass that is distinct from a graph solver pass (assuming that is the current design)?

Naively I would have thought there is one "decompose" pass, with the target gate set, and the pass computes whatever is necessary and replaces your gates until all are in the target.
Of course this doesn't mean the graph and the rewrite can't be separate components within the pass.

Alternatively, if the pass separation is in fact useful, one could perhaps leverage an analysis result from the first pass in the second, but it depends on how they are intended to be used.
A target-rules pass option doesn't really make too much sense to me though, as that is a relatively static configuration.

@kipawaa

kipawaa commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

is there a use case to having a separate decompose-lowering pass that is distinct from a graph solver pass (assuming that is the current design)?

I think that these two should be combined in the near future, but until the graph is able to accommodate all decomposition requirements we'll need the separation. I've been working towards this goal of unifying the decomposition passes, and hopefully this can be complete in the next couple of months.

@dime10

dime10 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

is there a use case to having a separate decompose-lowering pass that is distinct from a graph solver pass (assuming that is the current design)?

I think that these two should be combined in the near future, but until the graph is able to accommodate all decomposition requirements we'll need the separation. I've been working towards this goal of unifying the decomposition passes, and hopefully this can be complete in the next couple of months.

What does the separation do for us while we don't have all requirements?

kipawaa and others added 4 commits July 6, 2026 15:21
Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
@kipawaa

kipawaa commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

is there a use case to having a separate decompose-lowering pass that is distinct from a graph solver pass (assuming that is the current design)?

I think that these two should be combined in the near future, but until the graph is able to accommodate all decomposition requirements we'll need the separation. I've been working towards this goal of unifying the decomposition passes, and hopefully this can be complete in the next couple of months.

What does the separation do for us while we don't have all requirements?

Chatted offline, seems likely I was mistaken and that we can move up the timeline on combining these passes. I'll evaluate and make necessary changes in a follow-up PR.

@maliasadi maliasadi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦅

@kipawaa kipawaa merged commit c223625 into main Jul 7, 2026
39 checks passed
@kipawaa kipawaa deleted the dl-driver-restructure branch July 7, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants