Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

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.

About

dwave-gate provides the functionality for generating quantum circuit description language (QCDL) programs.

Topics

Resources

Stars

17 stars

Watchers

7 watching

Forks

Releases

Used by

Contributors

Languages