torch.are_deterministic_algorithms_enabled
function are_deterministic_algorithms_enabled(): booleanCheck if deterministic algorithm mode is currently enabled.
Queries the global configuration to see if deterministic algorithms are active. Use this to check your current determinism setting, or to conditionally adjust algorithm choice based on whether reproducibility is required.
- Query-only: This doesn't change any settings, only checks them
- Default: Returns false unless
use_deterministic_algorithms(true)was called - For debugging: Helpful to verify determinism is actually enabled
Returns
boolean– true if deterministic mode is enabled, false otherwiseExamples
// Check current setting
if (torch.are_deterministic_algorithms_enabled()) {
console.log('Running in reproducible mode');
} else {
console.log('Running in performance mode');
}
// Conditional configuration
if (!torch.are_deterministic_algorithms_enabled()) {
torch.use_deterministic_algorithms(true);
}
// Skip expensive operations that need determinism
if (!torch.are_deterministic_algorithms_enabled()) {
// Use faster but non-deterministic algorithm
result = torch.some_fast_op(input);
} else {
// Use slower but deterministic algorithm
result = torch.some_deterministic_op(input);
}See Also
- PyTorch torch.are_deterministic_algorithms_enabled()
- use_deterministic_algorithms - Enable deterministic mode
- is_deterministic_algorithms_warn_only_enabled - Check warn-only mode