Description
#1751 has dropped the condition that modifier bodies can only contain a single unitary operation followed by a yield operation.
We should add a pass that unrolls such modifiers into a sequence of one-operation modifiers. For example,
%const = arith.constant 0.123 : f64
qc.ctrl(%c0, %c1) targets(%t0, %t1) {
qc.x %t0 : !qc.qubit
qc.rxx(%const) %t0, %t1 : !qc.qubit, !qc.qubit
}
is unrolled to
%const = arith.constant 0.123 : f64
qc.ctrl(%c0, %c1) targets(%t0) {
qc.x %t0 : !qc.qubit
}
qc.ctrl(%c0, %c1) targets(%t0, %t1) {
qc.rxx(%const) %t0, %t1 : !qc.qubit, !qc.qubit
}
Notice that the block arguments (i.e., targets) should be adjusted as well. When unrolling inv modifiers, the order of the operations must be inverted as well.
Once implemented, this pass should be used to prepare the IR before the QCO-to-jeff and QC-to-QIR conversions. These cannot currently fully convert multi-operation modifiers. The QC-to-QIR conversion can furthermore be simplified by making LoweringState::inCtrlOp a bool.
Acceptance criteria
- The described pass is implemented for
ctrl, inv, and pow modifiers
- The described pass is used in the QCO-to-
jeff and QC-to-QIR conversions
LoweringState::inCtrlOp is simplified
Description
#1751 has dropped the condition that modifier bodies can only contain a single unitary operation followed by a
yieldoperation.We should add a pass that unrolls such modifiers into a sequence of one-operation modifiers. For example,
is unrolled to
Notice that the block arguments (i.e.,
targets) should be adjusted as well. When unrollinginvmodifiers, the order of the operations must be inverted as well.Once implemented, this pass should be used to prepare the IR before the QCO-to-
jeffand QC-to-QIR conversions. These cannot currently fully convert multi-operation modifiers. The QC-to-QIR conversion can furthermore be simplified by makingLoweringState::inCtrlOpabool.Acceptance criteria
ctrl,inv, andpowmodifiersjeffand QC-to-QIR conversionsLoweringState::inCtrlOpis simplified