uniqc.simulator.originir_ext_simulator module¶
Higher-level simulator for dynamic OriginIR-ext programs.
OriginIR_ext_Simulator sits above
OpcodeSimulator and interprets the
non-opcode control flow (QIF/QWHILE) of a classical / control-flow
program tree, driving the OpcodeSimulator — which owns the CREG store — for the
linear opcodes (gates, MEASURE → CREG, RESET, and the classical
instructions AND/OR/XOR/MOV/NOT).
Because mid-circuit measurement + classical feedback make each run stochastic,
results are produced by per-shot re-execution: every shot runs the whole
program from a fresh |0...0> state and reads the final CREG bitstring
(c[0] = LSB). The exact aggregate paths (simulate_pmeasure /
simulate_stateprob) are therefore ill-defined and raise.
- exception uniqc.simulator.originir_ext_simulator.LoopWatchdogError[source]¶
Bases:
RuntimeErrorRaised when a
QWHILEloop exceeds its configuredmax_iterations.
- class uniqc.simulator.originir_ext_simulator.OriginIR_ext_Simulator(backend_type='statevector', available_qubits=None, available_topology=None, seed=None, max_while_iterations=None, **extra_kwargs)[source]¶
Bases:
BaseSimulatorInterpreter for dynamic OriginIR-ext programs (CREG + control flow).
Accepts a
Circuit(with or without a structureddynamic_program) or an OriginIR-ext string. Ordinary flat circuits are executed as a single linear opcode sequence followed by their terminal measurements.- Parameters:
backend_type –
"statevector"or"density_matrix"(seeuniqc.simulator.opcode_simulator.backend_alias()).available_qubits – Optional list of available qubit indices.
available_topology – Optional list of available qubit pairs.
seed – Optional RNG seed (applied once before a shot loop / single run) for deterministic mid-circuit measurement outcomes.
max_while_iterations – Optional global override of every
QWHILEblock’s internal iteration watchdog.Nonehonours each block’s ownmax_iterations.
- simulate_density_matrix(quantum_code)[source]¶
Run the program once and return the resulting density matrix.
For programs with mid-circuit measurement this is a single stochastic sample’s density matrix.
- simulate_pmeasure(quantum_code)[source]¶
Blocked: exact measurement probabilities are ill-defined here.
- simulate_shots(quantum_code, shots)[source]¶
Run the program shots times and tally final CREG bitstrings.
- Returns:
Dict mapping outcome bitstring (int,
c[0]= LSB) to its count.