Skip to content

Repository files navigation

Active volume compiler: magic-state factory-ratio optimization

A running quantum algorithm spends most of its physical qubits not on data, but on the magic-state factories that distill the non-Clifford (T) resources it consumes. Provision too few and the computation stalls waiting for magic states; provision too many and idle factory tiles bloat the footprint. This repo compiles a Clifford+T circuit into a surface-code lattice-surgery layout, schedules the factories against the circuit's T-demand, and optimizes the factory ratio to minimize spacetime volume.

This is repo 10 of a ten-part QEC research portfolio. Where fault-tolerance-economics reproduces an algorithm-level resource estimate, this repo works one level down, at the layout-and-scheduling trade-off that turns a logical circuit into a physical-qubit budget.

Results at a glance

Spacetime volume versus number of magic-state factories, showing a clear minimum.

Spacetime volume (physical qubits × runtime cycles) versus factory count for a T-heavy benchmark. Volume falls steeply while the computation is factory-limited, bottoms out at the optimum (here 361 factories), then rises as additional idle factories only add area.

Runtime split into factory-limited and logic-limited regimes, crossing at the optimum.

The runtime is the maximum of the factory-limited time (orange, ∝ 1/factories) and the logic-limited floor (green). The volume-optimal factory count sits exactly at the crossover, where buying more factories stops shortening the runtime.

Scope

  • Compiler pass: a Clifford+T circuit is scheduled as-soon-as-possible to extract the quantities that drive cost — T-count, T-depth, peak parallel T-demand, and logical depth.
  • An explicit architecture model: logical data, routing, and factories are costed in surface-code tiles (2 d^2 physical qubits each); factories produce one T-state every ~5.5 d cycles.
  • Factory-ratio optimization: the factory ratio that minimizes spacetime volume is an interior minimum, found by scanning and located at the factory/logic crossover.

Cost model

Quantity Model
Physical qubits per logical tile 2 d^2
Data + routing footprint routing_tiles_per_qubit × logical qubits
Factory footprint factory_tiles per factory
Factory throughput one T-state per ~5.5 d cycles
Logic runtime logical_depth × d cycles
Factory runtime t_count × period / num_factories cycles
Runtime max(logic, factory) cycles
Spacetime volume physical qubits × runtime cycles

Every parameter is overridable in HardwareSpec.

Install

pip install -e ".[dev]"

Quick start

pytest
python examples/compile_adder.py   # writes docs/{volume_vs_factories,runtime_breakdown}.png
avcompile compile --tbench 200 --t-layers 5000 --distance 15
avcompile compile --adder 64
avcompile scan --adder 64 --output outputs/scan.json

Library usage

from avcompiler import HardwareSpec, analyze_circuit, optimize_factories, ripple_carry_adder

circuit = analyze_circuit(ripple_carry_adder(64))
result = optimize_factories(circuit, HardwareSpec(code_distance=15))
best = result.best
print(best.num_factories, best.physical_qubits, best.wall_clock_seconds)

Scope and limitations

This is an architecture-level estimator, not a placement-and-routing compiler. It models the factory/data trade-off with a first-order cost model; it does not lay out individual patches, schedule lattice-surgery operations cycle by cycle, or implement Litinski's full active-volume accounting. The defaults are order-of-magnitude values from the literature and are meant to make the shape of the trade-off — and the existence of a volume-optimal factory ratio — reproducible, not to certify a specific device's qubit count.

Layout

  • src/avcompiler/circuits.py — Clifford+T circuit, ASAP scheduler, example generators
  • src/avcompiler/resources.py — footprint and runtime model
  • src/avcompiler/optimize.py — factory-count scan and volume minimizer
  • src/avcompiler/types.pyCircuitSpec, HardwareSpec, estimate records
  • src/avcompiler/viz/plots.py, cli.py
  • examples/compile_adder.py

References

  • Fowler AG, Mariantoni M, Martinis JM, Cleland AN. Surface codes: towards practical large-scale quantum computation. Physical Review A 2012; 86:032324.
  • Litinski D. A game of surface codes: large-scale quantum computation with lattice surgery. Quantum 2019; 3:128.
  • Litinski D. Magic state distillation: not as costly as you think. Quantum 2019; 3:205.
  • Litinski D, Nickerson N. Active volume: an architecture for efficient fault-tolerant quantum computers. arXiv 2022; 2211.15465.

License

MIT — see LICENSE.

About

A fault-tolerant resource compiler: map a Clifford+T circuit to a surface-code lattice-surgery layout and optimise the magic-state factory ratio to minimise spacetime volume.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages