mimiqcircuits.decomposition.rules.to_z_rotation

Rewrite rule for converting X and Y rotations to Z rotations.

Classes

ToZRotationRewrite()

Rewrite rule that converts RX and RY rotations to RZ + Clifford gates.

class mimiqcircuits.decomposition.rules.to_z_rotation.ToZRotationRewrite[source]

Bases: RewriteRule

Rewrite rule that converts RX and RY rotations to RZ + Clifford gates.

This is useful for gate sets where only Z-rotations are available as the parametric rotation (e.g., some hardware native gate sets).

Transformations:
  • RX(theta) -> H * RZ(theta) * H

  • RY(theta) -> Sdg * H * RZ(theta) * H * S

Example

>>> from mimiqcircuits import GateRX, GateRY
>>> from mimiqcircuits.decomposition import ToZRotationRewrite
>>> from symengine import pi
>>> rule = ToZRotationRewrite()
>>> circ = rule.decompose_step(GateRX(pi/3), [0], [], [])
matches(op)[source]

Check if this rule can decompose the operation.

Parameters:

op (Operation) – The operation to check.

Returns:

True for GateRX and GateRY operations.

Return type:

bool

decompose_step(op, qubits, bits, zvars)[source]

Convert RX or RY to RZ + Clifford gates.

Parameters:
  • op (Operation) – The rotation operation (GateRX or GateRY).

  • qubits (Sequence[int]) – Qubit indices for the operation.

  • bits (Sequence[int]) – Classical bit indices (unused).

  • zvars (Sequence[int]) – Z-variable indices (unused).

Returns:

A Circuit containing the decomposed instructions.

Raises:

DecompositionError – If the operation is not supported.

Return type:

Circuit