qat.experimental.dialect.gate.ir.ops module

Operations of the gate dialect.

Each gate is its own op, such as HOp or CZOp. Base classes hold the shape of each family of gates: the qubits a gate acts on, the angles it takes, and the rule that each result keeps the qubit type of its operand. Angles are f64 operands, so a gate can take a run-time parameter as well as a constant.

Every op that takes a qubit consumes it, so a qubit value should be used once. Op verifiers check this only within one op: a two-qubit gate or a barrier rejects the same qubit twice. Checking it across a whole program is left to a verification pass.

Gate ops are not Pure. They change the state of a qubit, and dead-code elimination would otherwise delete a gate whose result is unused.

class AllocateAlgorithmicQubitOp

Bases: AllocateAlgorithmicQubitOp, AllocateQubitOp, AllocateQubitOp, IRDLOperation, Operation, _IRNode, ABC, object

Allocates a new algorithmic qubit, initialised to the |0⟩ state.

An algorithmic qubit is a qubit as written in the source program, before placement. Compiling a program starts by allocating its qubits with this op.

Allocates an algorithmic qubit.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.allocate_qubit.algorithmic'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

result

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class AllocatePhysicalQubitOp(index)

Bases: AllocatePhysicalQubitOp, AllocateQubitOp, AllocateQubitOp, IRDLOperation, Operation, _IRNode, ABC, object

Allocates a new physical qubit, initialised to the |0⟩ state.

Parameters:

index (IntegerAttr | int) – The index of the qubit on the device.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.allocate_qubit.physical'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

result

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class AllocateQubitOp(qubit_type)

Bases: AllocateQubitOp, IRDLOperation, Operation, _IRNode, ABC, object

Allocates a new qubit of any qubit type, initialised to the |0⟩ state.

The result type says whether the qubit is algorithmic or physical. AllocateAlgorithmicQubitOp and AllocatePhysicalQubitOp each allow only one.

Variables:

result – The new qubit.

Parameters:

qubit_type (QubitType) – The type of the new qubit.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.allocate_qubit'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

result

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class BarrierOp(qubits)

Bases: BarrierOp, IRDLOperation, Operation, _IRNode, ABC, object

Optimisation barrier across a set of qubits.

Stops optimisations moving operations on these qubits across the barrier. It carries no timing: whether it also lines up the qubits’ timelines is decided when it is lowered. Takes a variadic set of distinct qubits and returns each one unchanged.

Variables:
  • qubits – Qubits operand to which the barrier is applied.

  • result_qubits – The qubits after the barrier.

Parameters:

qubits (Sequence[SSAValue | Operation]) – The qubits to fence. Each result has the type of its qubit.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.barrier'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubits

Access a variadic construct in the case where it is the only variadic.

result_qubits

Access a variadic construct in the case where it is the only variadic.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class CXOp(control, target)

Bases: CXOp, CliffordDirectionalTwoQubitGate, DirectionalTwoQubitGate, TwoQubitGate, IRDLOperation, Operation, _IRNode, ABC, object

The controlled-X (CNOT) gate.

Builds the gate. Each result has the type of its qubit.

Parameters:
  • control (SSAValue | Operation) – The control qubit.

  • target (SSAValue | Operation) – The target qubit.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.cx'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubit_0

Access a non-variadic construct which appears before any variadic arguments.

qubit_1

Access a non-variadic construct which appears before any variadic arguments.

result_qubit_0

Access a non-variadic construct which appears before any variadic arguments.

result_qubit_1

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class CZOp(qubit_0, qubit_1)

Bases: CZOp, CliffordTwoQubitGate, TwoQubitGate, IRDLOperation, Operation, _IRNode, ABC, object

The controlled-Z gate.

Builds the gate. Each result has the type of its qubit.

Parameters:
  • qubit_0 (SSAValue | Operation) – The first qubit.

  • qubit_1 (SSAValue | Operation) – The second qubit.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.cz'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubit_0

Access a non-variadic construct which appears before any variadic arguments.

qubit_1

Access a non-variadic construct which appears before any variadic arguments.

result_qubit_0

Access a non-variadic construct which appears before any variadic arguments.

result_qubit_1

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class CliffordDirectionalTwoQubitGate(control, target)

Bases: DirectionalTwoQubitGate

Base class for a Clifford gate on two qubits with control and target roles.

Builds the gate. Each result has the type of its qubit.

Parameters:
  • control (SSAValue | Operation) – The control qubit.

  • target (SSAValue | Operation) – The target qubit.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

