Understand causes of non-determinism in GPU simulation
mainEven with fixed seeds, achieving perfect determinism in GPU-accelerated simulations is challenging due to several factors:
1. GPU Work Scheduling
GPU scheduling can alter the order of operations. Because of floating-point numeric storage, changes in execution order can cause small differences in the least significant bits, which diverge over thousands of simulation frames.
2. Domain Randomization Timing
Certain parameters, such as object scales, cannot be randomized during runtime without breaking determinism or causing simulation issues. These must be set at setup time using the on_startup condition for Domain Randomization.
3. Floating Point Precision and World Origin
Environments placed far from the world origin (0, 0, 0) accumulate floating-point errors. This can cause states to differ even when the same actions are applied to the same initial states.
- Workaround: Place all actors/environments at the world origin
(0, 0, 0)and filter out collisions between them. Note that this may cause a 15-50% performance degradation.
4. Resetting into Contact States
If actors are reset into a state where they are already in contact with other actors, the simulation may become non-deterministic. This is because contacts are re-computed from scratch during each reset scenario and cannot guarantee identical results across computations.