dwave-gate
dwave-gate provides the functionality for generating quantum circuit description language (QCDL) programs. QCDL is an embedded domain-specific language (DSL) that uses Python as its host language, allowing you to interleave classical Python preprocessing with quantum gate operations. Programs are defined with the @qcdl decorator, which converts an ordinary Python function into a QCDL program generator that accepts qubit arguments and returns a dictionary suitable for submission to compiler or simulator services.
The following example creates a Bell state circuit, producing a dictionary that can be passed to a compiler or simulator:
from dwave.gate.qcdl import qcdl
from dwave.gate.qcdl.operations import cx, h, measure
@qcdl(num_qubits=2)
def main(q0, q1):
h(q0) # Hadamard gate on q0
cx(q0, q1) # CNOT with q0 as control, q1 as target
measure(q0)
measure(q1)
qcdl_program = main()
To run the program on a solver, use the Ocean SDK’s cloud client to locate a solver that supports QCDL and submit the dictionary via sample_qcdl:
import orjson
from dwave.cloud import Client
from dwave.gate.results import Result
client = Client.from_config()
solver = client.get_solver(supported_problem_types__contains="qcdl")
response = solver.sample_qcdl(qcdl_program, shots=3)
answer = orjson.loads(response.answer_data.read())
result = Result(**answer)
Access measurements and sample counts by calling result.measurements or result.get_counts() respectively.
Installation
Installation from PyPI:
pip install dwave-gate
Installation from source:
pip install .
Development setup
Install development requirements and the package in editable mode:
pip install --group dev
pip install --editable .
Tests require the test dependency group:
pip install --group test
python -m pytest
License
Released under the Apache License 2.0. See LICENSE file.
Contributing
Ocean’s contributing guide has guidelines for contributing to Ocean packages.
Release Notes
We use reno to manage release notes.
See reno’s user guide for details.
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 dwave_gate-0.4.0.tar.gz.
File metadata
- Download URL: dwave_gate-0.4.0.tar.gz
- Upload date:
- Size: 104.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9895ecdf03b55cfea1ccaf4bdcf6d730c032543e4013e6e74a2b2ab11ab0a55
|
|
| MD5 |
f0a4e9b10b48c7f7ce6fdfd11e49a73b
|
|
| BLAKE2b-256 |
66513d052a8a2eb5a51db577e4bf9d037a902791fdee25cc934d15fd01203213
|
File details
Details for the file dwave_gate-0.4.0-py3-none-any.whl.
File metadata
- Download URL: dwave_gate-0.4.0-py3-none-any.whl
- Upload date:
- Size: 91.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7e75347d3201a2a7115508c56b1f109261f84ee4de7c51f0ae4b7fa7571a5d1
|
|
| MD5 |
0e553c8cf59c34cc7493c1c42c5412f9
|
|
| BLAKE2b-256 |
7e163ef2f218aaf2cade66b3e9f8000791e7b7f40c91aa92c79ac5f6470f54b7
|