autoqasm.simulator.simulator module
- class autoqasm.simulator.simulator.McmSimulator[source]
Bases:
StateVectorSimulatorAutoQASM-backed local simulator registered under the
autoqasmdevice ID.Deprecated: kept for now because
braket.devices.LocalSimulatordoes not yet execute OpenQASMoutputvariable declarations, which@aq.mainfunctions emit for every Python return value. This class will be removed once upstreamLocalSimulatorsupports output variables; after that, autoqasm programs can run directly onbraket.devices.LocalSimulator().- DEVICE_ID = 'autoqasm'
- initialize_simulation(**kwargs) Simulation[source]
Initialize simulation with mid-circuit measurement (MCM) support.
- Parameters:
**kwargs – qubit_count, shots, batch_size
- Returns:
Simulation – Initialized simulation.
- create_program_context() McmProgramContext[source]
Creates a new program context to handle translation of OpenQASM into a desired format.
- run(openqasm_ir: Program, shots: int = 0, *, batch_size: int = 1) GateModelQuantumTaskResult[source]
Executes the program specified by the supplied
circuit_iron the simulator.- Parameters:
openqasm_ir (OpenQASMProgram) – ir representation of a program 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:
GateModelQuantumTaskResult – 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.