Skip to content

Commit 9dd373a

Browse files
committed
Create RFC for a logging system and list some required features
1 parent b379b19 commit 9dd373a

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed

RFC-0026-logging-system.md

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# PyTorch Logging System
2+
3+
## **Summary**
4+
Create a new message logging system for PyTorch with the following features:
5+
6+
* The Python and C++ APIs for emitting messages and changing settings should
7+
all be consistent
8+
9+
* Offer different log levels (info, warning, error, ...)
10+
11+
* Offer different classes of messages
12+
13+
- TODO: What are some of the message classes that we'll need?
14+
15+
* Creating new message classes and log levels should be easy
16+
17+
* Settings to turn warnings for a specific message class into errors
18+
19+
* Settings to disable specific message classes and log levels
20+
21+
- TODO: However, I assume most errors should not be disableable
22+
23+
* Settings to avoid emitting duplicate messages generated by multiple
24+
`torch.distribted` ranks (related to issue
25+
[#68768](https://github.com/pytorch/pytorch/issues/68768))
26+
27+
* Ability to make a particular warning class or log level only warn once
28+
29+
- NOTE: Currently `TORCH_WARN_ONCE` does this in C++, but there is no Python
30+
equivalent
31+
32+
- TODO: Should there be a setting to turn a warn-always into a warn-once for
33+
a given message class?
34+
35+
* Settings can be changed from Python, C++, or environment variables
36+
37+
* Should integrate with Meta's internal logging system, which is
38+
[glog](https://github.com/google/glog)
39+
40+
- TODO: What are all the requirements that definine "integrating with glog"
41+
42+
* Must be OSS-friendly, so it shouldn't require libraries (like glog) which may
43+
cause incompatibility issues for projects that use PyTorch
44+
45+
46+
## **Motivation**
47+
Original issue: [link](https://github.com/pytorch/pytorch/issues/72948)
48+
49+
Currently, it is challenging for PyTorch developers to provide messages that
50+
act consistently between Python and C++.
51+
52+
It is also challenging for PyTorch users to manage the messages that PyTorch
53+
emits. For instance, if a PyTorch user happens to be calling PyTorch functions
54+
that emit lots of warnings, it can be difficult for them to filter out those
55+
warnings so that their project's users don't get bombarded with warnings that
56+
they don't need to see.
57+
58+
---
59+
60+
<details>
61+
<summary>Remaining template not yet filled in - click to expand</summary>
62+
63+
## **Proposed Implementation**
64+
This is the bulk of the RFC. Explain the design in enough detail for somebody familiar with PyTorch to understand, and for somebody familiar with the implementation to implement.
65+
This should get into specifics and corner-cases, and include examples of how the feature is used, and how it will interact with other features. Any new terminology should be defined here.
66+
Consider:
67+
* using examples and diagrams to help illustrate your ideas.
68+
* including code examples, if you're proposing an interface or system contract.
69+
* linking to project briefs or wireframes that are relevant.
70+
71+
72+
## **Metrics **
73+
What are the main metrics to measure the value of this feature?
74+
75+
76+
## **Drawbacks**
77+
Are there any reasons why we should not do this? Here we aim to evaluate risk and check ourselves.
78+
79+
Please consider:
80+
* is it a breaking change?
81+
* Impact on UX
82+
* implementation cost, both in terms of code size and complexity
83+
* integration of this feature with other existing and planned features
84+
85+
86+
## **Alternatives**
87+
What other designs have been considered? What is the impact of not doing this?
88+
89+
90+
## **Prior Art**
91+
Discuss prior art (both good and bad) in relation to this proposal:
92+
* Does this feature exist in other libraries? What experience has their community had?
93+
* What lessons can be learned from other implementations of this feature?
94+
* Published papers or great posts that discuss this
95+
96+
97+
## **How we teach this**
98+
* What names and terminology work best for these concepts and why? How is this idea best presented?
99+
* Would the acceptance of this proposal mean the PyTorch documentation must be re-organized or altered?
100+
* How should this feature be taught to existing PyTorch users?
101+
102+
103+
## **Unresolved questions**
104+
* What parts of the design do you expect to resolve through the RFC process before this gets merged?
105+
* What parts of the design do you expect to resolve through the implementation of this feature before stabilization?
106+
* What related issues do you consider out of scope for this RFC that could be addressed in the future independently of the solution that comes out of this RFC?
107+
108+
109+
## Resolution
110+
We decided to do it. X% of the engineering team actively approved of this change.
111+
112+
### Level of Support
113+
Choose one of the following:
114+
* 1: Overwhelming positive feedback.
115+
* 2: Positive feedback.
116+
* 3: Majority Acceptance, with conflicting Feedback.
117+
* 4: Acceptance, with Little Feedback.
118+
* 5: Unclear Resolution.
119+
* 6: RFC Rejected.
120+
* 7: RFC Rejected, with Conflicting Feedback.
121+
122+
123+
#### Additional Context
124+
Some people were in favor of it, but some people didn’t want it for project X.
125+
126+
127+
### Next Steps
128+
Will implement it.
129+
130+
131+
#### Tracking issue
132+
<github issue URL>
133+
134+
135+
#### Exceptions
136+
Not implementing on project X now. Will revisit the decision in 1 year.
137+
138+
</details>
139+
140+
<details>
141+
<summary>Instructions - click to expand</summary>
142+
143+
- Fork the rfcs repo: https://github.com/pytorch/rfcs
144+
- Copy `RFC-0000-template.md` to `RFC-00xx-my-feature.md`, or write your own open-ended proposal. Put care into the details.
145+
- Submit a pull request titled `RFC-00xx-my-feature`.
146+
- Assign the `draft` label while composing the RFC. You may find it easier to use a WYSIWYG editor (like Google Docs) when working with a few close collaborators; feel free to use whatever platform you like. Ideally this document is publicly visible and is linked to from the PR.
147+
- When opening the RFC for general discussion, copy your document into the `RFC-00xx-my-feature.md` file on the PR and assign the `commenting` label.
148+
- Build consensus for your proposal, integrate feedback and revise it as needed, and summarize the outcome of the discussion via a [resolution template](https://github.com/pytorch/rfcs/blob/rfc-process/RFC-0000-template.md#resolution).
149+
- If the RFC is idle here (no activity for 2 weeks), assign the label `stalled` to the PR.
150+
- Once the discussion has settled, assign a new label based on the level of support:
151+
- `accepted` if a decision has been made in the RFC
152+
- `draft` if the author needs to rework the RFC’s proposal
153+
- `shelved` if there are no plans to move ahead with the current RFC’s proposal. We want neither to think about evaluating the proposal
154+
nor about implementing the described feature until some time in the future.
155+
- A state of `accepted` means that the core team has agreed in principle to the proposal, and it is ready for implementation.
156+
- The author (or any interested developer) should next open a tracking issue on Github corresponding to the RFC.
157+
- This tracking issue should contain the implementation next steps. Link to this tracking issue on the RFC (in the Resolution > Next Steps section)
158+
- Once all relevant PRs are merged, the RFC’s status label can be finally updated to `closed`.
159+
160+
</details>

0 commit comments

Comments
 (0)