torch.set_deterministic_debug_mode
function set_deterministic_debug_mode(mode: 0 | 1 | 2): voidSet the debug verbosity level for deterministic algorithm violations.
When deterministic algorithms are enabled, this controls how violations are reported. This provides more granular control than the warn_only parameter.
Debug Modes:
- 0 (default): Silent mode - operations proceed without reporting
- 1 (warn): Warning mode - logs warnings for any non-deterministic behavior
- 2 (error): Error mode - throws exceptions on non-deterministic operations
Usage Pattern:
- Use mode 0 for quick testing where determinism isn't critical
- Use mode 1 to identify which operations violate determinism
- Use mode 2 (equivalent to warn_only=false) for strict reproducibility checking
- Works with determinism: Set after
use_deterministic_algorithms(true) - Granular control: Offers more options than warn_only parameter
- Global setting: Applies to all subsequent operations
Parameters
mode0 | 1 | 2- Verbosity level: 0 (default), 1 (warn), or 2 (error)
Returns
void
Examples
// Silent mode - no warnings (default)
torch.set_deterministic_debug_mode(0);
torch.use_deterministic_algorithms(true);
const result = torch.someOp(input); // Silent
// Warn mode - identify problematic operations
torch.set_deterministic_debug_mode(1);
const result = torch.someOp(input); // Warns if non-deterministic
// Error mode - strict determinism enforcement
torch.set_deterministic_debug_mode(2);
const result = torch.someOp(input); // Throws if non-deterministicSee Also
- PyTorch torch.set_deterministic_debug_mode()
- get_deterministic_debug_mode - Query current debug mode
- use_deterministic_algorithms - Enable deterministic mode