torch.set_warn_always
function set_warn_always(mode: boolean): voidEnable or disable "always warn" mode for all warnings.
When enabled, all warnings are logged regardless of other settings. This is a global setting that applies to all warning categories, including determinism violations, numerical instabilities, and other advisories.
Modes:
- true: Always log all warnings (verbose)
- false (default): Log warnings selectively based on other settings
Use Cases:
- Debugging: Enable to see all potential issues
- Strict mode: Use with error modes for defensive programming
- Production: Disable to reduce log spam
- Global setting: Affects all warnings throughout execution
- Can be toggled: Change at any time during runtime
- Combines with other settings: Works alongside determinism warnings
Parameters
modeboolean- If true, enable always-warn; if false, follow normal warning rules
Returns
void
Examples
// Enable verbose warnings for debugging
torch.set_warn_always(true);
const result = torch.someOp(input); // All warnings shown
// Production mode - normal warnings only
torch.set_warn_always(false);
const predictions = model.forward(test_data);
// Check current setting
if (torch.is_warn_always_enabled()) {
console.log('Running in verbose warning mode');
}See Also
- PyTorch torch.set_warn_always()
- is_warn_always_enabled - Check if always-warn is enabled
- set_deterministic_debug_mode - Set determinism warning level