Skip to content

Commit be169f7

Browse files
shinkpytorchmergebot
authored andcommitted
[Dynamo] Mark config.dead_code_elimination as deprecated (#136933)
part of #136862 For reviewers, all call sites are here: https://github.com/search?q=repo%3Apytorch%2Fpytorch+dead_code_elimination+language%3APython&type=code&l=Python Pull Request resolved: #136933 Approved by: https://github.com/williamwen42, https://github.com/anijain2305
1 parent 6e10f7d commit be169f7

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

test/dynamo/test_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ def test_config_hash(self):
9696
new_hash = config.get_hash()
9797
assert new_hash == starting_hash
9898

99-
with config.patch({"dead_code_elimination": not config.dead_code_elimination}):
99+
with config.patch({"suppress_errors": not config.suppress_errors}):
100100
changed_hash = config.get_hash()
101-
assert "dead_code_elimination" not in config._compile_ignored_keys
101+
assert "suppress_errors" not in config._compile_ignored_keys
102102
assert changed_hash != starting_hash
103103

104104
# Test nested patch

torch/_dynamo/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# need this many ops to create an FX graph
3232
minimum_call_count = 1
3333

34-
# turn on/off DCE pass
34+
# turn on/off DCE pass (deprecated: always true)
3535
dead_code_elimination = True
3636

3737
# disable (for a function) when cache reaches this size

torch/_dynamo/convert_frame.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import time
1818
import traceback
1919
import typing
20+
import warnings
2021
import weakref
2122
from pathlib import Path
2223
from types import CodeType, FrameType, FunctionType, ModuleType
@@ -656,10 +657,16 @@ def transform(
656657
instructions[:] = output.output_instructions
657658
code_options.update(output.code_options)
658659

659-
if config.dead_code_elimination:
660-
propagate_inst_exn_table_entries(instructions)
661-
check_inst_exn_tab_entries_valid(instructions)
662-
instructions[:] = remove_pointless_jumps(remove_dead_code(instructions))
660+
# The config.dead_code_elimination flag is deprecated
661+
# See https://github.com/pytorch/pytorch/issues/136862 for more information
662+
if not config.dead_code_elimination:
663+
warnings.warn(
664+
"The config.dead_code_elimination flag is deprecated, it's now always true."
665+
)
666+
667+
propagate_inst_exn_table_entries(instructions)
668+
check_inst_exn_tab_entries_valid(instructions)
669+
instructions[:] = remove_pointless_jumps(remove_dead_code(instructions))
663670

664671
def compile_inner(
665672
code: CodeType,

0 commit comments

Comments
 (0)