Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/call_precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ jobs:
- name: Print installed modules
run: pip list
- name: Run torch precommit test scope
run: pytest -ra -n2 --durations=30 tests/torch -m "not cuda"
run: pytest -s -ra --durations=30 tests/torch/fx/ -m "not cuda"

pytorch-cuda:
timeout-minutes: 40
Expand Down
29 changes: 29 additions & 0 deletions tests/torch/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import logging
import os
import random
import time

import pytest
import torch
Expand All @@ -22,6 +23,34 @@
from nncf.common.quantization.structs import QuantizationScheme


def _rss_mb() -> float:
with open("/proc/self/status") as f:
for line in f:
if line.startswith("VmRSS:"):
kb = int(line.split()[1])
return kb / 1024.0
return -1.0


def pytest_runtest_setup(item):
item._mem_rss_before = _rss_mb()
item._mem_t0 = time.time()


def pytest_runtest_teardown(item, nextitem):
before = getattr(item, "_mem_rss_before", -1.0)
after = _rss_mb()
dt = time.time() - getattr(item, "_mem_t0", time.time())
delta = after - before
print(
f"\n[MEM] {item.nodeid}\n"
f" RSS before: {before:.1f} MB\n"
f" RSS after : {after:.1f} MB\n"
f" ΔRSS : {delta:+.1f} MB\n"
f" time : {dt:.2f}s\n"
)


@pytest.fixture(scope="session", autouse=True)
def disable_tf32_precision():
if torch:
Expand Down