OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Added basic logging for torch.compile (#29443)
Surya Siddharth Pemmarajuc8a986c4e439
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/compile.py b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/compile.pyindex 72446ff6685..27cbd8076cb 100644--- a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/compile.py+++ b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/compile.py@@ -18,7 +18,6 @@ from openvino import Core, Type, PartialShape, serializefrom openvino.frontend.pytorch.torchdynamo.backend_utils import _get_cache_dir, _get_device, _get_config, _is_cache_dir_in_configlogger = logging.getLogger(__name__)-logger.setLevel(logging.WARNING)def cached_model_name(model_hash_str, device, args, cache_root, reversed=False): # noqa: VNE003@@ -139,4 +138,6 @@ def openvino_compile(gm: GraphModule, *args, model_hash_str: str = None, optionsconfig["CACHE_DIR"] = cache_rootcompiled = core.compile_model(om, device, config)+ logger.debug(f"OpenVINO graph compile successful on device {device}")+return compileddiff --git a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/execute.py b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/execute.pyindex f995c16f3c0..4f207ed03cb 100644--- a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/execute.py+++ b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/execute.py@@ -29,7 +29,6 @@ from torch.fx.experimental.proxy_tensor import make_fx, wrapper_and_args_for_makimport logginglogger = logging.getLogger(__name__)-logger.setLevel(logging.WARNING)DEFAULT_OPENVINO_PYTHON_CONFIG = MappingProxyType(@@ -128,8 +127,9 @@ class OpenVINOGraphModule(torch.nn.Module):try:result = openvino_execute(self.gm, *args, executor_parameters=self.executor_parameters, partition_id=self.partition_id, options=self.options)- except Exception:- logger.debug("OpenVINO execution failed. Falling back to native PyTorch execution.")+ logger.debug("OpenVINO graph execution successful")+ except Exception as e:+ logger.debug(f"OpenVINO execution failed with {e}. Falling back to native PyTorch execution.")self.perm_fallback = Truereturn self.gm(*args)diff --git a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/partition.py b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/partition.pyindex 9c18a017227..b848f53a4f8 100644--- a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/partition.py+++ b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/partition.py@@ -22,7 +22,6 @@ import typing as timport logginglogger = logging.getLogger(__name__)-logger.setLevel(logging.WARNING)class PatternNode:@@ -133,6 +132,7 @@ class Partitioner:self.supported_ops.enable_by_name(pattern_op)def make_partitions(self, graph_module: GraphModule, options) -> GraphModule:+ logger.debug(f"Graph module before partitioning {graph_module}")allow_single_node_partition = _is_testing(options)self.capture_gptq_patterns(graph_module)self.capture_nncf_patterns(graph_module)@@ -141,5 +141,6 @@ class Partitioner:partitions = partitioner.propose_partitions()self.add_get_attr_inputs(partitions)fused_graph_module = partitioner.fuse_partitions(partitions)+ logger.debug(f"Graph module after partitioning {fused_graph_module}")return fused_graph_module