uniqc.simulator.simulator module

Unified quantum circuit simulator.

Provides Simulator and NoisySimulator — the public simulator classes that accept any quantum-circuit representation (Circuit object, OriginIR string, or OpenQASM 2.0 string) and auto-detect the input format at runtime.

Key exports:
  • Simulator: Ideal simulator (statevector / density matrix backends).

  • NoisySimulator: Noisy simulator with error-model injection.

class uniqc.simulator.simulator.NoisySimulator(backend_type='statevector', available_qubits=None, available_topology=None, error_loader=None, readout_error={})[source]

Bases: BaseNoisySimulator

Unified noisy quantum circuit simulator.

Same input flexibility as Simulator (Circuit, OriginIR, or QASM string), with additional support for gate-level error injection and readout-error modelling.

Parameters:
  • backend_type – Backend type (must be "density_matrix" for noise).

  • available_qubits (list[int]) – List of available qubit indices (optional).

  • available_topology (list[list[int]]) – List of available qubit pairs (optional).

  • error_loader (ErrorLoader) – ErrorLoader instance for gate error injection.

  • readout_error (dict[int, list[float]]) – Dict mapping qubit index to [p01, p10] readout error rates.

simulate_preprocess(quantum_code)[source]

Parse, preprocess, and inject errors into a quantum program.

quantum_code may be a Circuit, an OriginIR string, or a QASM string.

Returns:

Tuple of (error-injected program_body, measurement_qubits).

class uniqc.simulator.simulator.Simulator(backend_type='statevector', available_qubits=None, available_topology=None, **extra_kwargs)[source]

Bases: BaseSimulator

Unified ideal quantum circuit simulator.

Accepts any of the following as quantum_code:

  • A Circuit object

  • An OriginIR string (circuit.originir)

  • An OpenQASM 2.0 string (circuit.qasm)

The input format is detected automatically: OriginIR is tried first, and if parsing fails the code falls back to QASM.

Parameters:
  • backend_type – Backend type ("statevector" or "densitymatrix").

  • available_qubits (list[int]) – List of available qubit indices (optional).

  • available_topology (list[list[int]]) – List of available qubit pairs (optional).

  • **extra_kwargs – Additional arguments passed to BaseSimulator (e.g. least_qubit_remapping).

simulate_preprocess(quantum_code)[source]

Parse and preprocess a quantum program.

quantum_code may be a Circuit, an OriginIR string, or a QASM string. The format is detected automatically.

Returns:

Tuple of (processed_program_body, measurement_qubits).