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
[ONNX] Migrate to PT2 logging #106592
[ONNX] Migrate to PT2 logging #106592
Conversation
Summary - 'dynamo_export' diagnostics now utilize PT2 artifact logger to manage the verbosity level of logs recorded into each diagnostic in SARIF log. The terminal logging is by default turned off. Setting environment variable 'TORCH_LOGS="+onnx_diagnostics"' turns on terminal logging, as well as adjusts the verbosity level which overrides that in diagnostic options. Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/106592
Note: Links to docs will display an error until the docs builds have been completed. ✅ 3 Unrelated FailuresAs of commit 0e223a3: UNSTABLE - The following jobs failed but were likely due to flakiness present on trunk and has been marked as unstable:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Summary - 'dynamo_export' diagnostics now utilize PT2 artifact logger to manage the verbosity level of logs recorded into each diagnostic in SARIF log. The terminal logging is by default turned off. Setting environment variable 'TORCH_LOGS="+onnx_diagnostics"' turns on terminal logging, as well as adjusts the verbosity level which overrides that in diagnostic options. Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. ghstack-source-id: cb731ec7ee3957ff26367ff52419766de6fa9b65 Pull Request resolved: #106592
Summary - 'dynamo_export' diagnostics now utilize PT2 artifact logger to manage the verbosity level of logs recorded into each diagnostic in SARIF log. The terminal logging is by default turned off. Setting environment variable 'TORCH_LOGS="+onnx_diagnostics"' turns on terminal logging, as well as adjusts the verbosity level which overrides that in diagnostic options. - Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. [ghstack-poisoned]
Summary - 'dynamo_export' diagnostics now utilize PT2 artifact logger to manage the verbosity level of logs recorded into each diagnostic in SARIF log. The terminal logging is by default turned off. Setting environment variable 'TORCH_LOGS="+onnx_diagnostics"' turns on terminal logging, as well as adjusts the verbosity level which overrides that in diagnostic options. Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. ghstack-source-id: 4cc785e10fb4a9eccf9b62e7f9540cb5aa2bc0e8 Pull Request resolved: #106592
Summary - 'dynamo_export' diagnostics now utilize PT2 artifact logger to manage the verbosity level of logs recorded into each diagnostic in SARIF log. The terminal logging is by default turned off. Setting environment variable 'TORCH_LOGS="+onnx_diagnostics"' turns on terminal logging, as well as adjusts the verbosity level which overrides that in diagnostic options. - Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. [ghstack-poisoned]
Summary - 'dynamo_export' diagnostics now utilize PT2 artifact logger to manage the verbosity level of logs recorded into each diagnostic in SARIF log. The terminal logging is by default turned off. Setting environment variable 'TORCH_LOGS="+onnx_diagnostics"' turns on terminal logging, as well as adjusts the verbosity level which overrides that in diagnostic options. Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. ghstack-source-id: 088f441b5f2f20c4a983194b7fb35c389a29582d Pull Request resolved: #106592
Summary - The 'dynamo_export' diagnostics leverages the PT2 artifact logger to handle the verbosity level of logs that are recorded in each SARIF log diagnostic. In addition to SARIF log, terminal logging is by default disabled. Terminal logging can be activated by setting the environment variable `TORCH_LOGS="onnx_diagnostics"`. When the environment variable is set, it also fixes logging level to `logging.DEBUG`, overriding the verbosity level specified in the diagnostic options. See `torch/_logging/__init__.py` for more on PT2 logging. - Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. [ghstack-poisoned]
Summary - 'dynamo_export' diagnostics now utilize PT2 artifact logger to manage the verbosity level of logs recorded into each diagnostic in SARIF log. The terminal logging is by default turned off. Setting environment variable 'TORCH_LOGS="+onnx_diagnostics"' turns on terminal logging, as well as adjusts the verbosity level which overrides that in diagnostic options. Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. ghstack-source-id: b979765ade83f6372095cfc81708a31dc8984dca Pull Request resolved: #106592
Summary - The 'dynamo_export' diagnostics leverages the PT2 artifact logger to handle the verbosity level of logs that are recorded in each SARIF log diagnostic. In addition to SARIF log, terminal logging is by default disabled. Terminal logging can be activated by setting the environment variable `TORCH_LOGS="onnx_diagnostics"`. When the environment variable is set, it also fixes logging level to `logging.DEBUG`, overriding the verbosity level specified in the diagnostic options. See `torch/_logging/__init__.py` for more on PT2 logging. - Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. [ghstack-poisoned]
Summary - 'dynamo_export' diagnostics now utilize PT2 artifact logger to manage the verbosity level of logs recorded into each diagnostic in SARIF log. The terminal logging is by default turned off. Setting environment variable 'TORCH_LOGS="+onnx_diagnostics"' turns on terminal logging, as well as adjusts the verbosity level which overrides that in diagnostic options. Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. ghstack-source-id: 9cac69b43b356d66852c8511a966203db9ea0bd1 Pull Request resolved: #106592
Summary - The 'dynamo_export' diagnostics leverages the PT2 artifact logger to handle the verbosity level of logs that are recorded in each SARIF log diagnostic. In addition to SARIF log, terminal logging is by default disabled. Terminal logging can be activated by setting the environment variable `TORCH_LOGS="onnx_diagnostics"`. When the environment variable is set, it also fixes logging level to `logging.DEBUG`, overriding the verbosity level specified in the diagnostic options. See `torch/_logging/__init__.py` for more on PT2 logging. - Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. [ghstack-poisoned]
Can #106478 be merged before this PR lol |
Sure, yours is earlier :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is diagnostics.levels.ERROR affected?
Summary - The 'dynamo_export' diagnostics leverages the PT2 artifact logger to handle the verbosity level of logs that are recorded in each SARIF log diagnostic. In addition to SARIF log, terminal logging is by default disabled. Terminal logging can be activated by setting the environment variable `TORCH_LOGS="onnx_diagnostics"`. When the environment variable is set, it also fixes logging level to `logging.DEBUG`, overriding the verbosity level specified in the diagnostic options. See `torch/_logging/__init__.py` for more on PT2 logging. - Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. [ghstack-poisoned]
Summary - The 'dynamo_export' diagnostics leverages the PT2 artifact logger to handle the verbosity level of logs that are recorded in each SARIF log diagnostic. In addition to SARIF log, terminal logging is by default disabled. Terminal logging can be activated by setting the environment variable `TORCH_LOGS="onnx_diagnostics"`. When the environment variable is set, it also fixes logging level to `logging.DEBUG`, overriding the verbosity level specified in the diagnostic options. See `torch/_logging/__init__.py` for more on PT2 logging. - Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. [ghstack-poisoned]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going OOF, so I will defer this to our colleagues. :)
The only thing I spotted is having a global logger instead of part of Diagnostic classes
@@ -16,6 +18,7 @@ | |||
|
|||
# This is a workaround for mypy not supporting Self from typing_extensions. | |||
_Diagnostic = TypeVar("_Diagnostic", bound="Diagnostic") | |||
diagnostic_logger: logging.Logger = logging.getLogger(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to move to the diagnostic ctor? It is nicer to not depend on globals as much as possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar discussion here #106741 (comment) on idiomatic global logger.
It is a bit anti-pattern that Diagnostic needs to keep track of logger, but I feel it is better to keep track of the global logger instead of a global var of __name__
value here to retrieve that same logger.
@pytorchbot merge |
Merging but will address any more comments in follow ups. |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Summary - 'dynamo_export' diagnostics now utilize PT2 artifact logger to manage the verbosity level of logs recorded into each diagnostic in SARIF log. The terminal logging is by default turned off. Setting environment variable 'TORCH_LOGS="+onnx_diagnostics"' turns on terminal logging, as well as adjusts the verbosity level which overrides that in diagnostic options. Replaces 'with_additional_message' with 'Logger.log' like apis. - Introduce 'LazyString', adopted from 'torch._dynamo.utils', to skip evaluation if the message will not be logged into diagnostic. - Introduce 'log_source_exception' for easier exception logging. - Introduce 'log_section' for easier markdown title logging. - Updated all existing code to use new api. - Removed 'arg_format_too_verbose' diagnostic. - Rename legacy diagnostic classes for TorchScript Onnx Exporter to avoid confusion. Follow ups - The 'dynamo_export' diagnostic now will not capture python stack information at point of diagnostic creation. This will be added back in follow up PRs for debug level logging. - There is type mismatch due to subclassing 'Diagnostic' and 'DiagnosticContext' for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will attempt to fix it. - More docstrings with examples. ghstack-source-id: fd5ad1132f3a71c56a3d16c6c693ee088cdcc185 Pull Request resolved: pytorch/pytorch#106592
Stack from ghstack (oldest at bottom):
Summary
level of logs that are recorded in each SARIF log diagnostic. In addition to SARIF log,
terminal logging is by default disabled. Terminal logging can be activated by setting
the environment variable
TORCH_LOGS="onnx_diagnostics"
. When the environment variableis set, it also fixes logging level to
logging.DEBUG
, overriding the verbosity levelspecified in the diagnostic options.
See
torch/_logging/__init__.py
for more on PT2 logging.evaluation if the message will not be logged into diagnostic.
confusion.
Follow ups
information at point of diagnostic creation. This will be added back in
follow up PRs for debug level logging.
for 'dynamo_export' to incorporate with PT2 logging. Follow up PR will
attempt to fix it.