Skip to content

Commit 394bd88

Browse files
xmfanfacebook-github-bot
authored andcommitted
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: pytorch/pytorch#146544 Approved by: https://github.com/masnesral Reviewed By: atalman Differential Revision: D69257043 fbshipit-source-id: fe9df73052c0ad64062e66c97667f985035a78f0
1 parent 89d01e9 commit 394bd88

File tree

1 file changed

+35
-0
lines changed
  • userbenchmark/dynamo/dynamobench/_dynamo

1 file changed

+35
-0
lines changed

userbenchmark/dynamo/dynamobench/_dynamo/utils.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,40 @@ def add_compilation_metrics_to_chromium(c: CompilationMetrics) -> None:
13301330
)
13311331

13321332

1333+
def _get_dynamo_config_for_logging() -> Optional[str]:
1334+
def clean_for_json(d: dict[str, Any]) -> dict[str, Any]:
1335+
blocklist = {
1336+
"TYPE_CHECKING",
1337+
"log_file_name",
1338+
"verbose",
1339+
"repro_after",
1340+
"repro_level",
1341+
"repro_forward_only",
1342+
"repro_tolerance",
1343+
"repro_ignore_non_fp",
1344+
"same_two_models_use_fp64",
1345+
"base_dir",
1346+
"debug_dir_root",
1347+
"_save_config_ignore",
1348+
"log_compilation_metrics",
1349+
"inject_BUILD_SET_unimplemented_TESTING_ONLY",
1350+
"_autograd_backward_strict_mode_banned_ops",
1351+
"reorderable_logging_functions",
1352+
"ignore_logger_methods",
1353+
"traceable_tensor_subclasses",
1354+
"_custom_ops_profile",
1355+
}
1356+
1357+
return {
1358+
key: sorted(value) if isinstance(value, set) else value
1359+
for key, value in d.items()
1360+
if key not in blocklist
1361+
}
1362+
1363+
config_dict = clean_for_json(config.get_config_copy())
1364+
return json.dumps(config_dict, sort_keys=True)
1365+
1366+
13331367
def _scrubbed_inductor_config_for_logging() -> Optional[str]:
13341368
"""
13351369
Method to parse and scrub uninteresting configs from inductor config
@@ -1409,6 +1443,7 @@ def record_compilation_metrics(
14091443
"structured_logging_overhead_us": to_int_us(
14101444
torch._logging.get_structured_logging_overhead()
14111445
),
1446+
"dynamo_config": _get_dynamo_config_for_logging(),
14121447
"inductor_config": _scrubbed_inductor_config_for_logging(),
14131448
"cuda_version": torch.version.cuda,
14141449
"triton_version": triton.__version__ if has_triton() else "",

0 commit comments

Comments
 (0)