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.

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

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.

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

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.3.2

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.3.2
File Size Uploaded
anb_estimator-0.3.2.tar.gz 3.5 MB Details

Built distributions (wheels)

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

Total release size: 12.6 MB

Release files / anb_estimator-0.3.2.tar.gz

Download URL anb_estimator-0.3.2.tar.gz
Size 3.5 MB
Tags Source
SHA-256 checksum
How to use checksums
58bea29f03cbd53be7030dfc58a0b32abd64a6f21cd5742cb89a1d2f41016583
BLAKE2b-256 checksum
How to use checksums
4bc751e50a01de47ef030722294211f4c80147f80f821051d2208c18b98fe0c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 17, 2026.

Transparency log

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

Download URL anb_estimator-0.3.2-cp311-cp311-win_amd64.whl
Size 2.9 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
9ea691b52935d2f802ab88ff9418b3e733862fc664c3c4d4b2a02f1025029e85
BLAKE2b-256 checksum
How to use checksums
5ea0f6f8883fb08c437e2dd06b0992b1f3dfa9a6786e217d09822622cb07d2b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 17, 2026.

Transparency log

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

Download URL anb_estimator-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl
Size 3.3 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2d2ae1ecc633ca103cd485362281071de6377a485adb732a28bbc10cfd26ebd3
BLAKE2b-256 checksum
How to use checksums
8c3eabfbb3aeea0828c313059ba6dbc1a5bc6e24b7ab329719cf8329343ca129
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 17, 2026.

Transparency log

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

Download URL anb_estimator-0.3.2-cp311-cp311-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3e1b44bc5b93a808b8b14bd4be1de0883615396ebbd2a5a08755ae511e3cd181
BLAKE2b-256 checksum
How to use checksums
155512d4690bb45d60df561bc0af95a54be873a10d982217710bcd828239adfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 17, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.3

4 release files

This release

0.3.2 This release

4 release files

0.3.1

4 release files

0.3.0

4 release files

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