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 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

dwave_gate-0.4.0.tar.gz (104.8 kB view details)

Uploaded Source

Built Distribution

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

dwave_gate-0.4.0-py3-none-any.whl (91.0 kB view details)

Uploaded Python 3

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

Hashes for dwave_gate-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c9895ecdf03b55cfea1ccaf4bdcf6d730c032543e4013e6e74a2b2ab11ab0a55
MD5 f0a4e9b10b48c7f7ce6fdfd11e49a73b
BLAKE2b-256 66513d052a8a2eb5a51db577e4bf9d037a902791fdee25cc934d15fd01203213

See more details on using hashes here.

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

Hashes for dwave_gate-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7e75347d3201a2a7115508c56b1f109261f84ee4de7c51f0ae4b7fa7571a5d1
MD5 0e553c8cf59c34cc7493c1c42c5412f9
BLAKE2b-256 7e163ef2f218aaf2cade66b3e9f8000791e7b7f40c91aa92c79ac5f6470f54b7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.5

26 files

0.3.4

26 files

0.3.3

26 files

0.3.2

26 files

0.3.1

26 files

0.3.0

21 files

0.2.1

24 files

0.2.0

24 files

0.1.0

24 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