MLX and determinism #2918
-
|
Is the MLX framework deterministic if the PRNGs are seeded? For debugging purposes I initialize my PRNG's as follows: random.seed(value)
numpy.random.seed(value)
mlx.core.random.seed(value)And then I get the following outputs from multiple training runs with the same seed: Notice that the best/last training/validation losses are quite similar, but not quite the same. For example, for the last two runs the best validation losses were 0.016939 and 0.016937 respectively. Close but not quite. Is this a known issue? I may have missed some other source of non-determinism in my network, but my investigation appears to show that the non-determinism comes from within the MLX framework. System: Apple M4 Max, 128 GB, Tahoe 26.0.1 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
No in general it's not deterministic. I would say it's 99% deterministic but there are some GPU kernels which can add floating point numbers in different orders and that can cause small numerical differences. |
Beta Was this translation helpful? Give feedback.
No in general it's not deterministic. I would say it's 99% deterministic but there are some GPU kernels which can add floating point numbers in different orders and that can cause small numerical differences.