fix dynamo_compile logging on RecompileLimitExceeded (#146544)
Summary:
Logging branches based on RecompileLimitExceeded or not. If we exceed the limit, we fallback to eager before even trying to analyze the frame. We handle RecompileLimitExceeded outside of the try/catch/finally that edits the metrics context:
https://github.com/pytorch/pytorch/blob/72405b0c0f40a5427656038adfdd4b3efe50d028/torch/_dynamo/convert_frame.py#L908-L935.
dynamo_config and recompile_reason are both known before we raise the RecompileLimitExceeded, so we can add them with the rest of the "common" metrics. which are logged on metric_context decorator exit and is always called
X-link: https://github.com/pytorch/pytorch/pull/146544
Approved by: https://github.com/masnesral
Reviewed By: atalman
Differential Revision: D69257043
fbshipit-source-id: fe9df73052c0ad64062e66c97667f985035a78f0