Skip to content

Commit

Permalink
Create RFC for a logging system and list some required features
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtamohler committed Jun 22, 2022
1 parent b379b19 commit 9442b54
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions RFC-0026-logging-system.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# PyTorch Logging System

## **Summary**
Create a new message logging system for PyTorch with the following requirements:

* All errors, warnings, and other messages generated by PyTorch should do so
using the the logging system API

* The APIs for emitting messages and changing settings should all be consistent
between C++ and Python

* Offer different log levels (info, warning, error, ...)

* Offer different classes of messages

- TODO: What are some of the message classes that we'll need?

* Creating new message classes and log levels should be easy

* Settings to turn warnings for a specific message class into errors

* Settings to disable specific message classes and log levels

- TODO: However, I assume most errors should not be disableable

* Settings to avoid emitting duplicate messages generated by multiple
`torch.distribted` ranks (related to issue
[#68768](https://github.com/pytorch/pytorch/issues/68768))

* Ability to make a particular warning class or log level only warn once

- NOTE: Currently `TORCH_WARN_ONCE` does this in C++, but there is no Python
equivalent

- TODO: Should there be a setting to turn a warn-always into a warn-once for
a given message class?

* Settings can be changed from Python, C++, or environment variables

* Should integrate with Meta's internal logging system, which is
[glog](https://github.com/google/glog)

- TODO: What are all the requirements that definine "integrating with glog"

* Must be OSS-friendly, so it shouldn't require libraries (like glog) which may
cause incompatibility issues for projects that use PyTorch


## **Motivation**
Original issue: [link](https://github.com/pytorch/pytorch/issues/72948)

Currently, it is challenging for PyTorch developers to provide messages that
act consistently between Python and C++.

It is also challenging for PyTorch users to manage the messages that PyTorch
emits. For instance, if a PyTorch user happens to be calling PyTorch functions
that emit lots of warnings, it can be difficult for them to filter out those
warnings so that their project's users don't get bombarded with warnings that
they don't need to see.

0 comments on commit 9442b54

Please sign in to comment.