The Unitary Compiler Collection (UCC) is a Python library for frontend-agnostic, high performance compilation of quantum circuits.
UCC interfaces automatically with multiple quantum computing frameworks, including Qiskit, Cirq, and PyTKET and supports programs in OpenQASM 2 and OpenQASM 3. For a full list of the latest supported interfaces, just call ucc.supported_circuit_formats
.
Want to know more?
- Check out our documentation, which you can build locally after installation by running
make html
inucc/docs/source
. - For code, repo, or theory questions, especially those requiring more detailed responses, submit a Discussion.
- For casual or time sensitive questions, chat with us on Discord.
Note: UCC requires Python version ≥ 3.12.
pip install ucc
If developing or running benchmark, please install Poetry, then setup a dev version:
git clone https://github.com/unitaryfund/ucc.git
cd ucc
poetry install
Define a circuit with your preferred quantum SDK and compile it!
from ucc import compile
from pytket import Circuit as TketCircuit
from cirq import Circuit as CirqCircuit
from qiskit import QuantumCircuit as QiskitCircuit
from cirq import H, CNOT, LineQubit
def test_tket_compile():
circuit = TketCircuit(2)
circuit.H(0)
circuit.CX(0, 1)
compile(circuit)
def test_qiskit_compile():
circuit = QiskitCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
compile(circuit)
def test_cirq_compile():
qubits = LineQubit.range(2)
circuit = CirqCircuit(
H(qubits[0]),
CNOT(qubits[0], qubits[1]))
compile(circuit)
We run benchmarks regularly to compare against the most recent versions of the most popular quantum compiler frameworks for a range of circuits. Here's the latest:
In addition to raw compilation stats, we simulate the compiled circuits with a noisy density matrix simulation to see how each compiler impacts performance.
Here we plot the absolute errors
And here you can see progress over time, with new package versions labeled for each compiler:
Note that the compile times before 2024-12-10 may have been run on different classical compute instances, so their runtime is not reported here, but you can find this data in benchmarks/results.
After 2024-12-10, all data present in this plot is on the same compute instance using our ucc-benchmarks GitHub Actions workflow.
You can benchmark the performance of ucc against other compilers using ./ucc/benchmarks/scripts/run_benchmarks.sh
. This script runs compiler benchmarks in parallel, so you will need to first install parallel
to support it. If you setup ucc
via poetry
as recommended, either run the scripts after running poetry shell
or prefix the script calls with poetry run
.
On Mac you can do this with brew install parallel
.
We’re building UCC as a community-driven project. Your contributions help improve the tool for everyone! There are many ways you can contribute, such as
- Create a Custom Compiler Pass: Learn how in the User Guide
- Submit a bug report or feature request: Submit a bug report or feature request on GitHub.
- Contribute Code: Follow the Contribution Guide to submit new passes and improvements.
If you have questions about contributing please ask on the Unitary Foundation Discord.
UCC is distributed under GNU Affero General Public License version 3.0(AGPLv3). Parts of ucc contain code or modified code that is part of Qiskit, which is distributed under Apache 2.0 license.