TensorPlay
Reference guides
latest (dev)
Copy
View Markdown

Latest development documentation · Updated 2026-10-08

Reproducibility

If an operation depends on randomness or on non-deterministic kernels (for example some parallel reductions, or GPU kernels), two runs may not produce bit-identical results. TensorPlay provides a set of helpers to request deterministic algorithms and to detect when one is in use.

import tensorplay as tp

print(tp.are_deterministic_algorithms_enabled())   # False by default
tp.use_deterministic_algorithms(True)
print(tp.are_deterministic_algorithms_enabled())   # True

use_deterministic_algorithms is the main switch. When enabled, TensorPlay raises an error for operations that cannot be run deterministically, so you can find them instead of silently getting a different answer.

tp.use_deterministic_algorithms(True, warn_only=True)

Passing warn_only=True downgrades that error to a warning, which is useful for tracking down culprits without stopping mid-run. tp.is_deterministic_algorithms_warn_only_enabled() reports whether you are in that mode.

There is also a debug mode that tells you which operation is at fault:

tp.set_deterministic_debug_mode(True)   # report the offending op
tp.get_deterministic_debug_mode()       # read the mode back

tensorplay.use_deterministic_algorithms

Sets whether TensorPlay operations must use "deterministic" algorithms.

tensorplay.are_deterministic_algorithms_enabled

Returns True if the global deterministic flag is turned on.

tensorplay.is_deterministic_algorithms_warn_only_enabled

Returns True if the global deterministic flag is set to warn only.

tensorplay.set_deterministic_debug_mode

Sets the debug mode for deterministic operations.

tensorplay.get_deterministic_debug_mode

Returns the current value of the debug mode for deterministic operations.

Seeding for random tensors

Deterministic algorithms are about how an op is computed. For the random values themselves, control the seed with tensorplay.random (see the random page).

Where to go next

  • Randomness — reproducibility across runs and processes.

On this page

Ask DeepWiki