torch.get_float32_matmul_precision
function get_float32_matmul_precision(): stringGet the current float32 matrix multiplication precision level.
Queries the global configuration to see what precision level is currently set for float32 matrix multiplications. Use this to verify your current settings or adjust algorithms based on the configured precision.
Return Values:
'highest': Maximum accuracy (default)'high': Balanced precision and speed'medium': Maximum speed, reduced precision
- Default: Returns 'highest' unless
set_float32_matmul_precision()was called - Query-only: Doesn't change any settings, only returns current setting
- Global setting: Returns the setting that applies to all matmul operations
Returns
string– Current precision setting as string: 'highest', 'high', or 'medium'Examples
// Check and log current precision
const precision = torch.get_float32_matmul_precision();
console.log(`Matrix multiplication precision: ${precision}`);
// Conditionally adjust algorithm based on precision
const precision = torch.get_float32_matmul_precision();
if (precision === 'medium') {
// Use extra validation for low-precision results
const result = torch.matmul(a, b);
console.warn('Results may have lower accuracy');
} else {
const result = torch.matmul(a, b);
}
// Verify precision before training
const precision = torch.get_float32_matmul_precision();
if (precision !== 'highest') {
console.warn(`Training with ${precision} precision - may affect convergence`);
}See Also
- PyTorch torch.get_float32_matmul_precision()
- set_float32_matmul_precision - Change precision setting