class CliffordOneQubitGate(qubit)

Bases: OneQubitGate

Base class for a Clifford gate on one qubit.

Parameters:

qubit (SSAValue | Operation) – The qubit to act on. The result has the same type.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

class CliffordTwoQubitGate(qubit_0, qubit_1)

Bases: TwoQubitGate

Base class for a Clifford gate on two qubits.

Builds the gate. Each result has the type of its qubit.

Parameters:
  • qubit_0 (SSAValue | Operation) – The first qubit.

  • qubit_1 (SSAValue | Operation) – The second qubit.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

class DeallocateQubitOp(qubit)

Bases: DeallocateQubitOp, IRDLOperation, Operation, _IRNode, ABC, object

Ends the lifetime of a qubit.

Consumes the qubit and returns nothing. Use it for a qubit that is not measured, so its chain of values has an explicit end. The verifier does not require one.

Variables:

qubit – The qubit to deallocate.

Parameters:

qubit (SSAValue | Operation) – The qubit to deallocate.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.deallocate_qubit'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubit

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class DirectionalTwoQubitGate(control, target)

Bases: TwoQubitGate

Base class for a gate on two qubits with control and target roles, with no angle.

The control is the first qubit and the target the second. The properties below name them by role.

Builds the gate. Each result has the type of its qubit.

Parameters:
  • control (SSAValue | Operation) – The control qubit.

  • target (SSAValue | Operation) – The target qubit.

property qubit_control: SSAValue

The control qubit operand.

property qubit_target: SSAValue

The target qubit operand.

property result_qubit_control: SSAValue

The control qubit after the gate.

property result_qubit_target: SSAValue

The target qubit after the gate.

class HOp(qubit)

Bases: HOp, CliffordOneQubitGate, OneQubitGate, IRDLOperation, Operation, _IRNode, ABC, object

The Hadamard gate.

Parameters:

qubit (SSAValue | Operation) – The qubit to act on. The result has the same type.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.h'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubit

Access a non-variadic construct which appears before any variadic arguments.

result

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class IdentityOp(qubit)

Bases: IdentityOp, IRDLOperation, Operation, _IRNode, ABC, object

Identity gate — passes the qubit state through unchanged.

Used as a canonical no-op placeholder, e.g. after gate cancellation leaves a qubit with an empty operation sequence before dead-qubit elimination runs.

Variables:
  • qubit – Qubit operand to which the gate is applied.

  • result – The qubit after the gate.

Parameters:

qubit (SSAValue | Operation) – The qubit to act on. The result has the same type.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.identity'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubit

Access a non-variadic construct which appears before any variadic arguments.

result

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class MeasureOp(qubit)

Bases: MeasureOp, IRDLOperation, Operation, _IRNode, ABC, object

Measures a single qubit.

Consumes the qubit and returns the outcome as an i1.

Variables:
  • qubit – The qubit to measure.

  • result – The measurement outcome.

Parameters:

qubit (SSAValue | Operation) – The qubit to measure.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.measure'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubit

Access a non-variadic construct which appears before any variadic arguments.

result

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class OneAngleGate(qubit, theta)

Bases: IRDLOperation

Base class for a gate on one qubit with one angle.

Variables:
  • qubit – Qubit operand to which the gate is applied.

  • theta – Angle in radians. A constant, or a run-time parameter.

  • result – The qubit after the gate.

Builds the gate. The result has the type of the qubit.

Parameters:
  • qubit (SSAValue | Operation) – The qubit to act on.

  • theta (SSAValue | Operation) – The angle, an f64 value.

qubit = <xdsl.irdl.operations._OperandFieldDef object>
result = <xdsl.irdl.operations._ResultFieldDef object>
theta = <xdsl.irdl.operations._OperandFieldDef object>
class OneQubitGate(qubit)

Bases: IRDLOperation

Base class for a gate on one qubit, with no angle.

Variables:
  • qubit – Qubit operand to which the gate is applied.

  • result – The qubit after the gate.

Parameters:

qubit (SSAValue | Operation) – The qubit to act on. The result has the same type.

qubit = <xdsl.irdl.operations._OperandFieldDef object>
result = <xdsl.irdl.operations._ResultFieldDef object>
class RZOp(qubit, theta)

Bases: RZOp, OneAngleGate, IRDLOperation, Operation, _IRNode, ABC, object

A rotation about the Z axis by theta.

