8000 [symbolic shapes] Log SymNode id for provenance by angelayi · Pull Request #146532 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[symbolic shapes] Log SymNode id for provenance #146532

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

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update on "[symbolic shapes] Log SymNode id for provenance"
cc ezyang SherlockNoMad EikanWang jgong5 wenzhe-nrv

[ghstack-poisoned]
  • Loading branch information
angelayi committed Feb 10, 2025
commit f03e985260f6f20764ee4d4a7b04d32e842bd10d
18 changes: 10 additions & 8 deletions torch/fx/experimental/sym_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,9 @@ def guard_float(self, file, line):
def guard_bool(self, file, line):
# TODO: use the file/line for some useful diagnostic on why a
# guard occurred
r = self.shape_env.evaluate_expr(self.expr, self.hint, fx_node=self.fx_node)
r = self.shape_env.evaluate_expr(
self.expr, self.hint, fx_node=self.fx_node, expr_sym_node=self
)
try:
return bool(r)
except Exception:
Expand Down Expand Up @@ -1228,9 +1230,6 @@ def _make_node_magic(method, func):
method_attr = f"{method}_"
else:
method_attr = method

def uninteresting_files() -> Set[str]:
import inspect

def uninteresting_files() -> Set[str]:
import inspect
Expand All @@ -1253,8 +1252,11 @@ def uninteresting_files() -> Set[str]:

def capture_provenance(fn):
@functools.wraps(fn)
def wrapper(self, other):
result = fn(self, other)
def wrapper(self, other=None):
if other is None:
result = fn(self)
else:
result = fn(self, other)
if torch._logging._internal.GET_DTRACE_STRUCTURED:
floc = None
user_stack = None
Expand Down Expand Up @@ -1306,7 +1308,7 @@ def get_id(sym_node) -> Optional[int]:
"result": str(result),
"result_id": id(result),
"arguments": [str(self), str(other)],
"arguments_id": [
"argument_ids": [
i for i in (get_id(self), get_id(other)) if i is not None
],
"user_bottom_stack": str(user_bottom_stack),
Expand All @@ -1319,7 +1321,7 @@ def get_id(sym_node) -> Optional[int]:

return wrapper

# @capture_provenance
@capture_provenance
def binary_magic_impl(self, other):
from torch.fx.experimental.proxy_tensor import (
get_proxy_mode,
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.
0