cirq_superstaq.ops
Submodules
Attributes
Classes
Active Cancellation Echoed Cross Resonance (AceCR) gate, parametrized (e.g., supporting |
|
iSWAP-like qutrit entangling gate swapping the "11" and "22" states of two qutrits. |
|
A temporal boundary restricting circuit compilation and pulse scheduling. |
|
The Dipole-Dipole gate for EeroQ hardware. |
|
A single gate combining a collection of concurrent gate(s) acting on different qubits. |
|
Wrapper class to define a ParallelGate of identical RGate gates. |
|
Embeds an n-qubit (i.e. SU(2^n)) gate into a given subspace of a higher-dimensional gate. |
|
A (non-parametrized) SWAP gate on two qudits of arbitrary dimension. |
|
Generalized CZ gate for pairs of equal-dimension qudits. |
|
Phase rotation on the ground state of a qutrit. |
|
Phase rotation on the first excited state of a qutrit. |
|
Phase rotation on the second excited state of a qutrit. |
|
A single-qubit gate that rotates about an axis in the X-Y plane. |
|
The Stripped CZ gate is a regular CZ gate when the rz angle = 0. |
|
Applies a phase rotation between two successive energy levels of a qudit. |
|
The ZX-parity gate, possibly raised to a power. |
|
The ZZ-SWAP gate, which performs the ZZ-interaction followed by a SWAP. |
Functions
|
Check if a ~= b (mod period). If either input is an unresolved parameter, returns a == b. |
|
Equivalent to https://qiskit.org/documentation/stubs/qiskit.circuit.library.Barrier.html. |
|
Constructs a parallel gates operation. |
|
Embeds a qubit Operation into a given subspace of a higher-dimensional Operation. |
|
Construct a SWAP gate and apply it to the provided qudits. |
Package Contents
- class cirq_superstaq.ops.AceCR(rads: str | cirq.TParamVal = np.pi / 2, sandwich_rx_rads: cirq.TParamVal = 0)
Bases:
cirq.GateActive 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.BSwapPowGate(*, exponent: cirq.value.TParamVal = 1.0, global_shift: float = 0.0)
Bases:
cirq.EigenGate,cirq.InterchangeableQubitsGateiSWAP-like qutrit entangling gate swapping the “11” and “22” states of two qutrits.
- property dimension: int
Indicates that this gate acts on qutrits.
- Returns:
The integer 3, representing the qudit dimension for qutrits.
- class cirq_superstaq.ops.Barrier(num_qubits: int | None = None, qid_shape: Tuple[int, Ellipsis] | None = None)
Bases:
cirq.ops.IdentityGate,cirq.InterchangeableQubitsGateA temporal boundary restricting circuit compilation and pulse scheduling.
Otherwise equivalent to the identity gate.
- class cirq_superstaq.ops.DDPowGate(*, exponent: cirq.value.TParamVal = 1.0, global_shift: float = 0.0)
Bases:
cirq.EigenGateThe Dipole-Dipole gate for EeroQ hardware.
- class cirq_superstaq.ops.ParallelGates(*component_gates: cirq.Gate)
Bases:
cirq.Gate,cirq.InterchangeableQubitsGateA 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.ParallelRGate(theta: cirq.TParamVal, phi: cirq.TParamVal, num_copies: int)
Bases:
cirq.ParallelGate,cirq.InterchangeableQubitsGateWrapper 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.QubitSubspaceGate(sub_gate: cirq.Gate, qid_shape: collections.abc.Sequence[int], subspaces: collections.abc.Sequence[tuple[int, int]] | None = None)
Bases:
cirq.Gate,cirq.InterchangeableQubitsGateEmbeds an n-qubit (i.e. SU(2^n)) gate into a given subspace of a higher-dimensional gate.
- qubit_index_to_equivalence_group_key(index: int) int
Check for interchangeable qubits.
Any interchangeable qubits in sub_gate will remain interchangeable in this gate if they have the same dimension and subspace.
- property qid_shape: tuple[int, Ellipsis]
Specifies the qudit dimension for each of the inputs.
- Returns:
The dimensions for the input qudits.
- property sub_gate: cirq.Gate
The gate that is applied to the specified subspace.
- Returns:
The underlying gate used.
- property subspaces: list[tuple[int, int]]
A list of subspace indices acted upon.
For instance, a CX on the 0-1 qubit subspace of two qudits would have subspaces of [(0, 1), (0, 1)]. The same gate acting on the 1-2 subspaces of both qudits would correspond to [(1, 2), (1, 2)].
- Returns:
A list of dimensions tuples, specified for each subspace.
- class cirq_superstaq.ops.QuditSwapGate(dimension: int)
Bases:
cirq.Gate,cirq.InterchangeableQubitsGateA (non-parametrized) SWAP gate on two qudits of arbitrary dimension.
- property dimension: int
The qudit dimension on which this SWAP gate will act.
- Returns:
The qudit dimension.
- class cirq_superstaq.ops.QutritCZPowGate(*, exponent: cirq.value.TParamVal = 1.0, global_shift: float = 0.0)
Bases:
cirq.EigenGate,cirq.InterchangeableQubitsGateGeneralized CZ gate for pairs of equal-dimension qudits.
It is defined by the following unitary:
U = Σ_(i<d,j<d) ω**ij.|i⟩⟨i|.|j⟩⟨j|,
where d is the dimension of the qudits and ω = exp(2πi/d).
Currently written for qutrits (d = 3), but its implementation should work for any dimension.
- property dimension: int
Indicates that this gate acts on qutrits.
- Returns:
The integer 3, representing the qudit dimension for qutrits.
- class cirq_superstaq.ops.QutritZ0PowGate(*, exponent: cirq.value.TParamVal = 1.0, global_shift: float = 0.0)
Bases:
_QutritZPowGatePhase rotation on the ground state of a qutrit.
- class cirq_superstaq.ops.QutritZ1PowGate(*, exponent: cirq.value.TParamVal = 1.0, global_shift: float = 0.0)
Bases:
_QutritZPowGatePhase rotation on the first excited state of a qutrit.
- class cirq_superstaq.ops.QutritZ2PowGate(*, exponent: cirq.value.TParamVal = 1.0, global_shift: float = 0.0)
Bases:
_QutritZPowGatePhase rotation on the second excited state of a qutrit.
- class cirq_superstaq.ops.RGate(theta: cirq.TParamVal, phi: cirq.TParamVal)
Bases:
cirq.PhasedXPowGateA 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.StrippedCZGate(rz_rads: cirq.TParamVal = 0)
Bases:
cirq.GateThe 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.VirtualZPowGate(dimension: int = 2, level: int = 1, exponent: cirq.TParamVal = 1.0, global_shift: float = 0.0)
Bases:
cirq.EigenGateApplies a phase rotation between two successive energy levels of a qudit.
- property dimension: int
The qudit dimension on which this gate acts.
- Returns:
The gate’s dimension.
- property level: int
The lowest energy level onto which this gate applies a phase; for example if level=2 a phase of (-1)**exponent will be applied to energy levels [2, …, dimension - 1]. This is equivalent to phase shifting all subsequent single-qudit gates acting in the (1, 2) subspace (assuming all other gates commute with this one).
- Returns:
The lowest energy level onto which this gate applies a phase.
- class cirq_superstaq.ops.ZXPowGate(*, exponent: cirq.value.TParamVal = 1.0, global_shift: float = 0.0)
Bases:
cirq.EigenGateThe 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.ZZSwapGate(theta: cirq.TParamVal)
Bases:
cirq.Gate,cirq.ops.gate_features.InterchangeableQubitsGateThe 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.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.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.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_subspace_op(sub_op: cirq.Operation, qid_shape: collections.abc.Sequence[int], subspaces: collections.abc.Sequence[tuple[int, int]] | None = None) cirq.Operation
Embeds a qubit Operation into a given subspace of a higher-dimensional Operation.
Uses QubitSubspaceGate.
- Parameters:
sub_op – The cirq.Operation to embed.
qid_shape – The dimensions of the subspace.
subspaces – The list of all subspaces.
- Returns:
A cirq.Operation embedding a low-dimensional operation.
- Raises:
ValueError – If there is no gate specified for the subspace operation.
- cirq_superstaq.ops.qudit_swap_op(qudit0: cirq.Qid, qudit1: cirq.Qid) cirq.Operation
Construct a SWAP gate and apply it to the provided qudits.
If both qudits have dimension 2, uses cirq.SWAP; otherwise uses QuditSwapGate.
- Parameters:
qudit0 – The first qudit to swap.
qudit1 – The second qudit to swap.
- Returns:
A SWAP gate acting on the provided qudits.
- Raises:
ValueError – If the input qudits don’t have the same dimension.
- cirq_superstaq.ops.AQTICCX
- cirq_superstaq.ops.AQTITOFFOLI
- cirq_superstaq.ops.AceCRMinusPlus
- cirq_superstaq.ops.AceCRPlusMinus
- cirq_superstaq.ops.BSWAP
- cirq_superstaq.ops.BSWAP_INV
- cirq_superstaq.ops.CR
- cirq_superstaq.ops.CZ3
- cirq_superstaq.ops.CZ3_INV
- cirq_superstaq.ops.DD
- cirq_superstaq.ops.QutritZ0
- cirq_superstaq.ops.QutritZ1
- cirq_superstaq.ops.QutritZ2
- cirq_superstaq.ops.SWAP3
- cirq_superstaq.ops.ZX