-
Couldn't load subscription status.
- Fork 57
A new catalyst decomposition at MLIR based on the experimental graph-based decomposition system #2029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…r e2e testing from v3)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2029 +/- ##
==========================================
+ Coverage 97.45% 97.46% +0.01%
==========================================
Files 90 91 +1
Lines 10476 10591 +115
Branches 972 990 +18
==========================================
+ Hits 10209 10323 +114
+ Misses 213 212 -1
- Partials 54 56 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f22bcd7 to
02be034
Compare
|
Just a question: what is this PR's relationship to #1962 ? |
@paul0403 The main difference is the scope! This PR enables decomposition at the MLIR level and improves interoperability with other MLIR/xDSL passes. #1962 is a temporary patch to apply decomposition at PLxPR that is still aligned with the compiler-specific decomposition in this PR. But for the compiler-specific decomposition, we don't use the graph-based decomposition to find the solutions because
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 🎉 just small changes and questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from my side, seems like all the "hacky" bits are isolated in the new decompose.py and there are plans to use the upstream PL decomposition interpreter, so the main catalyst from_plxpr program flow is not seeing anything increasing hacky-ness 😆
Approving pending Astral's comments regarding decomp logic (which I'm not super familiar with).
… present in MLIR (#2001) **Context:** Introduces a new MLIR pass that enables user-defined decomposition of quantum gate operations. The pass discovers decomposition functions in the module and uses MLIR's inlining infrastructure to replace target quantum operations with their decomposed implementations. **Description of the Change:** This PR will **recognize** the `func.func` as decomposition if they have name start with the pattern `<Gate>_rule[.]*` where the `<Gate>` is a `quantum.custom` op it expect to replace (It's not what generated from frontend). Also you can just mark the attributes `catalyst.decomposition` and `catalyst.decomposition.target_op` at decomposition function, it still works. And this pass just **discover** those decomposition functions and **replace** the target operation with `call` to the function and rely on the Inliner interface to inline these decomposition function if needed. The stages of the `--decompose-lowering`: 1. `decompose_lowering.cpp`: Main pass that orchestrates the decomposition process 2. `DecomposeLoweringPatterns`: Pattern rewriting logic that replaces `quantum.custom` operations with function call 3. `QuantumInlinerInterface`: Dialect interface that enables MLIR's inliner to process quantum operations correctly 4. Remove unused decomposition function (if the inliner decide not to inline the certain function, then it will leave a `func.call`, so the func is used, shouldn't be removed) The type signature between decomposition function provided from the frontend is different to the `quantum.custom` op, `OpSignatureAnalyzer` does the trick to get the enough information to generate a function call to decomposition function. Current right now, frontend choose to generate the decomposition function with type: ``` (qreg, param*, inWires*, inCtrlWires*?, inCtrlValues*?) -> qreg ``` We need to figure out the information that need to pass to create the function call: qreg, `in wires indices`, and `in ctrl wires`. `OpSignatureAnalyzer` will use the target `quantum.custom` op (that one we need to replace) to traverse the qubit, and find out the qreg, and wire indices. The traversal logic based on the following assumption for the quantum dialect: 1. The ordering of qubits is preserved in quantum instructions 2. For other instructions, they will use a register, so will hit an extract before them It promise that every gates, the result (qubits) will match to the operands (qubits) at the same index. That's the important assumptions to support the traversal logic here. Traverse the qubit, match the index, keep going up until reach the `qauntum.extract` operation. After then, we use those information to generate a function call and rely on the Inliner in MLIR infra to replace it. **Benefits:** The decision to use MLIR's inlining infrastructure (`InlinerPass`) is to provide future-proofing and flexibility. **Possible Drawbacks:** **Related GitHub Issues:** [sc-98593] --------- Co-authored-by: Ali Asadi <[email protected]>
…talyst into feature/handle_gdecomp_v4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for answering all my questions.
Uh oh!
There was an error while loading. Please reload this page.