Block

class guppyft.code.iceberg.logical.Block[source]

An Iceberg logical block containing N logical qubits.

static __new__() → Block[N][source]

Allocate a block in the all-zero logical state.

all_but_one_x(i: int) → None[source]

X gate on all qubits except that with index i.

all_but_one_z(i: int) → None[source]

Z gate on all qubits except that with index i.

all_h() → None[source]

H gate on all qubits.

all_x() → None[source]

X gate on all qubits.

all_y() → None[source]

Y gate on all qubits.

all_z() → None[source]

Z gate on all qubits.

cx(i: int, j: int) → None[source]

CX gate on the qubits with indices i (control) and j (target).

fan_in(i: int) → None[source]

Fan-in to the qubit with index i from all others.

fan_out(i: int) → None[source]

Fan-out from the qubit with index i to all others.

measure_syndrome() → tuple[Measurement, Measurement][source]

Syndrome measurement.

pauli_exp_all_x(phase: float) → None[source]

Apply the logical all-X Pauli exponential.

\[\exp(-i \theta X^{\otimes k} / 2)\]

where \(\theta\) is phase in radians and \(k\) is the number of logical qubits in the block.

pauli_exp_all_x_except_at(i: int, phase: float) → None[source]

Apply the Pauli exponential with I at i and X elsewhere.

\[\exp(-i \theta ( X^{\otimes i} \otimes I \otimes X^{\otimes(k-i-1)} ) / 2)\]

where \(\theta\) is phase in radians and \(k\) is the number of logical qubits in the block.

pauli_exp_all_x_except_z_at(i: int, phase: float) → None[source]

Apply the Pauli exponential with Z at i and X elsewhere.

\[\exp(-i \theta ( X^{\otimes i} \otimes Z \otimes X^{\otimes(k-i-1)} ) / 2)\]

where \(\theta\) is phase in radians and \(k\) is the number of logical qubits in the block.

pauli_exp_all_y(phase: float) → None[source]

Apply the logical all-Y Pauli exponential.

\[\exp(-i \theta Y^{\otimes k} / 2)\]

where \(\theta\) is phase in radians and \(k\) is the number of logical qubits in the block.

pauli_exp_all_z(phase: float) → None[source]

Apply the logical all-Z Pauli exponential.

\[\exp(-i \theta Z^{\otimes k} / 2)\]

where \(\theta\) is phase in radians and \(k\) is the number of logical qubits in the block.

pauli_exp_all_z_except_at(i: int, phase: float) → None[source]

Apply the Pauli exponential with I at i and Z elsewhere.

\[\exp(-i \theta ( Z^{\otimes i} \otimes I \otimes Z^{\otimes(k-i-1)} ) / 2)\]

where \(\theta\) is phase in radians and \(k\) is the number of logical qubits in the block.

pauli_exp_all_z_except_x_at(i: int, phase: float) → None[source]

Apply the Pauli exponential with X at i and Z elsewhere.

\[\exp(-i \theta ( Z^{\otimes i} \otimes X \otimes Z^{\otimes(k-i-1)} ) / 2)\]

where \(\theta\) is phase in radians and \(k\) is the number of logical qubits in the block.

rx(i: int, phase: float) → None[source]

Rx rotation of phase radians on the qubit with index i.

ry(i: int, phase: float) → None[source]

Ry rotation of phase radians on logical qubit i.

Ry is not a primitive and is implemented here as .. math:

R_y(\theta) = R_x(-\pi/2) R_z(\theta) R_x(\pi/2)

where \(\theta\) is phase.

rz(i: int, phase: float) → None[source]

Rz rotation of phase radians on the qubit with index i.

swap(i: int, j: int) → None[source]

Swap of the qubits with indices i and j.

try_measure_one_x(i: int) → Option[Measurement][source]

Fallible non-destructive measurement in the X basis of the qubit with index i.

try_measure_one_z(i: int) → Option[Measurement][source]

Fallible non-destructive measurement in the Z basis of the qubit with index i.

x(i: int) → None[source]

X gate on the qubit with index i.

x_with_all_but_one_z(i: int) → None[source]

X gate on the qubit with index i; Z on all others.

xx(i: int, j: int) → None[source]

X gate on the qubits with indices i and j.

xx_phase(i: int, j: int, phase: float) → None[source]

XXPhase rotation of phase radians on the qubits with indices i and j.

y(i: int) → None[source]

Y gate on the qubit with index i.

yy(i: int, j: int) → None[source]

Y gate on the qubits with indices i and j.

yy_phase(i: int, j: int, phase: float) → None[source]

YYPhase rotation of phase radians on the qubits with indices i and j.

z(i: int) → None[source]

Z gate on the qubit with index i.

z_with_all_but_one_x(i: int) → None[source]

Z gate on the qubit with index i; X on all others.

zz(i: int, j: int) → None[source]

Z gate on the qubits with indices i and j.

zz_phase(i: int, j: int, phase: float) → None[source]

ZZPhase rotation of phase radians on the qubits with indices i and j.