8000 Revert "Add symbolic_shape_specialization structured trace (#126450)" · pytorch/pytorch@53f73cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 53f73cd

Browse files
Revert "Add symbolic_shape_specialization structured trace (#126450)"
This reverts commit da1fc85. Reverted #126450 on behalf of https://github.com/DanilBaibak due to Break internal build ([comment](#126450 (comment)))
1 parent 5ad2f10 commit 53f73cd

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

torch/fx/experimental/symbolic_shapes.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4397,9 +4397,6 @@ def _set_replacement(self, a: "sympy.Symbol", tgt: "sympy.Expr", msg: str) -> No
43974397
Use this instead of `self.replacements[a] = tgt`.
43984398
"""
43994399

4400-
if tgt == self.replacements.get(a, None):
4401-
return
4402-
44034400
# Precondition: a == tgt
44044401
assert isinstance(a, sympy.Symbol)
44054402

@@ -4490,24 +4487,14 @@ def issubset(x, y):
44904487
"[%s not subset of %s (size-oblivious conditions)]", a, tgt, msg, tgt_bound_so, src_bound_so)
44914488
return
44924489

4493-
if isinstance(tgt, (sympy.Integer, sympy.Float)):
4494-
# specializing to a constant, which is likely unexpected (unless
4495-
# you specified dynamic=True)
4496-
4497-
user_tb = TracingContext.extract_stack()
4498-
trace_structured(
4499-
"symbolic_shape_specialization",
4500-
metadata_fn=lambda: {
4501-
"symbol": repr(a),
4502-
"sources": [s.name() for s in self.var_to_sources[a]],
4503-
"value": repr(tgt),
4504-
"reason": msg,
4505-
"stack": structured.from_traceback(CapturedTraceback.extract(skip=1).summary()),
4506-
"user_stack": structured.from_traceback(user_tb) if user_tb else None,
4507-
}
4508-
)
4490+
if config.print_specializations and isinstance(tgt, (sympy.Integer, sympy.Float)):
4491+
# specializing to a constant, which is likely unexpected
45094492

4510-
if config.print_specializations:
4493+
# NOTE(avik): It is possible that we try logging the same specialization multiple times, e.g.,
4494+
# when adding a to self.replacements, and again when simplifying an expression containing a.
4495+
# Thus to avoid duplication, checking whether a is in self.replacements isn't enough; if it is,
4496+
# it must not already map to `tgt`. Fortunately this check is cheap because `tgt` is a constant.
4497+
if a not in self.replacements or tgt != self.replacements[a]:
45114498
self.log.warning("Specializing %s to %s", self.var_to_sources[a][0].name(), tgt)
45124499
self.log.debug("SPECIALIZATION", stack_info=True)
45134500
log.info("set_replacement %s = %s (%s) %s", a, tgt, msg, tgt_bound)

0 commit comments

Comments
 (0)
0