Decomp/pbc decomposable interface - #3170
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3170 +/- ##
==========================================
- Coverage 95.72% 95.64% -0.09%
==========================================
Files 174 177 +3
Lines 20720 20854 +134
Branches 2087 2100 +13
==========================================
+ Hits 19835 19945 +110
- Misses 691 722 +31
+ Partials 194 187 -7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks @hsajjad14!
We still need the interface for PPMs because they can be the result of a decomposition, and so need to be registered in the graph. Could you add the interface & tests for this as well? |
There was a problem hiding this comment.
Could you add tests for controlled/adjoint gates as well?
There was a problem hiding this comment.
For controlled PPR gates, the mlir generated for this qp.ctrl(qp.PauliRot, control = (0), control_values=(1))(angle, pauli_word="YZ", wires=[1, 2]) after to-ppr is %16:2 = pbc.ppr.arbitrary ["Y", "Z"](%cst) %15#1, %15#2 : !quantum.bit, !quantum.bit there is no control attribute for pbc. So that test would be the same as PPRotationArbitraryOp.
For adjoint gates, for PBC dialect the adjoint attribute gets lowered out to be a negative angle. I added tests for that in here 6cca181
I added ppm op to the interface in 2f9a1cb. |
Context:
The DecomposableGate interface was introduced to provide a generic interface for decomposition of quantum gates. We want the graph-decomposition to be able to decompose to the PBC dialect, but this will require the DecomposableGate interface be implemented for PBC gates.
Description of the Change:
This PR extends the
DecomposableGateinterface to the PBC dialect. It uses the same template for how the interface is extended for Quantum and Qref dialects.I added the DecomposableGate interface to
PBCOpInterfaces.td(this does not inheritQuantumGateunlike inQuantumInterface.td), then extend the two PPR operations inPBCOps.td,PPRotationOpandPPRotationArbitraryOp. Currently only these two operations in the PBC dialect have decomposition rules,PPMeasurementOpisqp.PauliMeasure, but it has noadd_decompsin PennyLane yet.PBCOpInterfaces.cppis slightly different thanQuantumInterfances.cpp. FordefaultGetGraphOpIdbecause the PPR operations don't have adjoint in itsargumentsin thePBCOps.td, it is not an attribute. Also the operation will never be a QuantumGate, thus there is no need for awrapModifiersfunction aroundgetOperatorName().I used the same helpers from
QuantumInterfances.cppinPBCOpInterfaces.cpp, but from comparing with the QRef those helpers are slightly different, so I held off on moving the helpers into their own file.In
PBCOps.cppI implement two operationsPPRotationOpandPPRotationArbitraryOp. I use the same implementation fromQuantumOps.cppforPauliRotOpexcept because DecomposableGate for PBC does not inheritQuantumGate, forgetWireLens()I usedgetInQubits().size()to get wires instead ofgetNonCtrlQubitOperands().size().Benefits:
Allows PBC operations to be compatible with the
graph-decompositionpass.Possible Drawbacks:
Code duplication with Quantum and Qref dialect, especially for the helper functions.
Related GitHub Issues:
[sc-129100]