From 9719b42b712a99b24519b7e64e6beaf3228c970a Mon Sep 17 00:00:00 2001 From: gkumbhat Date: Mon, 15 Jul 2024 15:19:50 -0500 Subject: [PATCH 01/10] :package: Update torch to 2.3.1 Signed-off-by: gkumbhat --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ed967814..da6542aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "scipy>=1.8.1", "sentence-transformers>=2.3.1,<2.4.0", "tokenizers>=0.13.3", - "torch>=2.2.2,<2.3.0", + "torch>=2.3.1,<2.4.0", "tqdm>=4.65.0", "transformers>=4.32.0", "peft==0.6.0", From 4d0dfc4996f0ad1440fcaac01c8185b7568e8c7a Mon Sep 17 00:00:00 2001 From: gkumbhat Date: Mon, 15 Jul 2024 15:43:49 -0500 Subject: [PATCH 02/10] :bug: Remove tee from torch launch config to correspond to API changeswith lib update Signed-off-by: gkumbhat --- caikit_nlp/toolkit/torch_run.py | 1 - 1 file changed, 1 deletion(-) diff --git a/caikit_nlp/toolkit/torch_run.py b/caikit_nlp/toolkit/torch_run.py index 43184f2d..d9725811 100644 --- a/caikit_nlp/toolkit/torch_run.py +++ b/caikit_nlp/toolkit/torch_run.py @@ -100,6 +100,5 @@ def get_torch_elastic_launch_config( rdzv_backend="static", rdzv_endpoint=f"{master_addr}:{master_port}", rdzv_configs=rdzv_configs, - tee=Std.ALL, max_restarts=max_restarts, ) From cc86f6b97609d7857bf3275e89fdfe241d9fb433 Mon Sep 17 00:00:00 2001 From: gkumbhat Date: Mon, 15 Jul 2024 15:52:09 -0500 Subject: [PATCH 03/10] :art: Fix lint by removing unused import Signed-off-by: gkumbhat --- caikit_nlp/toolkit/torch_run.py | 1 - 1 file changed, 1 deletion(-) diff --git a/caikit_nlp/toolkit/torch_run.py b/caikit_nlp/toolkit/torch_run.py index d9725811..d2f0f3cf 100644 --- a/caikit_nlp/toolkit/torch_run.py +++ b/caikit_nlp/toolkit/torch_run.py @@ -24,7 +24,6 @@ # Third Party from torch import cuda -from torch.distributed.elastic.multiprocessing.api import Std from torch.distributed.launcher.api import LaunchConfig import torch.distributed as dist From 314db0170ce35decf037bfec4a6f1f0f2ac198b9 Mon Sep 17 00:00:00 2001 From: Flavia Beo Date: Tue, 16 Jul 2024 16:28:34 -0400 Subject: [PATCH 04/10] Changes result vector comparison to approximately. Signed-off-by: Flavia Beo --- tests/modules/text_embedding/test_embedding.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/modules/text_embedding/test_embedding.py b/tests/modules/text_embedding/test_embedding.py index d630b747..9dcd1246 100644 --- a/tests/modules/text_embedding/test_embedding.py +++ b/tests/modules/text_embedding/test_embedding.py @@ -1105,7 +1105,7 @@ def test_same_same(loaded_model: EmbeddingModule, truncate_input_tokens): assert np.allclose(e, combined_vectors[i]) # Next ensuring that the two identical sentences yield identical results (and 3rd does not) - assert np.array_equal(combined_vectors[0], combined_vectors[1]) + assert np.isclose(combined_vectors[0], combined_vectors[1], rtol=1e-05, atol=1e-08).all() assert not np.array_equal(combined_vectors[1], combined_vectors[2]) - assert np.array_equal(separate_vectors[0], separate_vectors[1]) - assert not np.array_equal(separate_vectors[1], separate_vectors[2]) + assert np.isclose(separate_vectors[0], separate_vectors[1], rtol=1e-05, atol=1e-08).all() + assert not np.isclose(separate_vectors[1], separate_vectors[2], rtol=1e-05, atol=1e-08).all() From d621b53ce292a90fd44b4c313a45f4f3efbe7b5d Mon Sep 17 00:00:00 2001 From: gkumbhat Date: Wed, 17 Jul 2024 10:29:52 -0500 Subject: [PATCH 05/10] :art: Fix formatting Signed-off-by: gkumbhat --- tests/modules/text_embedding/test_embedding.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/modules/text_embedding/test_embedding.py b/tests/modules/text_embedding/test_embedding.py index 9dcd1246..b4e294cd 100644 --- a/tests/modules/text_embedding/test_embedding.py +++ b/tests/modules/text_embedding/test_embedding.py @@ -1105,7 +1105,13 @@ def test_same_same(loaded_model: EmbeddingModule, truncate_input_tokens): assert np.allclose(e, combined_vectors[i]) # Next ensuring that the two identical sentences yield identical results (and 3rd does not) - assert np.isclose(combined_vectors[0], combined_vectors[1], rtol=1e-05, atol=1e-08).all() + assert np.isclose( + combined_vectors[0], combined_vectors[1], rtol=1e-05, atol=1e-08 + ).all() assert not np.array_equal(combined_vectors[1], combined_vectors[2]) - assert np.isclose(separate_vectors[0], separate_vectors[1], rtol=1e-05, atol=1e-08).all() - assert not np.isclose(separate_vectors[1], separate_vectors[2], rtol=1e-05, atol=1e-08).all() + assert np.isclose( + separate_vectors[0], separate_vectors[1], rtol=1e-05, atol=1e-08 + ).all() + assert not np.isclose( + separate_vectors[1], separate_vectors[2], rtol=1e-05, atol=1e-08 + ).all() From 59ae6d5d657aa50bcd0d5b37680989190f940196 Mon Sep 17 00:00:00 2001 From: gkumbhat Date: Wed, 17 Jul 2024 12:23:48 -0500 Subject: [PATCH 06/10] :bug: Replace allclose to isclose Signed-off-by: gkumbhat --- tests/modules/text_embedding/test_embedding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/text_embedding/test_embedding.py b/tests/modules/text_embedding/test_embedding.py index b4e294cd..e51ca06b 100644 --- a/tests/modules/text_embedding/test_embedding.py +++ b/tests/modules/text_embedding/test_embedding.py @@ -1018,7 +1018,7 @@ def test_encoding_order(loaded_model: EmbeddingModule, truncate_input_tokens): # test order by comparing value of individual embeddings in sequence for i, e in enumerate(separate_vectors): - assert np.allclose(e, combined_vectors[i]) + assert np.isclose(e, combined_vectors[i]) # test expected failure case by reordering shifted_separate_vectors = separate_vectors[1:] + [separate_vectors[0]] From 3cecf522d6118c0404fb14a438dbc542efbef260 Mon Sep 17 00:00:00 2001 From: Flavia Beo Date: Wed, 17 Jul 2024 13:29:13 -0400 Subject: [PATCH 07/10] Adds tolerance params Signed-off-by: Flavia Beo --- tests/modules/text_embedding/test_embedding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/text_embedding/test_embedding.py b/tests/modules/text_embedding/test_embedding.py index b4e294cd..30f9e5a7 100644 --- a/tests/modules/text_embedding/test_embedding.py +++ b/tests/modules/text_embedding/test_embedding.py @@ -1029,7 +1029,7 @@ def test_encoding_order(loaded_model: EmbeddingModule, truncate_input_tokens): not approx(e) == combined_vectors[i] ), "expected altered order to not match combined vectors" assert not np.allclose( - e, combined_vectors[i] + e, combined_vectors[i], rtol=1e-05, atol=1e-08 ), "expected altered order to not match combined" From f4883e3d224a1c91d4c253b002a7959a81792694 Mon Sep 17 00:00:00 2001 From: gkumbhat Date: Wed, 17 Jul 2024 15:02:05 -0500 Subject: [PATCH 08/10] :bug: Fix isclose to .all Signed-off-by: gkumbhat --- tests/modules/text_embedding/test_embedding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/text_embedding/test_embedding.py b/tests/modules/text_embedding/test_embedding.py index b98b58af..9a086cc1 100644 --- a/tests/modules/text_embedding/test_embedding.py +++ b/tests/modules/text_embedding/test_embedding.py @@ -1018,7 +1018,7 @@ def test_encoding_order(loaded_model: EmbeddingModule, truncate_input_tokens): # test order by comparing value of individual embeddings in sequence for i, e in enumerate(separate_vectors): - assert np.isclose(e, combined_vectors[i]) + assert np.isclose(e, combined_vectors[i], rtol=1e-03, atol=1e-05).all() # test expected failure case by reordering shifted_separate_vectors = separate_vectors[1:] + [separate_vectors[0]] From 9e3dda6c2cd37e2f0d36dd79fcd0381cab89ef42 Mon Sep 17 00:00:00 2001 From: gkumbhat Date: Wed, 17 Jul 2024 16:55:47 -0500 Subject: [PATCH 09/10] :recycle: Replace isclose().all logic to allclose as before Signed-off-by: gkumbhat --- tests/modules/text_embedding/test_embedding.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/modules/text_embedding/test_embedding.py b/tests/modules/text_embedding/test_embedding.py index 9a086cc1..f6d361c5 100644 --- a/tests/modules/text_embedding/test_embedding.py +++ b/tests/modules/text_embedding/test_embedding.py @@ -1018,7 +1018,7 @@ def test_encoding_order(loaded_model: EmbeddingModule, truncate_input_tokens): # test order by comparing value of individual embeddings in sequence for i, e in enumerate(separate_vectors): - assert np.isclose(e, combined_vectors[i], rtol=1e-03, atol=1e-05).all() + assert np.allclose(e, combined_vectors[i], rtol=1e-03, atol=1e-05) # test expected failure case by reordering shifted_separate_vectors = separate_vectors[1:] + [separate_vectors[0]] @@ -1105,13 +1105,13 @@ def test_same_same(loaded_model: EmbeddingModule, truncate_input_tokens): assert np.allclose(e, combined_vectors[i]) # Next ensuring that the two identical sentences yield identical results (and 3rd does not) - assert np.isclose( + assert np.allclose( combined_vectors[0], combined_vectors[1], rtol=1e-05, atol=1e-08 - ).all() + ) assert not np.array_equal(combined_vectors[1], combined_vectors[2]) - assert np.isclose( + assert np.allclose( separate_vectors[0], separate_vectors[1], rtol=1e-05, atol=1e-08 - ).all() - assert not np.isclose( + ) + assert not np.allclose( separate_vectors[1], separate_vectors[2], rtol=1e-05, atol=1e-08 - ).all() + ) From b4e510814071bdba0c7908c9d7b2483130472c2a Mon Sep 17 00:00:00 2001 From: gkumbhat Date: Wed, 17 Jul 2024 17:00:14 -0500 Subject: [PATCH 10/10] :art: Fix formatting Signed-off-by: gkumbhat --- tests/modules/text_embedding/test_embedding.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/modules/text_embedding/test_embedding.py b/tests/modules/text_embedding/test_embedding.py index f6d361c5..29da7b19 100644 --- a/tests/modules/text_embedding/test_embedding.py +++ b/tests/modules/text_embedding/test_embedding.py @@ -1105,13 +1105,9 @@ def test_same_same(loaded_model: EmbeddingModule, truncate_input_tokens): assert np.allclose(e, combined_vectors[i]) # Next ensuring that the two identical sentences yield identical results (and 3rd does not) - assert np.allclose( - combined_vectors[0], combined_vectors[1], rtol=1e-05, atol=1e-08 - ) + assert np.allclose(combined_vectors[0], combined_vectors[1], rtol=1e-05, atol=1e-08) assert not np.array_equal(combined_vectors[1], combined_vectors[2]) - assert np.allclose( - separate_vectors[0], separate_vectors[1], rtol=1e-05, atol=1e-08 - ) + assert np.allclose(separate_vectors[0], separate_vectors[1], rtol=1e-05, atol=1e-08) assert not np.allclose( separate_vectors[1], separate_vectors[2], rtol=1e-05, atol=1e-08 )