diff --git a/docs/source/conf.py b/docs/source/conf.py index 787c12c6188a..3268f54de47d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1062,7 +1062,6 @@ coverage_ignore_functions = [ "z3op", "z3str", # torch.fx.graph_module - "reduce_deploy_graph_module", "reduce_graph_module", "reduce_package_graph_module", # torch.fx.node diff --git a/test/expect/TestFXAPIBackwardCompatibility.test_function_back_compat-fx_backcompat_function_signatures.expect b/test/expect/TestFXAPIBackwardCompatibility.test_function_back_compat-fx_backcompat_function_signatures.expect index a3666936b7ab..d5da9d8eb9cf 100644 --- a/test/expect/TestFXAPIBackwardCompatibility.test_function_back_compat-fx_backcompat_function_signatures.expect +++ b/test/expect/TestFXAPIBackwardCompatibility.test_function_back_compat-fx_backcompat_function_signatures.expect @@ -29,7 +29,6 @@ torch.fx.graph_module.GraphModule.add_submodule(self, target: str, m: torch.nn.m torch.fx.graph_module.GraphModule.delete_all_unused_submodules(self) -> None torch.fx.graph_module.GraphModule.delete_submodule(self, target: str) -> bool torch.fx.graph_module.GraphModule.recompile(self) -> torch.fx.graph.PythonCode -torch.fx.graph_module.reduce_deploy_graph_module(importer: Callable, body: Dict[Any, Any], import_block: str) -> torch.nn.modules.module.Module torch.fx.graph_module.reduce_graph_module(body: Dict[Any, Any], import_block: str) -> torch.nn.modules.module.Module torch.fx.graph_module.reduce_package_graph_module(importer: Callable, body: Dict[Any, Any], generated_module_name: str) -> torch.nn.modules.module.Module torch.fx.interpreter.Interpreter.__init__(self, module: torch.nn.modules.module.Module, garbage_collect_values: bool = True, graph: Optional[torch.fx.graph.Graph] = None) diff --git a/torch/_dynamo/trace_rules.py b/torch/_dynamo/trace_rules.py index 3684aca12852..096b21b1d59c 100644 --- a/torch/_dynamo/trace_rules.py +++ b/torch/_dynamo/trace_rules.py @@ -3474,7 +3474,6 @@ MOD_SKIPLIST = [ "torch._custom_op", "torch._custom_ops", "torch._decomp", - "torch._deploy", "torch._dispatch", "torch._dynamo", "torch._export", diff --git a/torch/fx/_lazy_graph_module.py b/torch/fx/_lazy_graph_module.py index 377faf327fc9..83ce51fddd04 100644 --- a/torch/fx/_lazy_graph_module.py +++ b/torch/fx/_lazy_graph_module.py @@ -127,11 +127,6 @@ class _LazyGraphModule(GraphModule): forward = _lazy_forward - # TODO: we should handle __reduce_deploy__ the same way as __reduce_package__, - # or __reduce__ by calling _real_recompile. But I don't find a good way - # to test __reduce_deploy__ out. Also it's very unlikely that LazyGraphModule - # will be used in torch::deploy. So it's skipped for now. - def __reduce_package__(self, exporter: PackageExporter): """ Follow GraphModule.__reduce__ but call 'self._real_recompile' rather diff --git a/torch/fx/graph_module.py b/torch/fx/graph_module.py index 183011364f78..4c067c0e76e4 100644 --- a/torch/fx/graph_module.py +++ b/torch/fx/graph_module.py @@ -30,7 +30,6 @@ from .graph import ( __all__ = [ "reduce_graph_module", "reduce_package_graph_module", - "reduce_deploy_graph_module", "GraphModule", ] @@ -147,18 +146,6 @@ def reduce_package_graph_module( return _deserialize_graph_module(forward, body) -@compatibility(is_backward_compatible=True) -def reduce_deploy_graph_module( - importer: PackageImporter, body: dict[Any, Any], import_block: str -) -> torch.nn.Module: - ns = {} - ns["__builtins__"] = importer.patched_builtins - fn_src = body.get("_code") - assert fn_src is not None - forward = _forward_from_src(import_block + fn_src, ns) - return _deserialize_graph_module(forward, body) - - # We create a dummy class here because symbolic_trace pulls the forward() # function off of the class, rather than the instance. This class is used # in _deserialize_graph_module() below. @@ -855,14 +842,6 @@ class {module_name}(torch.nn.Module): # Passing Tracer as argument allows subclasses extending fx.GraphModule # define their own Tracer (extending fx.Tracer). - def __reduce_deploy__(self, importer: Importer): - dict_without_graph = self.__dict__.copy() - dict_without_graph["_graphmodule_cls_name"] = self.__class__.__name__ - del dict_without_graph["_graph"] - - python_code = self.recompile() - import_block = _format_import_block(python_code.globals, importer) - return (reduce_deploy_graph_module, (dict_without_graph, import_block)) def __reduce_package__(self, exporter: PackageExporter): dict_without_graph = self.__dict__.copy()