Skip to main content
https://img.shields.io/pypi/v/dwave-gate.svg https://codecov.io/gh/dwavesystems/dwave-gate/branch/main/graph/badge.svg https://circleci.com/gh/dwavesystems/dwave-gate.svg?style=svg

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 LeapQCDLSimulator to locate a solver that supports QCDL and submit the QCDL program via run:

from dwave.gate.leap import LeapQCDLSimulator

simulator = LeapQCDLSimulator()
future = simulator.run(qcdl_program, shots=3)
result = future.result().result

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.

Metadata

Release files for dwave-gate 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dwave-gate 0.5.0
File Size Uploaded
dwave_gate-0.5.0.tar.gz 108.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dwave-gate 0.5.0
File Interpreter ABI Platform
dwave_gate-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 203.5 kB

Release files / dwave_gate-0.5.0.tar.gz

Download URL dwave_gate-0.5.0.tar.gz
Size 108.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ff805435a711aa65b522e551ec190d96d961f0fe05de68fd2a4b7d36045f9601
BLAKE2b-256 checksum
How to use checksums
7b9631e6401c640b888ee44f0b80a73b85a9a4b990feb98d5ba6e85330f510ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / dwave_gate-0.5.0-py3-none-any.whl

Download URL dwave_gate-0.5.0-py3-none-any.whl
Size 94.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b481431c388b614e6370f0ac006848a4a466b8b2efb4437530f240ac4f03537e
BLAKE2b-256 checksum
How to use checksums
daf6e11e0147f7d551a57bf4ad2ac41bc7469b44dd6adcc7063470493adb20c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release history Release notifications | RSS feed

0.6.0

2 release files

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.5

26 release files

0.3.2

26 release files

0.3.0

21 release files

0.1.0

24 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page