Skip to main content

Unitary Compiler Collection: A quantum circuit interface and compiler for multiple quantum frameworks

Project description

ucc: Unitary Compiler Collection

Repository Unitary Foundation Documentation Status Discord Chat

The Unitary Compiler Collection (UCC) is a Python library for frontend-agnostic, high performance compilation of quantum circuits. UCC's goal is to gather together the best of open source compilation to make quantum programming simpler, faster, and more scalable.

By leveraging qBraid, 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 in ucc/docs/source.
  • Read the launch announcement to learn more on the current state of UCC, its capabilities and future direction.
  • 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.

Quickstart

Installation

Note: UCC requires Python version ≥ 3.12.

pip install ucc

If developing or running benchmarks, please install Poetry, which is used to managed dependencies. Then setup a dev version via:

git clone https://github.com/unitaryfund/ucc.git
cd ucc
poetry install

For any subsequent commands mentioned in the docs, we assume you either prefix each command with poetry run, or you first activate the poetry managed virtual environment by running the output of poetry env activate in your shell.

Example with Qiskit, Cirq, and PyTKET

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)

How does UCC stack up?

UCC seeks to provide an end-to-end compiler that works well for the majority of the users out of the box. Today, this is achieved by running a particular subset of Qiskit transpiler passes. To ensure we continue to improve performance and meet user needs, we regularly run benchmarks comparing UCC against the latest versions of leading quantum compiler frameworks across a range of circuits. Here’s the latest: alt text

And here you can see progress over time, with new package versions labeled for each compiler: alt text where pytket-peep indicates the FullPeepHoleOptimize function of PyTKET. 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.

To learn more about running these benchmarks, the overall benchmark philosophy, or how to contribute to improving the benchmarking methodology, check out the benchmarking section in the docs.

Contributing

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.

License

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 or Qiskit Benchpress, which are distributed under the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ucc-0.4.4.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ucc-0.4.4-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file ucc-0.4.4.tar.gz.

File metadata

  • Download URL: ucc-0.4.4.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ucc-0.4.4.tar.gz
Algorithm Hash digest
SHA256 19f476db84e951d59a0c7985c55aacbeaac0b05429301f25ca438c14fd696262
MD5 3ab63f5f2bc81e01c9cd7a6da39e12d8
BLAKE2b-256 433ce7002a8b69dd1b43686fc5ca9fe92a055dea9682a359204f5872c8ad0985

See more details on using hashes here.

Provenance

The following attestation bundles were made for ucc-0.4.4.tar.gz:

Publisher: python-publish.yml on unitaryfund/ucc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ucc-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: ucc-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ucc-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 72a5646bdc7aa281f69220d0a054e95979aa976bc9e0789e43210c0d5763e06f
MD5 345b231edcf586251434dfa7bfd3ce0a
BLAKE2b-256 afcfe425947a1ece184358bb7d52e6347739b9445fce527e732ccab4633ac75f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ucc-0.4.4-py3-none-any.whl:

Publisher: python-publish.yml on unitaryfund/ucc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page