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
[PyOV] Split `test_patched_8bit_model_converts` test into multiple smaller tests (#32829)
Przemyslaw Wysockiaab4cbece750
diff --git a/tests/layer_tests/py_frontend_tests/test_torch_frontend.py b/tests/layer_tests/py_frontend_tests/test_torch_frontend.pyindex 7e966242e92..eec5f93fdcd 100644--- a/tests/layer_tests/py_frontend_tests/test_torch_frontend.py+++ b/tests/layer_tests/py_frontend_tests/test_torch_frontend.py@@ -946,11 +946,10 @@ def test_patched_16bit_model_with_convert():assert mm_num == 2-def test_patched_8bit_model_converts():+def test_patched_8bit_model_converts_e4m3fn():from openvino.frontend.pytorch import patch_modelfrom openvino import convert_model, compile_modelfrom transformers.pytorch_utils import Conv1D- import gcclass ModelWithLinear(torch.nn.Module):def __init__(self):@@ -987,12 +986,34 @@ def test_patched_8bit_model_converts():res_f8_e4m3 = cm_f8_e4m3([x.numpy() for x in example])np.testing.assert_allclose(res_f8_e4m3[0], res_ref[0].numpy(), atol=1e-2)np.testing.assert_allclose(res_f8_e4m3[1], res_ref[1].numpy(), atol=1e-2)-- # Force cleanup before next test to avoid mutex deadlock on macOS ARM64- del model_f8_e4m3, model_ref, converted_model, cm_f8_e4m3, res_f8_e4m3, res_ref- gc.collect()- if torch.cuda.is_available():- torch.cuda.empty_cache()+++def test_patched_8bit_model_converts_e5m2():+ from openvino.frontend.pytorch import patch_model+ from openvino import convert_model, compile_model+ from transformers.pytorch_utils import Conv1D++ class ModelWithLinear(torch.nn.Module):+ def __init__(self):+ super().__init__()++ self.branch1 = torch.nn.Sequential(+ torch.nn.Embedding(10, 64),+ torch.nn.Linear(64, 32),+ torch.nn.ReLU()+ )+ self.branch2 = torch.nn.Sequential(+ Conv1D(256, 128),+ torch.nn.Linear(256, 64), torch.nn.ReLU()+ )+ self.buffer = torch.ones(32)++ def forward(self, x1, x2):+ out1 = self.branch1(x1)+ out2 = self.branch2(x2)+ return (out1 + self.buffer, out2)++ example = (torch.randint(0, 10, [32, 64]), torch.randn(32, 128))model_ref = ModelWithLinear().to(torch.float8_e5m2).float()with torch.no_grad():@@ -1007,12 +1028,6 @@ def test_patched_8bit_model_converts():res_f8_e5m2 = cm_f8_e5m2([x.numpy() for x in example])np.testing.assert_allclose(res_f8_e5m2[0], res_ref[0].numpy(), atol=1e-2)np.testing.assert_allclose(res_f8_e5m2[1], res_ref[1].numpy(), atol=1e-2)-- # Force final cleanup to prevent deadlock during test teardown- del model_f8_e5m2, model_ref, converted_model, cm_f8_e5m2, res_f8_e5m2, res_ref- gc.collect()- if torch.cuda.is_available():- torch.cuda.empty_cache()@pytest.mark.skipif(sys.platform.lower().startswith("win"), reason="CVS-174725")