Metadata-Version: 2.4
Name: bicycle_architecture_compiler
Version: 0.1.0
Summary: Resource estimation for the Tour de Gross fault-tolerant architecture
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/qiskit-community/bicycle-architecture-compiler
Project-URL: Issues, https://github.com/qiskit-community/bicycle-architecture-compiler/issues
Keywords: quantum,quantum computing,fault-tolerant quantum computing,ftqc,resource estimation,quantum resource estimation,gross code,tour de gross
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Rust
Classifier: Topic :: Scientific/Engineering :: Quantum Computing
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Software Development :: Compilers
Classifier: Development Status :: 3 - Alpha
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: qiskit>=2.5
Dynamic: license-file

# Bicycle Architecture Compiler

[Tour de Gross arXiv:2506.03094](https://arxiv.org/abs/2506.03094) presents the Bicycle Architecture - a modular architecture for fault-tolerant quantum computation based on bivariate bicycle codes. The analysis features:

 - A universal Instruction Set Archirecture (ISA) of logical gates in bivariate bicyle codes
 - Circuit-level noise benchmarks of all the ISA instructions
 - An end-to-end compilation scheme from Pauli-Based Computation (PBC) to the bicycle ISA

This compiler prototype implements and benchmarks this end-to-end compilation scheme so that it may inform future Qiskit development for fault-tolerant architectures.
Some example use cases are:
 - Random PBC circuits as a form of worst-case Clifford+T quantum circuits. See [`./notebooks/random_circuits.ipynb`](./notebooks/random_circuits.ipynb)
 - User-specified PBC circuits supporting arbitrary-angle rotations, see [`./notebooks/custom_circuits.ipynb`](./notebooks/custom_circuits.ipynb)
 - Qiskit circuits to Gross code ISA, see [`./scripts/qiskit_demo.sh`](./scripts/qiskit_demo.sh)

## Installation

This software is tested on some Linux and macOS platforms.

### Rust

We recommend using [rustup](https://www.rust-lang.org/tools/install) to install a rust toolchain.
Then run
```sh
shell> cargo build --release
```
Binaries are built and placed in `./target/release/`.
In the documentation we use these binaries without including their (relative) path.
Alternatively, you can use `cargo run --release --package <packageName> -- <arguments>`.

### Gridsynth

Angles other than $\pm\pi/4$ are synthesized with the built-in [rsgridsynth](https://github.com/qiskit-community/rsgridsynth) library.
No external `gridsynth` installation is required.

### Optional dependencies

To run the notebooks,
we require the packages `numpy`, `matplotlib`, and `jupyter`.
These can be installed via
```sh
shell> pip install -r optional_dependencies.txt
```

Furthermore, the following commandline applications are helpful and may be required for some functionality:
* `jq` - commandline JSON processor, or parsing JSON to a newline-delimited input.
* GNU `parallel` in order to
  run [./scripts/run_random_numerics.sh](./scripts/run_random_numerics.sh) in parallel.

### Python interface

A minimal Python interface is provided as `bicycle_architecture_compiler` package,
which can be locally installed via 
```sh
shell> pip install .
```
Note that installing in editable mode compiles the Rust crates in debug mode, which can be
rebuilt in release mode via
```sh
shell> python setup.py build_rust --inplace --release
```

## Usage

This Rust workspace consists of many Rust crates (packages) that can be used either as library
or, in many cases, also as a binary.
The contents of the repository as summarized as follows.

```
pbc-compiler/
├── analysis/                      # Python modules for postprocessing and steering
├── scripts/                       # Scripts for generating data (has some overlap with analysis)
├── notebooks/                     # Notebook for running and plotting a random circuit experiment.
├── data/                          # Cached measurement tables, and random circuit data
└── crates/
    ├── bicycle_common/            # Common definitions. Bicycle instructions.
    ├── bicycle_benchmark/         # Random generation of PBC circuits
    ├── bicycle_cliffords/         # Clifford gate implementation via search
    ├── bicycle_compiler/          # PBC to bicycle circuit compiler
    ├── bicycle_numerics/          # Additive noise estimates and stats collection
    ├── bicycle_random_numerics/   # Benchmarking via random PBC circuits
    └── pyext/                     # Python FFI (not included in the default workspaces)
```

Each crate has more info in their respective READMEs.

Many binary crates can be used via their compiled binaries (obtained by `cargo build` or `cargo run --package <package>`).
For an example workflow that generates benchmarks see [scripts/README.md](scripts/),
and more advanced examples are illustrated by Jupyter notebooks in `./notebooks/`.


### Testing

**Rust**

To test in release mode, run

```sh
shell> cargo test --release
```

The script [./scripts/local_QA.sh](./scripts/local_QA.sh) runs quality assurance tests locally.
This includes test, rustfmt, and clippy.

**Python**

To test the Python bindings and lint the tests, run the following after having installed
the package

```sh
shell> make lint
shell> make test
```


