braket.devices.local_simulator module

class braket.devices.local_simulator.LocalSimulator(backend: Union[str, braket.devices.braket_simulator.BraketSimulator] = 'default')[source]

Bases: braket.devices.device.Device

A simulator meant to run directly on the user’s machine.

This class wraps a BraketSimulator object so that it can be run and returns results using constructs from the SDK rather than Braket IR.

Parameters

backend (Union[str, BraketSimulator]) – The name of the simulator backend or the actual simulator instance to use for simulation. Defaults to the “default” simulator backend name.

run(task_specification: Union[braket.circuits.circuit.Circuit, braket.annealing.problem.Problem], *args, **kwargs)braket.tasks.local_quantum_task.LocalQuantumTask[source]

Runs the given task with the wrapped local simulator.

Parameters
  • task_specification (Union[Circuit, Problem]) –

  • *args – Positional args to pass to the IR simulator

  • **kwargs – Keyword arguments to pass to the IR simulator

Returns

LocalQuantumTask – A LocalQuantumTask object containing the results of the simulation

Note

If running a circuit, the number of qubits will be passed to the backend as the argument after the circuit itself.

Examples

>>> circuit = Circuit().h(0).cnot(0, 1)
>>> device = LocalSimulator("default")
>>> device.run(circuit, shots=1000)
static registered_backends() → Set[str][source]

Gets the backends that have been registered as entry points

Returns

Set[str] – The names of the available backends that can be passed into LocalSimulator’s constructor