CudaQ extension for ParityOS
Project description
ParityOS CudaQ
ParityOS extension adding an interface to cudaq.
Installation
It is recommended to install this package in a separate Python virtual environment. For example:
# To create a standard Python virtual environment:
python -m venv my_new_venv && source my_new_venv/bin/activate
# Alternatively, to create a Anaconda/Miniconda environment:
conda create --name my_new_conda_env python=<version> && conda activate my_new_conda_env
# or a pyenv environment
pyenv virtualenv <version> my_new_venv && pyenv activate my_new_venv
# or a uv managed environment
uv venv -p <version>
where <version> is a python version and one of [3.11, 3.12, 3.13].
After activating the virtual environment, install via your favorite package manager, e.g.:
# using pip
pip install parityos-cudaq
# using uv
uv pip install parityos-cudaq
Exporter
parityos-cudaq offers an exporter of ParityOS to quantum circuits to the
Quake dialect .
from parityos.bits import get_q
from parityos.operators.circuit import Circuit
from parityos.operators.controlled_operator import CNOT
from parityos.operators.elementary_operator import H, Z
from parityos.operators.rotation_operator import RX
from parityos_cudaq.exporter import export_parityos_to_quake
# Create circuit qubits.
qubits = [get_q(name) for name in ("a", "b", "c")]
# Create the following circuit as sequence of gates, followed by a measurement of all qubits.
# ┌───────┐┌───┐┌───┐ ┌─┐
# qa: ┤ Rx(2) ├┤ H ├┤ Z ├───┤M├
# └───────┘├───┤└┬─┬┘ └╥┘
# qb: ─────────┤ X ├─┤M├─────╫─
# ┌───┐ └─┬─┘ └╥┘ ┌─┐ ║
# qc: ──┤ H ├────■────╫──┤M├─╫─
# └───┘ ║ └╥┘ ║
# c: 3/═══════════════╩═══╩══╩═
# 1 2 0
circuit = Circuit(
[
RX(qubits[0], 2),
H(qubits[0]),
H(qubits[2]),
CNOT(qubits[2], qubits[1]),
Z(qubits[0]),
]
).measure_all()
# Export to quake.
qiskit_result = export_parityos_to_quake(circuit, False)
print(qiskit_result.module)
# // Generated by ParityOS
# module {
# func.func @parityos_circuit() {
# // Allocate register
# %n_qubits = arith.constant 3 : i64
# %register = quake.alloca !quake.veq<?>[%n_qubits : i64]
# %q_0 = quake.extract_ref %register[0] : (!quake.veq<?>) -> !quake.ref
# %q_1 = quake.extract_ref %register[1] : (!quake.veq<?>) -> !quake.ref
# %q_2 = quake.extract_ref %register[2] : (!quake.veq<?>) -> !quake.ref
#
# %angle_0 = arith.constant 2.0 : f64
# quake.rx (%angle_0) %q_0 : (f64, !quake.ref) -> ()
# quake.h %q_0 : (!quake.ref) -> ()
# quake.h %q_2 : (!quake.ref) -> ()
# quake.x [%q_2] %q_1 : (!quake.ref, !quake.ref) -> ()
# quake.z %q_0 : (!quake.ref) -> ()
# %m_result_0 = quake.mz %q_0 : (!quake.ref) -> !quake.measure
#
# %m_result_1 = quake.mz %q_1 : (!quake.ref) -> !quake.measure
#
# %m_result_2 = quake.mz %q_2 : (!quake.ref) -> !quake.measure
#
# return
# }
# }
print(qiskit_result.qubit_map) # Maps ParityOS qubits to quake Qubit integer labels
# {Qubit(id='a'): 0, Qubit(id='b'): 1, Qubit(id='c'): 2}
License
This software package is made available under the 3-Clause BSD License.
See License.txt for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file parityos_cudaq-0.1.0.tar.gz.
File metadata
- Download URL: parityos_cudaq-0.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8da5f3a5873cbf7ebf991432d178ffc3eea049dbbccfcdeaabea687bd6032ad9
|
|
| MD5 |
c4a33dff4783b4e673e8562928f0993b
|
|
| BLAKE2b-256 |
dfc555f3af3d26545a09a2132ae74af1df87a3a05287a8de7675a5578e2fd3ea
|
File details
Details for the file parityos_cudaq-0.1.0-py3-none-any.whl.
File metadata
- Download URL: parityos_cudaq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5725a17dc70dc98fdfd3379ebf5e15bcdf40929f96d32e4e7cc24382dfaf9ed
|
|
| MD5 |
5a54bd76beb1d10c5cd700e4a6d5abe0
|
|
| BLAKE2b-256 |
31360be692aff71343ed8adaa00706dc6497a22703a12d3f588fa86d5a36c4a6
|