QCC: the Quantum Compiler Collection
A technology-agnostic quantum circuit compiler, part of the Qevedo packages:
it installs as qevedo-compiler and imports as qevedo.compiler.
Install
pip install qevedo-compiler
For development, from a checkout (this builds the Rust core, so it needs a Rust toolchain, from https://rustup.rs):
cd qcc/python
pip install -e ".[dev]" # or: maturin develop --release
The Rust core lives in ../core (cargo test --release there runs its own
tests); src/ holds its Python bindings.
openqasm 3.x is installed from PyPI. To develop both together, also install
the sibling checkout: pip install -e ../../openqasm.
Usage
qcc compile examples/bell.qasm -o /tmp/out.qasm --device qevedo/compiler/profiles/all_to_all.yaml
qcc compile program.qasm -o /tmp/out.qasm --qasm-version 3 -I lib/
From Python:
from qevedo.compiler import compile_source, emit_qasm
circuit = compile_source(open("examples/bell.qasm").read())
print(emit_qasm(circuit))
The reference device profiles ship with the package, in
qevedo/compiler/profiles/.
Input can be OpenQASM 2 or 3. Programs are checked by openqasm.analyze
before lowering, so errors are reported with their location. The frontend
supports qubit and bit registers, gate calls with constant parameters
(broadcast over registers), measurements, resets, barriers, let aliases of
qubits and const values. Control flow, gate modifiers, classical variables,
timing and hardware qubits are rejected with an error until the IR supports
them. Gates defined by the program (or its own include files) are expanded
into their bodies; gates from qelib1.inc and stdgates.inc stay named so
the compiler can lower them optimally.
Lowering to native gates
compile_source and compile_file rewrite every gate into the device
profile's native_gates, with the fewest gates:
- single-qubit gates through an Euler decomposition into the device's
single-qubit basis (
rz+sx,rz+rx,rz+ry,rx+ryoru3); - two-qubit gates through a KAK decomposition into the device's two-qubit
gate (
cx,cz,cy,ch,ecr,rxx,ryy,rzzorrzx), using the minimal number of two-qubit gates (at most 3; on acxdevice, 1 forcz, 2 forcrzand 3 forswap); - standard gates with a shorter textbook definition, and gates on three or more qubits, through their definitions.
After lowering, the circuit is optimized: rotations acting on the same
parity of the qubits are merged however far apart they are (phase folding),
single-qubit runs are merged, gates cancel or merge across gates they
commute with, and every run of gates on one pair of qubits is resynthesized
as a single two-qubit unitary when that is cheaper, choosing among equally
short syntheses the one with the fewest gates inside the block. Two-qubit
interactions whose removal costs less than 10⁻⁹ in average gate infidelity
are dropped, as Qiskit's default does. On a benchmark of 21 circuits (QFT,
QAOA, Quantum Volume, GHZ, Heisenberg, adders, Clifford+T) this uses 0.968×
the two-qubit gates of Qiskit's optimization_level=3 and 0.901× its gates
in all, and no more of either on any circuit
(benchmarks/compilation).
SWAP gates are removed by relabelling the qubits after them, and blocks that
are a SWAP away from fewer CX are synthesized that way, whenever the moved
qubits are measured last, so that the output is equivalent. With
CompileOptions(relabel_outputs=True) (qcc compile --relabel-outputs)
QCC does so for any circuit, as Qiskit does, and the result's
output_permutation says on which wire each qubit's state ends. On a device
that is not all-to-all, see below.
from qevedo.compiler import CompileOptions, compile_source
from qevedo.compiler.device import DeviceSpec
ion_trap = DeviceSpec(name="ions", topology="all_to_all", qubits=4,
native_gates={"rx", "ry", "rxx"})
circuit = compile_source(open("program.qasm").read(), CompileOptions(device=ion_trap))
print(circuit.gate_counts())
Compiling for a device
For a device whose qubits are not all coupled, give its couplings: QCC optimizes the circuit, places it (with no SWAP at all when the circuit's pairs fit the chip), routes it with SABRE, counting each SWAP for what it costs once merged with the gates next to it, and optimizes it again on the physical qubits, turning gates around on devices whose couplings have a direction.
from qevedo.compiler import CompileOptions, compile_source
from qevedo.compiler.device import DeviceSpec
chip = DeviceSpec(name="line", topology="linear_chain", qubits=5,
edges=[(0, 1), (1, 2), (2, 3), (3, 4)],
native_gates={"rz", "sx", "x", "cz"})
circuit = compile_source(open("program.qasm").read(), CompileOptions(device=chip))
print(circuit.initial_layout, circuit.output_permutation) # where each qubit starts and ends
The result is on the device's physical qubits (a register q), and
qcc compile --device profile.yaml prints both layouts. On a 19-qubit
heavy-hex chip, QCC alone uses 5–6% fewer two-qubit gates than Qiskit's
optimization_level=3 and 12–17% fewer gates in all
(benchmarks/compilation).
Inside Qiskit
From version 0.2.1, with Qiskit installed (pip install qevedo-compiler[qiskit]), QCC is also
an optimization stage for Qiskit's transpiler: Qiskit lays out, routes and
translates the circuit, and QCC optimizes it.
from qiskit import transpile
compiled = transpile(circuit, backend, optimization_method="qcc")
On a 19-qubit heavy-hex chip with CX gates, this uses 3% fewer two-qubit gates than Qiskit's level 3 and 14% fewer gates in all (61% on a QFT); with CZ gates, 9% fewer gates in all; see benchmarks/compilation.
Multi-core architectures
qevedo.compiler.multicore compiles circuits for modular quantum computers
made of several cores joined by quantum links, in Rust:
- mapping: before each timeslice, which core every qubit is in, with as few teleportations as possible: Hungarian Qubit Assignment (HQA, Escofet et al.), FGP-rOEE and a naive mapper, on cores linked all to all, in a line, a ring, a grid or any connected way;
- routing inside the cores (
map_and_route): each core routed on its own coupling graph with SABRE, giving a circuit on physical qubits with SWAPs and teleportations, optionally through fixed communication qubits (ports); - timing: how long the circuit takes when links make EPR pairs a few at
a time, and
"hqa-latency", an HQA that plans for it.
from qevedo.compiler.multicore import Timing, map_and_route, map_to_cores
mapping = map_to_cores(open("circuit.qasm").read(), cores=4, qubits_per_core=10)
print(mapping.communications) # teleportations
result = map_and_route(open("circuit.qasm").read(), cores=4, qubits_per_core=9,
chip="grid:3x3", topology="line", ports="central",
method="hqa-latency", timing=Timing(link_capacity=2))
print(result.teleportations, result.swaps, result.schedule().duration)
It reproduces Escofet et al.'s comparison (HQA needs 1.24× fewer teleportations than FGP-rOEE), and on TeleSABRE's own device and circuits, HQA with ports uses 0.26× its EPR pairs and 0.51× its SWAPs. See docs/MULTICORE.md for the model, the methods and every benchmark.
Tests
pytest
Metadata
Release files for qevedo-compiler 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qevedo_compiler-0.3.0.tar.gz | 170.0 kB | With provenance | Details for qevedo_compiler-0.3.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| qevedo_compiler-0.3.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for qevedo_compiler-0.3.0-cp310-abi3-win_amd64.whl |
| qevedo_compiler-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for qevedo_compiler-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| qevedo_compiler-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details for qevedo_compiler-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| qevedo_compiler-0.3.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for qevedo_compiler-0.3.0-cp310-abi3-macosx_11_0_arm64.whl |
| qevedo_compiler-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details for qevedo_compiler-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl |
Total release size: 3.3 MB
Release files / qevedo_compiler-0.3.0.tar.gz
| Download URL | qevedo_compiler-0.3.0.tar.gz |
|---|---|
| Size | 170.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efad7f83126b403cad1a15db916f5a1c76e5c9e1f99041371207ec1962651714
|
|
BLAKE2b-256 checksum How to use checksums |
cb076d07e931f97dc0c45eb6c7814752310a0d54b15b0ee2cd8a5e7c08013f76
|
| 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 Oct 19, 2026.
Transparency logRelease files / qevedo_compiler-0.3.0-cp310-abi3-win_amd64.whl
| Download URL | qevedo_compiler-0.3.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 560.0 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d55de6b3d626e37727bebd7bc910c2c8fff516c54857525b54ce6b1fb63c27c6
|
|
BLAKE2b-256 checksum How to use checksums |
6dcb1cea230e7e6b91836f88195d819c37e8db6a12296ae6c364133a60c4ff65
|
| 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 Oct 19, 2026.
Transparency logRelease files / qevedo_compiler-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | qevedo_compiler-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 666.2 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5ad71bc9006a07a04614af61ff58d7510c3d61d85de911e3e5283335d1b6c33c
|
|
BLAKE2b-256 checksum How to use checksums |
32ac9af2a8f3e4428d35026efd18854489b83a40c7733881dd78ac192d2990cf
|
| 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 Oct 19, 2026.
Transparency logRelease files / qevedo_compiler-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | qevedo_compiler-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 638.6 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
54d42dcf6572d45020f9bc320d4a3a02a11976ba90b656e8087f3ee35eace304
|
|
BLAKE2b-256 checksum How to use checksums |
11507886c192061b9bbb62736e03af4802d1befc73ff6b7e6d0a1ae88fb39b9e
|
| 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 Oct 19, 2026.
Transparency logRelease files / qevedo_compiler-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | qevedo_compiler-0.3.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 592.6 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
35609539c747679ceace5003acb14bceec1dd2be99043d3b780e91d1b1d3ed01
|
|
BLAKE2b-256 checksum How to use checksums |
a3c7da12e2c170782ccff78e91ba6f29df79fe4d92d0986b3bf1b360135d55ff
|
| 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 Oct 19, 2026.
Transparency logRelease files / qevedo_compiler-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | qevedo_compiler-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 625.5 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
9df2a63310c0ee60fbcb8abbb803bba6f11e59309b18a331858a2ab23dfb7513
|
|
BLAKE2b-256 checksum How to use checksums |
068f67696d717276046dce7b82d89ee7f47e5a94b5d4fa9372a36a7b04806542
|
| 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 Oct 19, 2026.
Transparency logSecurity for qevedo-compiler 0.3.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 6 files in this release have been uploaded with provenance metadata.
Attestation for qevedo_compiler-0.3.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 Oct 19, 2026.
Transparency logA 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.