Overview#

This section describes the basic working principle of the cuStabilizer library. For a general introduction to quantum circuits, please refer to Introduction to quantum computing.

Introduction to Pauli frame simulation#

Trajectory-based noise simulation#

A common approach to model the effect of noise on quantum computation is a trajectory-based simulation. For any quantum channel that consists of \(k\) Kraus operators, this approach considers \(k\) different trajectories - each corresponding to a different circuit where the channel is replaced by a corresponding Kraus operator. Each additional noise channel multiplies the number of possible trajectories by \(k\), thus for a large number of channels, a simulation cannot run every trajectory. Instead, the approach is to create an ensemble of \(K\) trajectories where each trajectory is added with probability corresponding to the probability of the Kraus operator.

Each circuit in the ensemble is then simulated using conventional noise-free methods and the outputs of each simulation are aggregated to form the final output. This is equivalent to running a regular circuit simulation with a probabilistic gate application at the locations of the noise channels.

Pauli frame simulation#

Pauli frame simulation applies the same principle as the trajectory-based simulation, but instead of simulating a quantum state, it tracks the effect of the noisy gates.

For example, in a trajectory with a noisy “X” gate on qubit 0, a traditional trajectory simulation would apply the gate to a statevector and proceed with other gates in the circuit. In Pauli frame simulation, the simulator records X0 in a Pauli frame - a string of Pauli operators. Then, the subsequent gates \(G_i\) are applied by conjugating the frame: \(P_{t+1} = G_i(P_t) = G_i^\dagger P_t G_i\). This simulation requires \(G_i\) to produce a Pauli string under conjugation, which is why it only supports Clifford gates.

Pauli frame simulation only tracks the difference between noise-free and noisy simulations, making it particularly useful for simulating circuits with a known noise-free state, such as error correction circuits that aim to preserve the all-zero state.

In the Pauli frame simulation, each frame is independent of the others, and thus can be simulated in parallel, which is the approach used by cuStabilizer.

Main data structures#

Bit tables#

A common encoding for Pauli operators is using two bits:

Pauli Operator

Encoding (x_bit, z_bit)

\(I\)

(\(0\), \(0\))

\(X\)

(\(1\), \(0\))

\(Z\)

(\(0\), \(1\))

\(Y\)

(\(1\), \(1\))

A single Pauli string on \(N\) qubits would be represented by \(2N\) bits.

To specify \(K\) Pauli frames on \(N\) qubits, we use two bit tables - matrixes of bits of size \(N \times K\): one for X bits and one for Z bits.

Overall the Pauli frame simulation acts on following data structures:

  1. Bit table for X bits - size \(N \times K\)

  2. Bit table for Z bits - size \(N \times K\)

  3. Bit table for measurement outcomes - size \(N \times M\) for \(M\) measurement instructions

Please refer to custabilizerFrameSimulatorApplyCircuit() for more details on how to specify the tables.

Circuit#

cuStabilizer uses a circuit specification format similar to Stim.

  • A Circuit is is a sequence of Instructions.

  • A circuit Instruction can be of different types. A simple gate instruction has a list of arguments and gate targets, while a REPEAT instruction points to another Circuit to repeat.

  • Instruction targets may refer to qubits or measurement outcomes, depending on the instruction type.

For example, the following circuit:

H 0 1 15
X_ERROR(0.01) 1 2
REPEAT 2 {
    CNOT 2 3 4 5
    DEPOLARIZE1(0.001) 4
    MX(0.1) 5 6 7
}

Is a valid circuit with

  • 16 qubits

  • 6 measurements with outcome noise probability 0.1

  • 4 CNOT gates

  • 3 H gates

  • 4 noisy gates

While cuStabilizer generally will accept any practical Stim circuit, there are important restrictions that may not be respected by a valid Stim circuit.

  1. Instruction targets must not overlap. E.g. instruction CX 0 1 2 4 is valid, but CX 0 1 1 2 is not.

  2. The depth of nested REPEAT instructions must not exceed 3.

Please refer to the Stim gate reference for more details on the supported instructions.

Supported circuit instructions#

  1. M - Measure on Z basis

  2. MX - Measure on X basis

  3. MY - Measure on Y basis

  4. MR - Measure on Z basis and reset

  5. MRX - Measure on X basis and reset

  6. MRY - Measure on Y basis and reset

  7. RZ - Reset on Z basis

  8. RX - Reset on X basis

  9. RY - Reset on Y basis

  10. H / H_XZ - Hadamard

  11. ZCX / CNOT - Controlled-X gate. Must have an even number of targets.

  12. CZ - Controlled-Z gate. Must have an even number of targets.

  13. PAULI_CHANNEL_1(p_x, p_y, p_z) - Pauli channel 1 with probabilities p_x, p_y, p_z

  14. PAULI_CHANNEL_2(p_x, ..., p_zz) - Pauli channel 2 with probabilities p_x, …, p_zz. Must have 15 arguments and an even number of targets.

  15. DEPOLARIZE1(p) - Depolarize 1 with probability p

  16. DEPOLARIZE2(p) - Depolarize 2 with probability p. Must have an even number of targets.

  17. X_ERROR(p) - X error with probability p

  18. Z_ERROR(p) - Z error with probability p

  19. REPEAT n {...} - Repeat a circuit n times

  20. TICK - No operation.

  21. DETECTOR - Detector instruction - experimental

Useful tips#

Environment variables for logging#

cuStabilizer uses the following environment variables to control C library logging:

  • CUSTABILIZER_LOG_LEVEL: Set the logging level verbosity. Supports the following values:

    • 0 - Off (no logging)

    • 1 - Error

    • 2 - Trace

    • 3 - Hint

    • 4 - Info

    • 5 - Debug

  • CUSTABILIZER_LOG_MASK: Control which categories of messages are logged.

  • CUSTABILIZER_LOG_FILE: Redirect log output to a file at the specified path instead of standard output.

Example usage:

export CUSTABILIZER_LOG_LEVEL=5
export CUSTABILIZER_LOG_FILE=custabilizer_debug.log

./my_application

These environment variables control logging from the cuStabilizer C library. Python users should also see Stabilizer APIs for Python-level logging options.

Citing cuQuantum#

  • H. Bayraktar et al., “cuQuantum SDK: A High-Performance Library for Accelerating Quantum Science,” 2023 IEEE International Conference on Quantum Computing and Engineering (QCE), Bellevue, WA, USA, 2023, pp. 1050-1061, doi: 10.1109/QCE57702.2023.00119.