|
| 1 | +# PyTorch Logging System |
| 2 | + |
| 3 | +## **Summary** |
| 4 | +Create a new message logging system for PyTorch with the following requirements: |
| 5 | + |
| 6 | +* All errors, warnings, and other messages generated by PyTorch should do so |
| 7 | + using the the logging system API |
| 8 | + |
| 9 | +* The APIs for emitting messages and changing settings should all be consistent |
| 10 | + between C++ and Python |
| 11 | + |
| 12 | +* Offer different log levels (info, warning, error, ...) |
| 13 | + |
| 14 | +* Offer different classes of messages |
| 15 | + |
| 16 | + - TODO: What are some of the message classes that we'll need? |
| 17 | + |
| 18 | +* Creating new message classes and log levels should be easy |
| 19 | + |
| 20 | +* Settings to turn warnings for a specific message class into errors |
| 21 | + |
| 22 | +* Settings to disable specific message classes and log levels |
| 23 | + |
| 24 | + - TODO: However, I assume most errors should not be disableable |
| 25 | + |
| 26 | +* Settings to avoid emitting duplicate messages generated by multiple |
| 27 | + `torch.distribted` ranks (related to issue |
| 28 | + [#68768](https://github.com/pytorch/pytorch/issues/68768)) |
| 29 | + |
| 30 | +* Ability to make a particular warning class or log level only warn once |
| 31 | + |
| 32 | + - NOTE: Currently `TORCH_WARN_ONCE` does this in C++, but there is no Python |
| 33 | + equivalent |
| 34 | + |
| 35 | + - TODO: Should there be a setting to turn a warn-always into a warn-once for |
| 36 | + a given message class? |
| 37 | + |
| 38 | +* Settings can be changed from Python, C++, or environment variables |
| 39 | + |
| 40 | +* Should integrate with Meta's internal logging system, which is |
| 41 | + [glog](https://github.com/google/glog) |
| 42 | + |
| 43 | + - TODO: What are all the requirements that definine "integrating with glog" |
| 44 | + |
| 45 | +* Must be OSS-friendly, so it shouldn't require libraries (like glog) which may |
| 46 | + cause incompatibility issues for projects that use PyTorch |
| 47 | + |
| 48 | + |
| 49 | +## **Motivation** |
| 50 | +Original issue: [link](https://github.com/pytorch/pytorch/issues/72948) |
| 51 | + |
| 52 | +Currently, it is challenging for PyTorch developers to provide messages that |
| 53 | +act consistently between Python and C++. |
| 54 | + |
| 55 | +It is also challenging for PyTorch users to manage the messages that PyTorch |
| 56 | +emits. For instance, if a PyTorch user happens to be calling PyTorch functions |
| 57 | +that emit lots of warnings, it can be difficult for them to filter out those |
| 58 | +warnings so that their project's users don't get bombarded with warnings that |
| 59 | +they don't need to see. |
0 commit comments