Skip to main content

ci

Q# Resource Estimator for Alice & Bob's Architecture

This project estimates the amount of physical resources required to run quantum algorithms on Alice & Bob's quantum architecture, which uses cat qubits and repetition code as described in arXiv: 2302.06639 (LDPC codes might be added in the future).

The current version of the code specifically targets Shor's algorithm for solving the elliptic curve discrete logarithm problem and its subroutines. It improves the python project from which the results of the paper Phys. Rev. Lett. 131, 040602 (arXiv: 2302.06639) originate.

Big thanks to Mathias Soeken for the initial repository and for rebuilding the Microsoft Q# resource estimator to support our architecture.

This project mixes Rust and Python because the Q# resource estimator (QDK) is written in Rust, and we also want to support Qualtran, which is Python-only.

Python: CLI and library

pip install anb-estimator

This installs the anb-estimator CLI and the anb_estimator library. No Rust toolchain needed.

CLI

anb-estimator [OPTIONS] <COMMAND>. Run anb-estimator help for the full reference.

Commands:

  • resources <qubits> <cx> <ccx>: pass the pre-layout logical resource cost directly.
  • file <path-to-qsharp-file>: read it from a Q# file.

Global options (must appear before the command):

  • -f or --frontier: print a frontier of good parameter sets instead of a single estimate.
  • --json <file>: also write the computed estimate(s) as JSON to <file> (a single object, or an array with --frontier).
  • --error-budget <topological> <magic> <rotation>: detailed error split into 3 components.
  • --error-total <value>: overall error budget, equivalent to --error-budget <value>/2 <value>/2 0. Default 0.333.
  • --max-physical-qubits <n>: maximum number of physical qubits, for example the size of a target machine. The estimate is the fastest one that fits, so it can use more qubits than the estimate without this option. With --frontier, the frontier only has points that fit. Fails if no estimate fits.

Use either --error-total or --error-budget, not both.

Examples:

  • anb-estimator resources 40 10 10
  • anb-estimator --frontier file qsharp/Adder.qs
  • anb-estimator --json estimate.json resources 40 10 10
  • anb-estimator --max-physical-qubits 1300 resources 40 10000 10000

Library

from anb_estimator import estimate_logical_counts, estimate_qsharp_file, estimate_from_qualtran

estimate_from_qualtran takes a Qualtran Bloq, estimate_qsharp_file a Q# file, and estimate_logical_counts explicit (qubits, cx, ccx). See Program description for details on these three input forms.

All three take an optional max_physical_qubits, with the same behavior as the CLI option. They raise ValueError if no estimate fits.

Rust crate

This is a standard Cargo crate, and where the CLI actually lives. cargo build --release builds the library and the anb_estimator_cli binary. The anb-estimator Python command above is just a thin wrapper around this same code, with the same commands and options. Use it directly with cargo run -- (while developing) or anb_estimator_cli (once built), in place of anb-estimator.

The crate can also be used as a library in any Rust project. examples/elliptic_log.rs and examples/from_qsharp.rs show two ways to call it directly:

  • cargo run --example=elliptic_log: resources for the elliptic curve discrete logarithm problem (bit size 256, window size 18), as in arXiv:2302.06639.
  • cargo run --example=from_qsharp: equivalent to cargo run -- --error-budget 0.0005 0.0005 0.0 file qsharp/Adder.qs.

Working on this repo (Pixi)

Install Pixi, then run:

pixi install

This sets up Rust, Python, and the Python bindings, built with maturin and installed editable. After changing Rust code, rerun pixi install (or pixi run maturin develop for a faster incremental rebuild).

Run scripts with pixi run python script-name. For the walkthrough notebook (examples/getting_started.ipynb), use pixi run jupyter notebook: on Windows, anb_estimator may fail to import in the notebook if it isn't launched this way.

Program description

The program takes as input

  • a quantum algorithm described via its "pre-layout" logical resource cost in the sense of arXiv:2311.05801, i.e. (qubits, cx, ccx) where
    • qubits is the number of logical qubits,
    • cx and ccx are the numbers of expensive logical gates involved.
  • an "error budget" in the sense of arXiv:2311.05801, which represents the maximal logical error rates allowed for the target algorithm
  • optionally, a maximum number of physical qubits

Based on these, the purpose of the program is to predict the physical resource preparation conditions under which the target algorithm may eventually be executed on Alice & Bob’s proprietary architecture with an error rate consistent with the desired tolerance.

In practice, the machine’s execution costs, particularly energy costs, will depend heavily on the choice of easily adjustable machine parameters, such as the average number of photons per cat qubit, the distance of the repetition codes used to implement error correction, and the number of magic-state factories to provide. The program is precisely designed to calculate machine parameters that significantly reduce the combined product of the costs associated with parameter choices and the physical resource costs.

A physical resource cost, defined here as a number of physical qubits and a computation time on an Alice & Bob quantum machine, is computed at fixed parameters with Microsoft Azure Q# resource estimator. To do so, it uses the logical-to-physical mapping described in:

  • arXiv:2311.05801 for the base Q# Resource Estimator model,
  • arXiv:2302.06639 for Alice & Bob architecture parameters regarding the cat qubit (average number of photons $\alpha^2$), the repetition code (code distance), and the different choices of magic state factories allowed,
  • the function logical_depth from src/counter.rs for the logical_depths attributed to cx and ccx gates in the sense of arXiv:2311.05801, i.e. how many logical cycles are necessary for their executions.

