From b8bb91dc9c5a7359573382df861657e471acca84 Mon Sep 17 00:00:00 2001 From: Nikita Savelyev Date: Mon, 29 Jul 2024 10:43:18 +0200 Subject: [PATCH] Revert memory monitor usage in conformance tests --- tests/post_training/conftest.py | 5 ----- tests/post_training/pipelines/base.py | 19 +------------------ .../pipelines/lm_weight_compression.py | 18 ++---------------- .../test_quantize_conformance.py | 9 --------- 4 files changed, 3 insertions(+), 48 deletions(-) diff --git a/tests/post_training/conftest.py b/tests/post_training/conftest.py index 08153bc0929..0cc92c29866 100644 --- a/tests/post_training/conftest.py +++ b/tests/post_training/conftest.py @@ -29,8 +29,3 @@ def pytest_addoption(parser): action="store_true", help="Add additional columns to reports.csv", ) - parser.addoption( - "--memory-monitor", - action="store_true", - help="Report memory using MemoryMonitor from tools/memory_monitor.py.", - ) diff --git a/tests/post_training/pipelines/base.py b/tests/post_training/pipelines/base.py index 484c1dcb8ca..b1f7b0a558b 100644 --- a/tests/post_training/pipelines/base.py +++ b/tests/post_training/pipelines/base.py @@ -9,7 +9,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import datetime as dt -import gc import os import re import time @@ -31,9 +30,6 @@ import nncf from nncf import TargetDevice from tests.shared.command import Command -from tools.memory_monitor import MemoryType -from tools.memory_monitor import MemoryUnit -from tools.memory_monitor import monitor_memory_for_callable DEFAULT_VAL_THREADS = 4 @@ -198,7 +194,6 @@ def __init__( run_benchmark_app: bool, params: dict = None, batch_size: int = 1, - memory_monitor: bool = False, ) -> None: self.reported_name = reported_name self.model_id = model_id @@ -209,7 +204,6 @@ def __init__( self.reference_data = reference_data self.params = params or {} self.batch_size = batch_size - self.memory_monitor = memory_monitor self.no_eval = no_eval self.run_benchmark_app = run_benchmark_app self.output_model_dir: Path = self.output_dir / self.reported_name / self.backend.value @@ -357,18 +351,7 @@ def compress(self) -> None: torch.set_num_threads(int(inference_num_threads)) start_time = time.perf_counter() - if self.memory_monitor: - gc.collect() - max_value_per_memory_type = monitor_memory_for_callable( - self._compress, - interval=0.1, - memory_unit=MemoryUnit.MiB, - return_max_value=True, - save_dir=self.output_model_dir / "ptq_memory_logs", - ) - self.run_info.compression_memory_usage = max_value_per_memory_type[MemoryType.SYSTEM] - else: - self.run_info.compression_memory_usage = memory_usage(self._compress, max_usage=True) + self.run_info.compression_memory_usage = memory_usage(self._compress, max_usage=True) self.run_info.time_compression = time.perf_counter() - start_time def save_compressed_model(self) -> None: diff --git a/tests/post_training/pipelines/lm_weight_compression.py b/tests/post_training/pipelines/lm_weight_compression.py index f02b6a384a5..27479fe6a50 100644 --- a/tests/post_training/pipelines/lm_weight_compression.py +++ b/tests/post_training/pipelines/lm_weight_compression.py @@ -8,7 +8,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import gc + import os import re import shutil @@ -32,9 +32,6 @@ from tests.post_training.pipelines.base import BaseTestPipeline from tests.post_training.pipelines.base import StatsFromOutput from tests.shared.paths import TEST_ROOT -from tools.memory_monitor import MemoryType -from tools.memory_monitor import MemoryUnit -from tools.memory_monitor import monitor_memory_for_callable @dataclass @@ -181,18 +178,7 @@ def compress(self) -> None: print("Weight compression...") start_time = time.perf_counter() - if self.memory_monitor: - gc.collect() - max_value_per_memory_type = monitor_memory_for_callable( - self._compress, - interval=0.1, - memory_unit=MemoryUnit.MiB, - return_max_value=True, - save_dir=self.output_model_dir / "wc_memory_logs", - ) - self.run_info.compression_memory_usage = max_value_per_memory_type[MemoryType.SYSTEM] - else: - self.run_info.compression_memory_usage = memory_usage(self._compress, max_usage=True) + self.run_info.compression_memory_usage = memory_usage(self._compress, max_usage=True) self.run_info.time_compression = time.perf_counter() - start_time def collect_data_from_stdout(self, stdout: str): diff --git a/tests/post_training/test_quantize_conformance.py b/tests/post_training/test_quantize_conformance.py index e2709f227d2..e0f7a107627 100644 --- a/tests/post_training/test_quantize_conformance.py +++ b/tests/post_training/test_quantize_conformance.py @@ -80,11 +80,6 @@ def fixture_extra_columns(pytestconfig): return pytestconfig.getoption("extra_columns") -@pytest.fixture(scope="session", name="memory_monitor") -def fixture_memory_monitor(pytestconfig): - return pytestconfig.getoption("memory_monitor") - - def _parse_version(s: Path): version_str = re.search(r".*_(\d+\.\d+).(?:yaml|yml)", s.name).group(1) return version.parse(version_str) @@ -247,7 +242,6 @@ def test_ptq_quantization( run_benchmark_app: bool, capsys: pytest.CaptureFixture, extra_columns: bool, - memory_monitor: bool, ): pipeline = None err_msg = None @@ -273,7 +267,6 @@ def test_ptq_quantization( "no_eval": no_eval, "run_benchmark_app": run_benchmark_app, "batch_size": batch_size, - "memory_monitor": memory_monitor, } ) pipeline: BaseTestPipeline = pipeline_cls(**pipeline_kwargs) @@ -318,7 +311,6 @@ def test_weight_compression( run_benchmark_app: bool, capsys: pytest.CaptureFixture, extra_columns: bool, - memory_monitor: bool, ): pipeline = None err_msg = None @@ -338,7 +330,6 @@ def test_weight_compression( "no_eval": no_eval, "run_benchmark_app": run_benchmark_app, "batch_size": batch_size, - "memory_monitor": memory_monitor, } ) pipeline: BaseTestPipeline = pipeline_cls(**pipeline_kwargs)