autoqasm.simulator.simulation module

class autoqasm.simulator.simulation.Simulation(qubit_count: int, shots: int, batch_size: int)[source]

Bases: StateVectorSimulation

Parameters:
  • qubit_count (int) – The number of qubits being simulated. All the qubits start in the \(\ket{\mathbf{0}}\) computational basis state.

  • shots (int) – The number of samples to take from the simulation. If set to 0, only results that do not require sampling, such as state vector or expectation, are generated.

  • batch_size (int) – The size of the partitions to contract; if set to 1, the gates are applied one at a time, without any optimization of contraction order. Must be a positive integer.

add_qubits(num_qubits: int) None[source]

Adds the given number of qubits to the simulation.

Parameters:

num_qubits (int) – The number of qubits to add.

measure(targets: tuple[int]) tuple[int][source]

Measures the specified qubits and returns the outcome.

Parameters:

targets (tuple[int]) – The qubit indices to measure.

Returns:

tuple[int] – The measurement outcomes 0 or 1 for each measured qubit.

reset() None[source]

Resets the simulation and resets the qubit count to 0.

flip(target: int) None[source]

Performs a bit flip (PauliX operation) on the specified qubit.

Parameters:

target (int) – The qubit index on which to perform a bit flip.