Merged
Conversation
youkaichao
commented
Aug 7, 2024
Comment on lines
+118
to
+147
| cpp_guard = False | ||
|
|
||
| try: | ||
| from torch._dynamo.guards import GuardManager | ||
| cpp_guard = isinstance(cache.check_fn, GuardManager) | ||
| except Exception: | ||
| pass | ||
|
|
||
| if not cpp_guard: | ||
| guard = cache.check_fn.code_parts | ||
| freevar_names = cache.check_fn.__code__.co_freevars | ||
| freevar_values = [x.cell_contents for x in cache.check_fn.__closure__] | ||
| else: | ||
| def visit(root, ans): | ||
| for x in root.get_leaf_guards(): | ||
| for verbose_str in x.verbose_code_parts(): | ||
| verbose_str = verbose_str.split("#")[0].strip() | ||
| ans.append(verbose_str) | ||
| for child in root.get_child_managers(): | ||
| visit(child, ans) | ||
| guard = [] | ||
| root = cache.check_fn.root | ||
| visit(root, guard) | ||
| if cache.check_fn.closure_vars is None: | ||
| freevar_names = tuple() | ||
| freevar_values = [] | ||
| else: | ||
| freevar_names = tuple(cache.check_fn.closure_vars.keys()) | ||
| freevar_values = list(cache.check_fn.closure_vars.values()) | ||
|
|
Member
Author
There was a problem hiding this comment.
@anijain2305 can you help check if these lines are correct for getting all the guards when cpp guards are enabled?
I got thousands of guards from my experiments.
There was a problem hiding this comment.
Yes, these lines seem correct to me. We have increased the number of guards by more than order of magnitude since February. This is by enabling two flags
guard_nn_modules = True
and more recently
inline_inbuilt_nn_modules = True
These flags make Dynamo tracing safer than before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.