Log information about suppressed data dependent errors (#151041)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/151041
Approved by: https://github.com/bobrenjc93
ghstack dependencies: #151023, #151038
This commit is contained in:
Laith Sakka 2025-04-21 16:37:19 -07:00 committed by PyTorch MergeBot
parent 73d95893a2
commit ccd00359da

View File

@ -1187,6 +1187,17 @@ def compute_unbacked_bindings(
return symbol_to_path
def _log_suppressed_dde(a: SymBool, assumed_value: bool) -> None:
sloc, extra = a.node.shape_env._get_stack_summary(True)
log.info(
"could not evaluate %s due to data dependency, it was assumed to be %s with no runtime assertions %s %s",
a,
assumed_value,
sloc,
extra,
)
# The following two functions are common utilities used while defining unbacked semantics
# of various framework code. Those would be used in situations you prefer to guard and know
# the result of the expression over not guarding, but in case you hit a data dependent error
@ -1210,6 +1221,7 @@ def guard_or_false(a: BoolLikeType) -> bool:
try:
return guard_bool(a)
except GuardOnDataDependentSymNode:
_log_suppressed_dde(a, False)
return False
@ -1231,6 +1243,7 @@ def guard_or_true(a: BoolLikeType) -> bool:
try:
return guard_bool(a)
except GuardOnDataDependentSymNode:
_log_suppressed_dde(a, True)
return True