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.6.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.6.0
File Size Uploaded
dwave_gate-0.6.0.tar.gz 114.1 kB Details

Built distribution (wheel)

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

Total release size: 211.2 kB

Release files / dwave_gate-0.6.0.tar.gz

Download URL dwave_gate-0.6.0.tar.gz
Size 114.1 kB
Tags Source
SHA-256 checksum
How to use checksums
37973ae748ab85c9e2cf4514f6570eb53ea3a60c7c59c7a472c43c0d7b78f2ec
BLAKE2b-256 checksum
How to use checksums
676453391082de36e8a2d575c5331ccc15cad45ea08b919b0d3bb3854069a90b
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.6.0-py3-none-any.whl

Download URL dwave_gate-0.6.0-py3-none-any.whl
Size 97.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
883b040f4b7e40c95a4ebe9c9857a5edf8e9d1823b0eb4ba552b5c32d9b01cad
BLAKE2b-256 checksum
How to use checksums
4123e40033802f46e1a6993a63de652d4bb07d39c1060d65f976e862be5d194e
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

This release

0.6.0 This release

2 release files

0.5.0

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