Simulator#

The QPU Simulator section provides an introduction to the simulator in the Leap service and the Submitting Programs shows its use.

Classes#

class LeapQCDLSimulator(**config)[source]#

Bases: object

Submits QCDL programs to the dual-rail simulator in the Leap service.

Examples

Construct a simple QCDL program:

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

Submit it to the QCDL simulator:

from dwave.gate.leap import LeapQCDLSimulator

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

Access measurements and sample counts by calling measurements property or get_counts() method respectively.

class RunResult(result: Result, info: 'dwave.system.samplers.ResultInfoDict')[source]#

Bases: NamedTuple

run() method future result.

count(value, /)[source]#

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)[source]#

Return first index of value.

Raises ValueError if the value is not present.

info: 'dwave.system.samplers.ResultInfoDict'[source]#

Alias for field number 1

result: Result[source]#

Alias for field number 0

close() → None[source]#

Close the underlying cloud client to release system resources such as threads.

The method blocks for all the currently scheduled work (sampling requests) to finish.

See also

close().

property default_solver: dict[str, str][source]#

Features used to select the latest accessible QCDL simulator.

property parameters: dict[str, list[str]][source]#

Supported parameters.

Keys of the returned dict are keyword parameters as returned by a SAPI query.

Solver parameters are dependent on the selected solver and subject to change; for example, new features may add parameters.

property properties: dict[str, Any][source]#

Solver properties as returned by a SAPI query.

Solver properties are dependent on the selected solver and subject to change; for example, new features may add properties.

run(qcdl: QCDLProgram | Mapping[str, Any], **params) → Future[RunResult][source]#

Run the QCDL program using the selected simulator in the Leap service.

Returns the Result class, with SAPI job metadata, both wrapped in a RunResult class and returned in a Future.

Parameters:
  • qcdl – QCDL circuit to upload and simulate.

  • **params – Job parameters accepted by the simulator (solver).

Returns:

Simulation results.