✨ Add Additional Canonicalization Patterns for QTensor#1728
✨ Add Additional Canonicalization Patterns for QTensor#1728MatthiasReumann wants to merge 16 commits into
Conversation
(cherry picked from commit 0ce2d8b1e7fac64c25b160e2f8c1cd860c26d98e)
…ub.com/munich-quantum-toolkit/core into enh/additional-tensor-canonicalization
|
If I understood this correctly, then this complements the Furthermore: Does the bubbling canonicalization provide any "real" advantage besides sorting? Both canonicalizations can handle tensor chains well already without it, right? But I am most likely missing something 😌 |
Roughly yes. However, where the Extract-Insert one removes "no-ops": %q0_0, %t0_1 = extract %t0_0, 0
%t0_1 = insert %q0_0, %t0_1, 0
// transformed to
// <empty>the Insert-Extract removes double-extracts of the same index: %q0_0, %t0_1 = extract %t0_0, 0
%q0_1 = qco.h %q0_0
%t0_1 = insert %q0_1, %t0_1, 0
%q0_2, %t0_2 = extract %t0_1, 0
%q0_3 = qco.x %q0_2
%t0_3 = insert %q0_3, %t0_2, 0
// transformed to
%q0_0, %t0_1 = extract %t0_0, 0
%q0_1 = qco.h %q0_0
%q0_2 = qco.x %q0_1
%t0_2 = insert %q0_2, %t0_1, 0
This is probably true nonetheless. I was initially thinking about putting it to the
Yes.
I would argue the following (may be irrelevant or invalid)
Lastly, the pattern has been inspired by the |
Maybe I am stupid, but this is the same right. It is also removing a "no-op", it's just not an
Something really global would potentially better fit in the
Fair points. It is probably reasonable to aim for a canonical ordering here. Moreso a general observation: At some point we may think about whether we really want to run the full canonicalization at every stage in our pipeline or whether we'd rather run more targeted sequences of patterns. |
Now that I think about it, you are right 🫠
Probably also depends on how fast the end-to-end pipeline is, right? |
Yeah, small potential inefficiencies like these are particularly noticeable now since we do not yet have sophisticated passes running by default. |
(cherry picked from commit c6985f0190f8a9450086411b03096edae6534e12)
…ub.com/munich-quantum-toolkit/core into enh/additional-tensor-canonicalization
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Description
This pull request adds two additional canonicalization patterns to the
qtensor::InsertOpoperation.As discussed in #1718, in combination with the
QuantumLoopUnrollpass, this should us allow to map any quantum program usingscf.foroperations to superconducting architectures that do not support backwards branching.For example, base profile backends and adaptive profile backends without backwards branching support can run the following pass pipeline to map their quantum program.
Changes
TensorIteratorfor existing patterns inInsertOp.cppRemoveExtractAfterInsertPatternandBubbleDownInsertPatterncanonicalization patternsFollow-Ups
scf.foroperations natively, implement an approximative algorithm to find a SWAP sequence that restores one layout to another.Checklist
If PR contains AI-assisted content:
Assisted-by: [Model Name] via [Tool Name]footer.