torch.use_deterministic_algorithms
function use_deterministic_algorithms(mode: boolean, options?: DeterministicOptions): voidfunction use_deterministic_algorithms(mode: boolean, warn_only: boolean, options?: DeterministicOptions): voidEnables or disables deterministic algorithms for reproducibility.
When enabled, all operations use deterministic algorithms instead of potentially faster non-deterministic ones. This ensures exact reproducibility across runs but may reduce performance.
This is a no-op in torch.js. Use
manual_seed to set seeds for reproducible random number generation. WebGPU operations are deterministic by design.Parameters
modeboolean- If true, enable deterministic mode; if false, disable it
optionsDeterministicOptionsoptional
Returns
void
Examples
// Enable deterministic mode for reproducible results
torch.use_deterministic_algorithms(true);
// This would warn but not error if a non-deterministic op is used
torch.use_deterministic_algorithms(true, { warn_only: true });
// Disable deterministic mode for better performance
torch.use_deterministic_algorithms(false);See Also
- PyTorch torch.use_deterministic_algorithms()
- manual_seed - Set random seed for reproducibility
- get_rng_state - Capture and restore RNG state