Builds the gate. The result has the type of the qubit.

Parameters:
  • qubit (SSAValue | Operation) – The qubit to act on.

  • theta (SSAValue | Operation) – The angle, an f64 value.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.rz'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubit

Access a non-variadic construct which appears before any variadic arguments.

result

Access a non-variadic construct which appears before any variadic arguments.

theta

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class ResetOp(qubit)

Bases: ResetOp, IRDLOperation, Operation, _IRNode, ABC, object

Resets a qubit to the |0⟩ state.

MeasureOp consumes its qubit, so a measured qubit cannot be reset.

Variables:
  • qubit – Qubit operand to which the reset is applied.

  • result – The qubit after the reset.

Parameters:

qubit (SSAValue | Operation) – The qubit to act on. The result has the same type.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.reset'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubit

Access a non-variadic construct which appears before any variadic arguments.

result

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class ThreeAngleGate(qubit, theta, phi, lam)

Bases: IRDLOperation

Base class for a gate on one qubit with three angles.

Variables:
  • qubit – Qubit operand to which the gate is applied.

  • theta – First angle in radians.

  • phi – Second angle in radians.

  • lam – Third angle in radians (lambda).

  • result – The qubit after the gate.

Builds the gate. The result has the type of the qubit.

Parameters:
  • qubit (SSAValue | Operation) – The qubit to act on.

  • theta (SSAValue | Operation) – The first angle, an f64 value.

  • phi (SSAValue | Operation) – The second angle, an f64 value.

  • lam (SSAValue | Operation) – The third angle, an f64 value.

lam = <xdsl.irdl.operations._OperandFieldDef object>
phi = <xdsl.irdl.operations._OperandFieldDef object>
qubit = <xdsl.irdl.operations._OperandFieldDef object>
result = <xdsl.irdl.operations._ResultFieldDef object>
theta = <xdsl.irdl.operations._OperandFieldDef object>
class TwoQubitGate(qubit_0, qubit_1)

Bases: IRDLOperation

Base class for a gate on two qubits, with no angle.

The two qubits must be distinct, and both algorithmic or both physical.

Variables:
  • qubit_0 – First qubit operand to which the gate is applied.

  • qubit_1 – Second qubit operand to which the gate is applied.

  • result_qubit_0 – The first qubit after the gate.

  • result_qubit_1 – The second qubit after the gate.

Builds the gate. Each result has the type of its qubit.

Parameters:
  • qubit_0 (SSAValue | Operation) – The first qubit.

  • qubit_1 (SSAValue | Operation) – The second qubit.

qubit_0 = <xdsl.irdl.operations._OperandFieldDef object>
qubit_1 = <xdsl.irdl.operations._OperandFieldDef object>
result_qubit_0 = <xdsl.irdl.operations._ResultFieldDef object>
result_qubit_1 = <xdsl.irdl.operations._ResultFieldDef object>
verify_()
Return type:

None

class U3Op(qubit, theta, phi, lam)

Bases: U3Op, ThreeAngleGate, IRDLOperation, Operation, _IRNode, ABC, object

The general single-qubit gate U3(theta, phi, lambda).

Builds the gate. The result has the type of the qubit.

Parameters:
  • qubit (SSAValue | Operation) – The qubit to act on.

  • theta (SSAValue | Operation) – The first angle, an f64 value.

  • phi (SSAValue | Operation) – The second angle, an f64 value.

  • lam (SSAValue | Operation) – The third angle, an f64 value.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

lam

Access a non-variadic construct which appears before any variadic arguments.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.u3'

The operation name. Should be a static member of the class

phi

Access a non-variadic construct which appears before any variadic arguments.

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubit

Access a non-variadic construct which appears before any variadic arguments.

result

Access a non-variadic construct which appears before any variadic arguments.

theta

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class XOp(qubit)

Bases: XOp, CliffordOneQubitGate, OneQubitGate, IRDLOperation, Operation, _IRNode, ABC, object

The Pauli-X gate.

Parameters:

qubit (SSAValue | Operation) – The qubit to act on. The result has the same type.

attributes: dict[str, Attribute]

The attributes attached to the operation.

classmethod get_irdl_definition()

Get the IRDL operation definition.

location: LocationAttr

The source location attached to this operation.

name: ClassVar[str] = 'gate.op.x'

The operation name. Should be a static member of the class

properties: dict[str, Attribute]

The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.

qubit

Access a non-variadic construct which appears before any variadic arguments.

result

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()