[BugFix] Fix order of compile logging#38012
Conversation
Previously the logging went: ``` torch.compile took X s in total Directly load AOT compilation from path ... Initial profiling/warmup run took X s ``` This was a little weird because loading the AOT compilation is a part of "torch.compile". This PR fixes it to ``` Directly load AOT compilation from path ... torch.compile took X s in total Initial profiling/warmup run took X s ``` Signed-off-by: Richard Zou <zou3519@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request addresses a bug in the AOT compilation loading logic. The change correctly moves the counter increment for loaded AOT artifacts and the corresponding log message to be inside the conditional block that checks for the existence of the compiled artifact. This ensures that the metric and log are only updated when an artifact is actually loaded from the cache, fixing a bug where they would be updated even if the cache was missed. While the PR description focuses on logging order, the core of this change is a correctness fix for when the loading log and metric are recorded. The implementation is correct and improves the reliability of compilation metrics and logs.
| compilation_counter.num_aot_artifacts_loaded += 1 | ||
| logger.info( | ||
| "Directly load AOT compilation from path %s", aot_compilation_path | ||
| ) |
There was a problem hiding this comment.
nit: why changing indent here?
There was a problem hiding this comment.
the context manager around it prints the "torch.compile takes Xs in total" when it exists
Signed-off-by: Richard Zou <zou3519@gmail.com>
Signed-off-by: Richard Zou <zou3519@gmail.com>
Signed-off-by: Richard Zou <zou3519@gmail.com> Signed-off-by: Michel Belleau <michel.belleau@malaiwah.com>
Signed-off-by: Richard Zou <zou3519@gmail.com>
Signed-off-by: Richard Zou <zou3519@gmail.com> Signed-off-by: Monishver Chandrasekaran <monishverchandrasekaran@gmail.com>
Signed-off-by: Richard Zou <zou3519@gmail.com> Signed-off-by: Nithin Chalapathi <nithin.ch10@gmail.com>
Signed-off-by: Richard Zou <zou3519@gmail.com>
Signed-off-by: Richard Zou <zou3519@gmail.com> Signed-off-by: Vinay Damodaran <vrdn@hey.com>
Signed-off-by: Richard Zou <zou3519@gmail.com> Signed-off-by: EricccYang <yangyang4991@gmail.com>
Signed-off-by: Richard Zou <zou3519@gmail.com> Signed-off-by: bhargav-patel-29 <bhargav.patel@tihiitb.org>
Previously the logging went:
This was a little weird because loading the AOT compilation is a part of "torch.compile".
This PR fixes it to