braket.default_simulator.simulator module

class braket.default_simulator.simulator.BaseLocalSimulator[source]

Bases: braket.simulator.braket_simulator.BraketSimulator

run(circuit_ir: Union[braket.ir.openqasm.program_v1.Program, braket.ir.jaqcd.program_v1.Program], *args, **kwargs) → braket.task_result.gate_model_task_result_v1.GateModelTaskResult[source]

Simulate a circuit using either OpenQASM or Jaqcd.

Parameters:
  • circuit_ir (Union[OpenQASMProgram, JaqcdProgram]) – Circuit specification.
  • qubit_count (int, jaqcd-only) – Number of qubits.
  • shots (int, optional) – The number of shots to simulate. Default is 0, which performs a full analytical simulation.
  • batch_size (int, optional) – The size of the circuit partitions to contract, if applying multiple gates at a time is desired; see StateVectorSimulation. Must be a positive integer. Defaults to 1, which means gates are applied one at a time without any optimized contraction.
Returns:

GateModelTaskResult – object that represents the result

Raises:

ValueError – If result types are not specified in the IR or sample is specified as a result type when shots=0. Or, if StateVector and Amplitude result types are requested when shots>0.

properties

simulator properties

initialize_simulation(**kwargs) → braket.default_simulator.simulation.Simulation[source]

Initializes simulation with keyword arguments

run_openqasm(openqasm_ir: braket.ir.openqasm.program_v1.Program, shots: int = 0, *, batch_size: int = 1) → braket.task_result.gate_model_task_result_v1.GateModelTaskResult[source]

Executes the circuit specified by the supplied circuit_ir on the simulator.

Parameters:
  • openqasm_ir (Program) – ir representation of a braket circuit specifying the instructions to execute.
  • shots (int) – The number of times to run the circuit.
  • batch_size (int) – The size of the circuit partitions to contract, if applying multiple gates at a time is desired; see StateVectorSimulation. Must be a positive integer. Defaults to 1, which means gates are applied one at a time without any optimized contraction.
Returns:

GateModelTaskResult – object that represents the result

Raises:

ValueError – If result types are not specified in the IR or sample is specified as a result type when shots=0. Or, if StateVector and Amplitude result types are requested when shots>0.

run_jaqcd(circuit_ir: braket.ir.jaqcd.program_v1.Program, qubit_count: int, shots: int = 0, *, batch_size: int = 1) → braket.task_result.gate_model_task_result_v1.GateModelTaskResult[source]

Executes the circuit specified by the supplied circuit_ir on the simulator.

Parameters:
  • circuit_ir (Program) – ir representation of a braket circuit specifying the instructions to execute.
  • qubit_count (int) – The number of qubits to simulate.
  • shots (int) – The number of times to run the circuit.
  • batch_size (int) – The size of the circuit partitions to contract, if applying multiple gates at a time is desired; see StateVectorSimulation. Must be a positive integer. Defaults to 1, which means gates are applied one at a time without any optimized contraction.
Returns:

GateModelTaskResult – object that represents the result

Raises:

ValueError – If result types are not specified in the IR or sample is specified as a result type when shots=0. Or, if StateVector and Amplitude result types are requested when shots>0.