Skip to content

Commit a1f1f58

Browse files
bobrenjc93pytorchmergebot
authored andcommitted
clean up error_on_nested_jit_trace flag (pytorch#136961)
Pull Request resolved: pytorch#136961 Approved by: https://github.com/jansel
1 parent d326962 commit a1f1f58

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

test/dynamo/test_repros.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3704,9 +3704,6 @@ def f(x):
37043704
with self.assertRaises(RuntimeError):
37053705
torch.jit.trace(f, torch.randn(3))
37063706

3707-
with torch._dynamo.config.patch(error_on_nested_jit_trace=False):
3708-
torch.jit.trace(f, torch.randn(3))
3709-
37103707
@torch._dynamo.config.patch("assume_static_by_default", False)
37113708
def test_tensor_split(self):
37123709
def f(x):

torch/_dynamo/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ def _get_optimize_ddp_mode():
334334
# If True, raise when aot autograd is unsafe to use
335335
raise_on_unsafe_aot_autograd = False
336336

337-
# If true, error if you torch.jit.trace over a dynamo-optimized function.
338-
# If false, silently suppress dynamo
337+
# This flag is ignored and maintained for backwards compatibility.
339338
error_on_nested_jit_trace = True
340339

341340
# If true, error with a better message if we symbolically trace over a

torch/_dynamo/eval_frame.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,10 @@ def _fn(*args, **kwargs):
440440
return fn(*args, **kwargs)
441441

442442
if is_jit_tracing():
443-
if config.error_on_nested_jit_trace:
444-
raise RuntimeError(
445-
"Detected that you are using FX to torch.jit.trace "
446-
"a dynamo-optimized function. This is not supported at the moment."
447-
)
448-
else:
449-
return fn(*args, **kwargs)
443+
raise RuntimeError(
444+
"Detected that you are using FX to torch.jit.trace "
445+
"a dynamo-optimized function. This is not supported at the moment."
446+
)
450447

451448
cleanups = [enter() for enter in self.enter_exit_hooks]
452449
prior = _maybe_set_eval_frame(callback)

0 commit comments

Comments
 (0)