You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Controls: handled lazily via the unitary operation interface in both MQT Core IR and MLIR. No separate modifier op required right now.
Inversion: supported eagerly in MQT Core IR (see Operation::invert / Operation::get_inverted), but not yet modeled in MLIR and not available in a lazy evaluation scheme
A quick LLM summary about the general concept:
In MLIR, gate modifiers can be represented using one or more of the following approaches:
Op attributes on the modified op (e.g., mqtref.gate {inv} or {pow = r}) with canonicalizations that eliminate attributes by rewriting to equivalent ops.
Wrapper ops that own a region containing the target op(s) (e.g., mqtref.inv { ... }), enabling region-level transforms like reversing order and inverting contained ops.
Function- or region-level modifiers for block-wise semantics (e.g., to invert a block of unitary ops), verified via traits (e.g., "unitary-only region").
We’ll introduce a single, consistent framework that:
Defines a common modifier abstraction.
Verifies legality via traits/interfaces (e.g., only unitary ops permit inv/pow).
Provides canonicalizations to eliminate modifiers when possible (e.g., inv(Rz(θ)) -> Rz(-θ)).
Problem
We lack a unified representation for gate modifiers in MLIR; inversion isn’t modeled yet, and pow is missing entirely. We need IR constructs, verifiers, and canonicalizations consistent with frontend semantics and downstream lowerings.
Proposal:
Introduce modifier attributes and wrapper ops in MQTRef:
Attributes: inv: unit, pow: <integer|float>, reserved control (deferred).
Wrapper ops: mqtref.inv (region-level), optional mqtref.power if region application is needed.
Define traits/interfaces that mark ops and regions as unitary-only and thus eligible for modifiers.
Add canonicalizations and legality checks (e.g., prohibit pow on non-unitary ops, allow inv only on unitary sequences).
Provide lowering guidance for inv and pow (see sub-issues below): eager rewrites where possible; otherwise preserve modifier until a later pass.
Examples:
Attribute form on a single op
// Conceptual attribute usage (to be legalized by canonicalizations)%q = ... : !mqtref.qubitmqtref.rz%q, %theta {inv} : (!mqtref.qubit, f64) -> ()
Region form for inverse of a block
mqtref.inv {
// quantum-only region mqtref.h%q : !mqtref.qubit mqtref.cz%q0, %q1 : !mqtref.qubit, !mqtref.qubit
}
// Canonicalization: reverse order and invert each op
Acceptance criteria:
Common modifier abstraction exists (attributes + region wrapper), with verifiers and traits.
Canonicalizations for standard gates (e.g., adjoint of rotations, power-of-phase simplifications) are defined at framework level for reuse.
Documentation added to docs/mlir.md covering the modifier model.
Background
OpenQASM 3 introduces gate modifiers to concisely express transformations on quantum gates/blocks (see https://openqasm.com/versions/3.0/language/gates.html#quantum-gate-modifiers). Common modifiers include
inv(adjoint),pow(r), andctrl/negctrl.In our stack today:
Operation::invert/Operation::get_inverted), but not yet modeled in MLIR and not available in a lazy evaluation schemeMLIR concept of “modifiers”
A quick LLM summary about the general concept:
In MLIR, gate modifiers can be represented using one or more of the following approaches:
mqtref.gate {inv}or{pow = r}) with canonicalizations that eliminate attributes by rewriting to equivalent ops.mqtref.inv { ... }), enabling region-level transforms like reversing order and inverting contained ops.We’ll introduce a single, consistent framework that:
inv/pow).inv(Rz(θ)) -> Rz(-θ)).Problem
We lack a unified representation for gate modifiers in MLIR; inversion isn’t modeled yet, and
powis missing entirely. We need IR constructs, verifiers, and canonicalizations consistent with frontend semantics and downstream lowerings.Proposal:
inv: unit,pow: <integer|float>, reservedcontrol(deferred).mqtref.inv(region-level), optionalmqtref.powerif region application is needed.powon non-unitary ops, allowinvonly on unitary sequences).invandpow(see sub-issues below): eager rewrites where possible; otherwise preserve modifier until a later pass.Examples:
Acceptance criteria:
docs/mlir.mdcovering the modifier model.