Random Number Generation

Reproducible, independently-seeded RNG streams (see the Backend Interface Contract's RNG expectations for the full stream table).

QuantumCircuitsMPS.RNGRegistryType
RNGRegistry(; gates_spacetime, gates_realization, born_measurement, state_init=0)

Create RNG registry with seeds for each stream. First 3 arguments (gatesspacetime, gatesrealization, born_measurement) are REQUIRED.

source
RNGRegistry(::Val{:ct_compat}; circuit, measurement)

Create CT.jl-compatible RNG registry where :gatesspacetime, :gatesrealization share the SAME RNG. This matches CT.jl's interleaved consumption pattern for verification.

Used ONLY for Task 8 CT.jl verification with p_proj=0.

Invariant exemption

Because the two gate streams are the SAME object, the fixed-draw invariant on :gates_spacetime does not hold for this registry (see RNGRegistry docstring). is_aliased(registry) returns true here; draw-count tests and with_guarded_stream detect this and bypass.

source
QuantumCircuitsMPS.expected_drawsFunction
expected_draws(circuit::Circuit, n_steps::Int) -> Int

Fixed :gates_spacetime coin consumption of circuit over n_steps steps under the v0.1 unified stochastic rule: each stochastic operation consumes exactly ONE scalar coin per element per step (K coins, where K is the common element count of its outcomes' geometries), independent of which outcomes are selected. Deterministic operations consume none.

Set geometries (SingleSite, AdjacentPair, Sites, staircases, Pointer) always count K = 1; broadcast geometries count element_count(geo, L, bc). Outcomes with unequal K violate the unified equal-K rule and make the coin budget ill-defined — this throws an ArgumentError listing each outcome's K.

Engine status

Since the v0.1 unified engine (Task 9), this count is EXACT for every operation: simulate! draws exactly one :gates_spacetime coin per element slot of every stochastic op, regardless of which outcomes are selected.

ct_compat exemption

Under RNGRegistry(Val(:ct_compat); ...) the :gates_spacetime and :gates_realization streams are the SAME RNG object (CT.jl parity), so Haar draws interleave with coins and the fixed-draw invariant CANNOT hold. Detect such registries with QuantumCircuitsMPS.is_aliased and skip draw-count checks for them.

source