torch.is_deterministic_algorithms_warn_only_enabled
function is_deterministic_algorithms_warn_only_enabled(): booleanCheck if warn-only mode is enabled for non-deterministic operations.
When enabled alongside deterministic mode, operations that violate determinism constraints will log warnings instead of throwing errors. Useful for:
- Identifying which operations are non-deterministic
- Prototyping with non-deterministic ops before fixing them
- Gradual migration to deterministic code
Modes:
- warn_only=false (default): Throw error on non-deterministic op → prevents silent incorrectness
- warn_only=true: Log warning on non-deterministic op → allows debugging in-place
- Requires determinism enabled: Only meaningful if deterministic mode is on
- For debugging: Useful to find which ops violate determinism
- Not for production: Warnings don't prevent incorrect behavior, only log it
- Works with determinism: Must be used with deterministic algorithms enabled
Returns
boolean– true if warn-only mode is enabled, false otherwise (strict error mode)Examples
// Setup determinism with warnings
torch.use_deterministic_algorithms(true, true); // warn_only=true
// Check if warnings are enabled
if (torch.is_deterministic_algorithms_warn_only_enabled()) {
console.log('Non-deterministic ops will warn but continue');
} else {
console.log('Non-deterministic ops will throw errors');
}
// Debug which operations are non-deterministic
torch.use_deterministic_algorithms(true, true);
const result = torch.someOp(input); // Will warn if non-deterministic
// Later fix all the warnings...
torch.use_deterministic_algorithms(true, false); // Switch to strict mode
const result2 = torch.someOp(input); // Will error if any ops are still non-deterministicSee Also
- PyTorch torch.is_deterministic_algorithms_warn_only_enabled()
- use_deterministic_algorithms - Enable deterministic mode with warn_only option
- are_deterministic_algorithms_enabled - Check if determinism is enabled
- get_deterministic_debug_mode - Query debug verbosity level