Problem
PartialObserve appears to use stable ordering when sampling outcomes, but ObserveGlobal appears to iterate over probability sums without the same deterministic ordering.
This may cause seeded randomness to produce different results depending on dictionary iteration order.
Why this matters
The project has replay/convergence/determinism concepts, so seeded observations should behave predictably.
Unstable ordering can make tests flaky and make replay behaviour harder to reason about.
Suggested approach
Apply a stable ordering in ObserveGlobal before sampling outcomes, similar to the ordering already used in PartialObserve.
For example, order basis states by their bit/index representation before accumulating probabilities.
Acceptance criteria
ObserveGlobal produces the same result for the same seed and same wavefunction across repeated runs.
- Existing observation behaviour is preserved except for improved determinism.
- A regression test is added for stable seeded global observation.
Problem
PartialObserveappears to use stable ordering when sampling outcomes, butObserveGlobalappears to iterate over probability sums without the same deterministic ordering.This may cause seeded randomness to produce different results depending on dictionary iteration order.
Why this matters
The project has replay/convergence/determinism concepts, so seeded observations should behave predictably.
Unstable ordering can make tests flaky and make replay behaviour harder to reason about.
Suggested approach
Apply a stable ordering in
ObserveGlobalbefore sampling outcomes, similar to the ordering already used inPartialObserve.For example, order basis states by their bit/index representation before accumulating probabilities.
Acceptance criteria
ObserveGlobalproduces the same result for the same seed and same wavefunction across repeated runs.