factories Package

Classes

GSJ24CCXFactory

Implements the 8|T⟩ → >>|<<CCX⟩ magic state factory described in Fig. 24 of Gidney, Shutty, and Jones (2024). This design converts eight T magic states into a single CCX (Toffoli) state using lattice surgery operations on 12 logical qubits (including helper qubits) with a circuit depth of 6.

The output CCX error rate has two contributions:

  • Distillation error: 28 · p_T², where p_T is the T state error rate (from pairs of T states failing simultaneously).

  • Logical error: accumulated over 6 lattice surgery rounds on 12 qubits.

The factory production time includes an overhead factor of (1 + 8·p_T) to account for the failure probability when consuming the T states.

Reference:

  • C. Gidney, C. Shutty, C. Jones, "Magic state cultivation: growing T states with 78% reduced overhead", arXiv:2409.17595 (2024). https://arxiv.org/abs/2409.17595

  • C. Gidney, A. G. Fowler, "Efficient magic state factories with a catalyzed >>|<<CCZ⟩ to 2|T⟩ transformation", Quantum 3, 135 (2019). arXiv:1812.01238. https://arxiv.org/abs/1812.01238

GSJ24Factory

Implements the magic state cultivation factory from Gidney, Shutty, and Jones (2024) for producing logical >>|<<T⟩ states from physical-level operations.

Magic state cultivation gradually grows the size and reliability of a magic state within a surface code patch, using roughly the same number of physical gates as a lattice surgery CNOT gate of equivalent reliability. The approach refines ideas from Knill (1996), Jones (2016), Chamberland (2020), Gidney (2023/2024), Bombin (2024), and Hirano (2024).

Compared to prior magic state distillation approaches, cultivation uses an order of magnitude fewer qubit-rounds to reach logical error rates as low as 2·10⁻⁹ under 10⁻³ uniform depolarizing circuit noise. Halving the circuit noise to 5·10⁻⁴ improves the achievable logical error rate to 4·10⁻¹¹.

The factory is parameterized by pre-computed simulation data (from Monte Carlo sampling at https://doi.org/10.5281/zenodo.13777072) that maps physical error rates to (logical_error, num_qubits, volume, steps) tuples for supported distance pairs.

Hyper parameters: distance: Tuple (d_color, d_surface) specifying the color code distance and surface code distance used in the cultivation protocol. Supported values are (3, 15) and (5, 15). Larger color code distance (5 vs 3) yields lower logical error rates at the cost of higher qubit count and more time steps.

Reference:

Litinski19Factory

T and CCZ factories based on the paper arXiv:1905.06903.

It contains two categories of estimates. If the input T error rate is similar to the Clifford error, it produces magic state instructions based on Table 1 in the paper. If the input T error rate is at most 10 times higher than the Clifford error rate, it produces magic state instructions based on Table 2 in the paper.

It requires Clifford error rates of at most 0.1% for CNOT, H, and MEAS_Z instructions. If these instructions have different error rates, the maximum error rate is assumed.

References:

  • Daniel Litinski: Magic state distillation: not as costly as you think, arXiv:1905.06903
MagicUpToClifford

An ISA transform that adds Clifford equivalent representations of magic states. For example, if the input ISA contains a T gate, the provided ISA will also contain SQRT_SQRT_X, SQRT_SQRT_X_DAG, SQRT_SQRT_Y, SQRT_SQRT_Y_DAG, and T_DAG. The same is applied for CCZ gates and their Clifford equivalents.

Example:

RoundBasedFactory

A magic state factory that produces T gate instructions using round-based distillation pipelines.

This factory explores combinations of distillation units (such as "15-to-1 RM prep" and "15-to-1 space efficient") to find optimal configurations that minimize time and space while achieving target error rates. It supports both physical-level distillation (when the input T gate is physically encoded) and logical-level distillation (using lattice surgery via surface codes).

In order to account for the success probability of distillation rounds, the factory models the pipeline using a failure probability requirement (defaulting to 1%) that each round must meet. The number of distillation units per round is adjusted to meet this requirement, which in turn affects the overall space requirements.

Space requirements are calculated using a user-provided function that aggregates per-round space (e.g., sum or max). The sum function models the case in which qubits are not reused across rounds, while the max function models the case in which qubits are reused across rounds.

For the enumeration of logical-level distillation units, the factory relies on a user-provided ISAQuery (defaulting to SurfaceCode.q()) to explore different surface code configurations and their corresponding lattice surgery instructions. These need to be provided by the user and cannot automatically be derived from the provided implementation ISA, as they can only contain a subset of the required instructions. The user needs to ensure that the provided query matches the architecture for which this factory is being used.

Results are cached to disk for efficiency.

References:

  • Sergei Bravyi, Alexei Kitaev: Universal Quantum Computation with ideal Clifford gates and noisy ancillas, arXiv:quant-ph/0403025

  • Michael E. Beverland, Prakash Murali, Matthias Troyer, Krysta M. Svore, Torsten Hoefler, Vadym Kliuchnikov, Guang Hao Low, Mathias Soeken, Aarthi Sundaram, Alexander Vaschillo: Assessing requirements to scale to practical quantum advantage, arXiv:2211.07629