dwave-gate#
Reference documentation for dwave-gate:
About 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.
Usage Information#
Concepts for terminology