The program's output then consists of:

  • Resources:
    • Total number of physical qubits
    • Runtime estimates
    • Number of magic state factories
    • Percentage of physical qubits involved in magic state production
  • Physical parameters (data qubits and magic state factories are considered separately):
    • Code distance
    • Cat-qubit parameters (average photon number)
  • Total error rate

The pre-layout logical resource cost input (qubits, cx, ccx) can be provided in three different ways:

  1. Qualtran Bloq (only via the python interface): Qualtran calculates (qubits, cx, ccx)
  2. Q# program: the interpreter extracts (qubits, cx, ccx)
  3. Explicit resources: you pass (qubits, cx, ccx) directly

Note that a few specific simplifying assumptions are performed in the estimation of arbitrary Q# or Qualtran code. In particular, one-qubit gates are assumed to cost nothing compared to controlled gates and each CZ gate is exactly worth one CNOT gate, see below for more information.

Supported gates and their costs

All cost assumptions made in this program have been designed with Shor's algorithm and its subroutines in mind. As such, they might not be relevant for the resource estimation of completely different algorithms.

In Q# code

Supported gates in Q# code cost in nb of cx cost in nb of ccx
ccx 0 1
cx, cy and cz 1 0
swap 3 0
supported one-qubit gates
(x, y, z, h, sadj, s )
0 0
measurements (m, mresetz & reset) 0 0

Using other gate types should result in a runtime error for being not implemented.

For further reading:

In Qualtran code

Supported gates in Qualtran code cost in nb of cx cost in nb of ccx
CNOT 1 0
Toffoli 0 1
TwoBitCSwap 2 1
C[CNOT] 0.5 0
And 0 1
And.adjoint() 0 0
any other qualtran gate 0 0

No error should be returned due to an unsupported gate since gates cost nothing if they do not appear in the table.

For further reading:

  • language syntax: Qualtran documentation
  • exact implementation of our rules: local file qualtran_interface.py
  • arguments behind the values in this table:
    • see arXiv: 2302.06639 appC.10 for the case of TwoBitCSwap
    • see arXiv: 2302.06639 app G.2 for the case of And gates with the application to adder circuits in mind
    • for C[CNOT], we assume the controlled bit to take a "random", unbiased value in practical applications in cryptography, hence C[CNOT] should apply CNOTs half of the time in average

Authors

  • Mathias Soeken (initial version of the repository)
  • Élie Gouzien
  • Nicholas Gialouris
  • Axel Pappalardo
  • Adel Ben Moussa
  • Mattéo Pappalardo

Metadata

Release files for anb-estimator 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anb-estimator 0.4.0
File Size Uploaded Provenance Actions
anb_estimator-0.4.0.tar.gz 2.5 MB With provenance Details for anb_estimator-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for anb-estimator 0.4.0
File Interpreter ABI Platform Actions
anb_estimator-0.4.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for anb_estimator-0.4.0-cp311-cp311-win_amd64.whl
anb_estimator-0.4.0-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details for anb_estimator-0.4.0-cp311-cp311-manylinux_2_28_x86_64.whl
anb_estimator-0.4.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for anb_estimator-0.4.0-cp311-cp311-macosx_11_0_arm64.whl

Total release size: 9.0 MB

Release files / anb_estimator-0.4.0.tar.gz

Download URL anb_estimator-0.4.0.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
b308fd986bd12638fb08faa18c594d39e9259f5fe767511b5d7734ea546889ad
BLAKE2b-256 checksum
How to use checksums
c64af0d75cf86246f2d728e6176262618163995283522fdbb19b90bf1e28c342
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / anb_estimator-0.4.0-cp311-cp311-win_amd64.whl

Download URL anb_estimator-0.4.0-cp311-cp311-win_amd64.whl
Size 2.1 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
c38870ac0380702638eafa71f7f23f185fd7084f0f09c925ba574494b8621b77
BLAKE2b-256 checksum
How to use checksums
28e91fba4d76cdf5842ea8b7752bf18f53281ae4fb611ff39f5d7733d87ee7de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / anb_estimator-0.4.0-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL anb_estimator-0.4.0-cp311-cp311-manylinux_2_28_x86_64.whl
Size 2.3 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
71794a0b2497451fa5081ac922647a0d2ebb6e812856f628795049d30f40ab04
BLAKE2b-256 checksum
How to use checksums
2840b1009e481830cb4e572b33b98c16064c5df54456eb35a0701c06203e174b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / anb_estimator-0.4.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL anb_estimator-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e397deaa880922236f9fdfabfc10966162f3b51e7c62cbb94cff106df8fc2f22
BLAKE2b-256 checksum
How to use checksums
4270ad40faa7d7505d265e67ecd4258b1a4958239bacef05de135cace126d7e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for anb-estimator 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for anb_estimator-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page