mixle.engines.precision module¶
Floating-point precision helpers for compute engines.
- precision_name(precision)[source]
Return a readable canonical precision name.
- normalize_numpy_dtype(precision)[source]
Normalize a precision specifier to a NumPy floating dtype.
- normalize_torch_dtype(precision, torch_module)[source]
Normalize a precision specifier to a Torch floating dtype.
- engine_with_precision(engine, precision)[source]
Return
engineadjusted to the requested floating precision.
- auto_precision(data=None, *, engine=None, sample_size=512)[source]
Recommend
'float32'or'float64'from the data and the target hardware.float32 only helps on a GPU Torch engine (on CPU/NumPy it is a no-op or slower), and even there only when the data is well conditioned for single precision. Sufficient-statistic accumulation is already float64-safe (see
ComputeEngine.accumulator_dtype), so this guards the remaining risk – the ~7 significant digits of float32 scoring – by inspecting the data’s magnitude and dynamic range. Returns'float64'whenever a numeric sample is unavailable or looks risky.- Parameters:
- Returns:
'float32'or'float64'.- Return type: