Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use float64 instead of float32 in logger & metric & result #11386

Closed
qqueing opened this issue Jan 10, 2022 · 2 comments · Fixed by #11401
Closed

Use float64 instead of float32 in logger & metric & result #11386

qqueing opened this issue Jan 10, 2022 · 2 comments · Fixed by #11401
Assignees
Labels
bug Something isn't working logging Related to the `LoggerConnector` and `log()` priority: 0 High priority task
Milestone

Comments

@qqueing
Copy link
Contributor

qqueing commented Jan 10, 2022

🐛 Bug

Torch metrics or logs use float32 as the default type.
However, this handling is not appropriate for large data sizes.

example in code, I log_dict - tensor(67128463., dtype=torch.float64)
but output result is tensor(67128464.) Maybe this logger use default type float32

https://github.com/PyTorchLightning/pytorch-lightning/blob/master/pytorch_lightning/trainer/connectors/logger_connector/result.py#L217

I think the default type of log or metric would be float64.

torch.tensor(67128463., dtype=torch.float64)
Out[17]: tensor(67128463., dtype=torch.float64)
torch.tensor(67128463., dtype=torch.float32)
Out[18]: tensor(67128464.)

To Reproduce

torch.tensor(67128463., dtype=torch.float64)
Out[17]: tensor(67128463., dtype=torch.float64)
torch.tensor(67128463., dtype=torch.float32)
Out[18]: tensor(67128464.)

In model, self.log_dict({"a": torch.tensor(67128463., dtype=torch.float64)})
output is tensor(67128464.)

Expected behavior

Environment

  • PyTorch Lightning Version (e.g., 1.5.0): 1.5.4, but maybe all version..
  • PyTorch Version (e.g., 1.10):
  • Python version (e.g., 3.9):
  • OS (e.g., Linux):
  • CUDA/cuDNN version:
  • GPU models and configuration:
  • How you installed PyTorch (conda, pip, source):
  • If compiling from source, the output of torch.__config__.show():
  • Any other relevant information:

Additional context

cc @tchaton @rohitgr7 @carmocca @edward-io @ananthsub @kamil-kaczmarek @Raalsky @Blaizzy

@qqueing qqueing added the bug Something isn't working label Jan 10, 2022
@carmocca carmocca added the logging Related to the `LoggerConnector` and `log()` label Jan 10, 2022
@carmocca carmocca self-assigned this Jan 10, 2022
@carmocca carmocca added this to the 1.5.x milestone Jan 10, 2022
@carmocca carmocca added the priority: 0 High priority task label Jan 10, 2022
@carmocca
Copy link
Contributor

Hi @qqueing, thanks for your report.

Can you verify that the changes in #11401 fix your problem?

@qqueing
Copy link
Contributor Author

qqueing commented Jan 11, 2022

Hi @qqueing, thanks for your report.

Can you verify that the changes in #11401 fix your problem?

It is good. works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working logging Related to the `LoggerConnector` and `log()` priority: 0 High priority task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants