Skip to content

✨ Add pass for unrolling multi-operation modifiers #1758

@denialhaag

Description

@denialhaag

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    MLIRAnything related to MLIRfeatureNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions