You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#18686 made it such that all ResultMetric values are stored at float32 or higher precision.
However, values passed in as floats to self.log still get auto-casted to a low precision type (if that's the default precision) via __to_tensor. This means that even though the internal result metric representation is precise, the values can loose precision before even reaching ResultMetric.
I'd suggest we modify __to_tensor to use a function like this (as introduced in #18686) to determine and set the dtype:
def_get_default_dtype() ->torch.dtype:
"""The default dtype for new tensors, but no lower than float32."""dtype=torch.get_default_dtype()
returndtypeifdtypein (torch.float32, torch.float64) elsetorch.float32
What version are you seeing the problem on?
v2.1
How to reproduce the bug
No response
Error messages and logs
N/A
Environment
Current environment
#- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
#- PyTorch Lightning Version (e.g., 1.5.0):
#- Lightning App Version (e.g., 0.5.2):
#- PyTorch Version (e.g., 2.0):
#- Python version (e.g., 3.9):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
#- Running environment of LightningApp (e.g. local, cloud):
Bug description
#18686 made it such that all
ResultMetric
values are stored atfloat32
or higher precision.However, values passed in as floats to
self.log
still get auto-casted to a low precision type (if that's the default precision) via__to_tensor
. This means that even though the internal result metric representation is precise, the values can loose precision before even reachingResultMetric
.I'd suggest we modify
__to_tensor
to use a function like this (as introduced in #18686) to determine and set the dtype:What version are you seeing the problem on?
v2.1
How to reproduce the bug
No response
Error messages and logs
N/A
Environment
Current environment
More info
No response
cc @carmocca
The text was updated successfully, but these errors were encountered: