cirq_superstaq.ops.qubit_gates

Miscellaneous custom gates that we encounter and want to explicitly define.

Attributes

AQTICCX

AQTITOFFOLI

AceCRMinusPlus

AceCRPlusMinus

CR

DD

ICCX

IX

ZX

Classes

AceCR

Active Cancellation Echoed Cross Resonance (AceCR) gate, parametrized (e.g., supporting

Barrier

A temporal boundary restricting circuit compilation and pulse scheduling.

DDPowGate

The Dipole-Dipole gate for EeroQ hardware.

IXGate

Thin wrapper of \(RX(-\pi)\) to improve iToffoli circuit diagrams.

ParallelGates

A single gate combining a collection of concurrent gate(s) acting on different qubits.

ParallelRGate

Wrapper class to define a ParallelGate of identical RGate gates.

RGate

A single-qubit gate that rotates about an axis in the X-Y plane.

StrippedCZGate

The Stripped CZ gate is a regular CZ gate when the rz angle = 0.

ZXPowGate

The ZX-parity gate, possibly raised to a power.

ZZSwapGate

The ZZ-SWAP gate, which performs the ZZ-interaction followed by a SWAP.

Functions

approx_eq_mod(→ bool)

Check if a ~= b (mod period). If either input is an unresolved parameter, returns a == b.

barrier(→ cirq.Operation)

Equivalent to https://qiskit.org/documentation/stubs/qiskit.circuit.library.Barrier.html.

custom_resolver(→ type[cirq.Gate] | None)

Tells cirq.read_json how to deserialize cirq-superstaq's custom gates.

parallel_gates_operation(→ cirq.Operation)

Constructs a parallel gates operation.

Module Contents

class cirq_superstaq.ops.qubit_gates.AceCR(rads: str | cirq.TParamVal = np.pi / 2, sandwich_rx_rads: cirq.TParamVal = 0)

Bases: cirq.Gate

Active Cancellation Echoed Cross Resonance (AceCR) gate, parametrized (e.g., supporting polarity switches) and supporting sandwiches.

The typical AceCR in literature is a positive half-CR, then X on “Z side”, then negative half-CR (“Z side” and “X side” refer to the two sides of the underlying ZX interactions).

rads
sandwich_rx_rads = 0
class cirq_superstaq.ops.qubit_gates.Barrier(num_qubits: int | None = None, qid_shape: Tuple[int, Ellipsis] | None = None)

Bases: cirq.ops.IdentityGate, cirq.InterchangeableQubitsGate

A temporal boundary restricting circuit compilation and pulse scheduling.

Otherwise equivalent to the identity gate.

class cirq_superstaq.ops.qubit_gates.DDPowGate(*, exponent: cirq.value.TParamVal = 1.0, global_shift: float = 0.0)

Bases: cirq.EigenGate

The Dipole-Dipole gate for EeroQ hardware.

class cirq_superstaq.ops.qubit_gates.IXGate

Bases: cirq.XPowGate

Thin wrapper of \(RX(-\pi)\) to improve iToffoli circuit diagrams.

class cirq_superstaq.ops.qubit_gates.ParallelGates(*component_gates: cirq.Gate)

Bases: cirq.Gate, cirq.InterchangeableQubitsGate

A single gate combining a collection of concurrent gate(s) acting on different qubits.

qubit_index_to_equivalence_group_key(index: int) int

Returns a key that differs between qubits.

Does it by different component gates and non-interchangeable qubits in the same component gate.

Parameters:

index – The qubit index.

Returns:

Equivalence group key.

qubit_index_to_gate_and_index(index: int) tuple[cirq.Gate, int]

Gets gate (and index) for the corresponding index.

Parameters:

index – The index into a particular member of the ParallelGates operation.

Returns:

A tuple of the gate at the given index and the index itself.

Raises:

ValueError – If index is outside bounds of gate index range.

component_gates: tuple[cirq.Gate, Ellipsis] = ()
class cirq_superstaq.ops.qubit_gates.ParallelRGate(theta: cirq.TParamVal, phi: cirq.TParamVal, num_copies: int)

Bases: cirq.ParallelGate, cirq.InterchangeableQubitsGate

Wrapper class to define a ParallelGate of identical RGate gates.

property exponent: cirq.TParamVal

The exponent property of ParallelRGate.

Returns:

The sub gate exponent.

property phase_exponent: cirq.TParamVal

The phase_exponent property of each RGate.

Returns:

The phase exponent.

property phi: cirq.TParamVal

The phi property of ParallelRGate, defining orientation (i.e., axis of rotation).

Returns:

The rotation-axis angle phi.

property sub_gate: RGate

The gate that is applied to the specified subspace.

Returns:

The underlying gate used.

property theta: cirq.TParamVal

The theta property of ParallelRGate, angle to rotate about the phi-determined axis.

Returns:

The rotation angle theta.

class cirq_superstaq.ops.qubit_gates.RGate(theta: cirq.TParamVal, phi: cirq.TParamVal)

Bases: cirq.PhasedXPowGate

A single-qubit gate that rotates about an axis in the X-Y plane.

property phi: cirq.TParamVal

Angle (in radians) defining the axis of rotation in the X-Y plane.

Returns:

The phi rotation angle.

property theta: cirq.TParamVal

Angle (in radians) by which to rotate about the axis given by self.phi.

Returns:

The theta rotation angle.

class cirq_superstaq.ops.qubit_gates.StrippedCZGate(rz_rads: cirq.TParamVal = 0)

Bases: cirq.Gate

The Stripped CZ gate is a regular CZ gate when the rz angle = 0.

It is the gate that is actually being performed by Sqale, and it is corrected into a CZ gate by RZ gates afterwards if the rz angle is nonzero.

property rz_rads: cirq.TParamVal

The RZ-rotation angle in radians for the gate.

Returns:

The angle for the RZ rotation.

class cirq_superstaq.ops.qubit_gates.ZXPowGate(*, exponent: cirq.value.TParamVal = 1.0, global_shift: float = 0.0)

Bases: cirq.EigenGate

The ZX-parity gate, possibly raised to a power.

Per arxiv.org/pdf/1904.06560v3 eq. 135, the ZX**t gate implements the following unitary:

\[\begin{split}e^{-\frac{i\pi}{2} t Z \otimes X} = \begin{bmatrix} c & -s & . & . \\ -s & c & . & . \\ . & . & c & s \\ . & . & s & c \\ \end{bmatrix}\end{split}\]

where ‘.’ means ‘0’ and \(c = \cos(\frac{\pi t}{2})\) and \(s = i \sin(\frac{\pi t}{2})\).

class cirq_superstaq.ops.qubit_gates.ZZSwapGate(theta: cirq.TParamVal)

Bases: cirq.Gate, cirq.ops.gate_features.InterchangeableQubitsGate

The ZZ-SWAP gate, which performs the ZZ-interaction followed by a SWAP.

ZZ-SWAPs are useful for applications like QAOA or Hamiltonian Simulation, particularly on linear- or low- connectivity devices. See https://arxiv.org/pdf/2004.14970.pdf for an application of ZZ SWAP networks.

The unitary for a ZZ-SWAP gate parametrized by ZZ-interaction angle \(\theta\) is:

\[\begin{split}\begin{bmatrix} 1 & . & . & . \\ . & . & e^{i \theta} & . \\ . & e^{i \theta} & . & . \\ . & . & . & 1 \\ \end{bmatrix}\end{split}\]

where ‘.’ means ‘0’. For \(\theta = 0\), the ZZ-SWAP gate is just an ordinary SWAP.

theta
cirq_superstaq.ops.qubit_gates.approx_eq_mod(a: cirq.TParamVal, b: cirq.TParamVal, period: float, atol: float = 1e-08) bool

Check if a ~= b (mod period). If either input is an unresolved parameter, returns a == b.

Parameters:
  • a – A Cirq parameter value.

  • b – A Cirq parameter value.

  • period – The parameter period (i.e., cycle time).

  • atol – The absolute tolerance for equality checking.

Returns:

A boolean indicating whether input parameters are approximately equal.

cirq_superstaq.ops.qubit_gates.barrier(*qubits: cirq.Qid) cirq.Operation

Equivalent to https://qiskit.org/documentation/stubs/qiskit.circuit.library.Barrier.html.

Parameters:

qubits – The qubits that the barrier will cover.

Returns:

A barrier cirq.Operation on the provided qubits.

cirq_superstaq.ops.qubit_gates.custom_resolver(cirq_type: str) type[cirq.Gate] | None

Tells cirq.read_json how to deserialize cirq-superstaq’s custom gates.

Changes to gate names in this file should be reflected in this resolver. See quantumai.google/cirq/dev/serialization for more information about (de)serialization.

Parameters:

cirq_type – The string of the gate type for the serializer to resolve.

Returns:

The resolved cirq.Gate matching the input, or None if no match.

cirq_superstaq.ops.qubit_gates.parallel_gates_operation(*ops: cirq.Operation) cirq.Operation

Constructs a parallel gates operation.

Given operations acting on disjoint qubits, constructs a single cirq_superstaq.ParallelGates instance and applies it such that each operation’s .gate is applied to its .qubits.

Parameters:

ops – Operations to pack into a single ParallelGates operation.

Returns:

ParallelGates(op.gate, op2.gate, …).on(*op.qubits, *op2.qubits, …)

Raises:
  • ValueError – If the operation has no .gate attribute.

  • ValueError – If the operation has tags.

cirq_superstaq.ops.qubit_gates.AQTICCX
cirq_superstaq.ops.qubit_gates.AQTITOFFOLI
cirq_superstaq.ops.qubit_gates.AceCRMinusPlus
cirq_superstaq.ops.qubit_gates.AceCRPlusMinus
cirq_superstaq.ops.qubit_gates.CR
cirq_superstaq.ops.qubit_gates.DD
cirq_superstaq.ops.qubit_gates.ICCX
cirq_superstaq.ops.qubit_gates.IX
cirq_superstaq.ops.qubit_gates.ZX