From adfb78ccb275e5bd7a84d2693da41ff3002eed32 Mon Sep 17 00:00:00 2001 From: Kevin Musgrave Date: Mon, 1 Apr 2024 04:13:40 -0400 Subject: [PATCH 01/10] Update README.md --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b757ec1b..da812a8c 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,17 @@ ## News +**April 1**: v2.5.0 +- Improved `get_all_triplets_indices` so that large batch sizes don't trigger the `INT_MAX` error. +- See the [release notes](https://github.com/KevinMusgrave/pytorch-metric-learning/releases/tag/v2.5.0). +- Thank you [mkmenta](https://github.com/mkmenta). + **December 15**: v2.4.0 - Added [DynamicSoftMarginLoss](https://kevinmusgrave.github.io/pytorch-metric-learning/losses/#dynamicsoftmarginloss). - Added [RankedListLoss](https://kevinmusgrave.github.io/pytorch-metric-learning/losses/#rankedlistloss). - See the [release notes](https://github.com/KevinMusgrave/pytorch-metric-learning/releases/tag/v2.4.0). - Thank you [domenicoMuscill0](https://github.com/domenicoMuscill0), [Puzer](https://github.com/Puzer), [interestingzhuo](https://github.com/interestingzhuo), and [GaetanLepage](https://github.com/GaetanLepage). -**July 25**: v2.3.0 -- Added [HistogramLoss](https://kevinmusgrave.github.io/pytorch-metric-learning/losses/#histogramloss) -- Thank you [domenicoMuscill0](https://github.com/domenicoMuscill0). - ## Documentation - [**View the documentation here**](https://kevinmusgrave.github.io/pytorch-metric-learning/) - [**View the installation instructions here**](https://github.com/KevinMusgrave/pytorch-metric-learning#installation) @@ -236,6 +237,7 @@ Thanks to the contributors who made pull requests! | [AlenUbuntu](https://github.com/AlenUbuntu) | [CircleLoss](https://kevinmusgrave.github.io/pytorch-metric-learning/losses/#circleloss) | | [interestingzhuo](https://github.com/interestingzhuo) | [PNPLoss](https://kevinmusgrave.github.io/pytorch-metric-learning/losses/#pnploss) | | [wconnell](https://github.com/wconnell) | [Learning a scRNAseq Metric Embedding](https://github.com/KevinMusgrave/pytorch-metric-learning/blob/master/examples/notebooks/scRNAseq_MetricEmbedding.ipynb) | +| [mkmenta](https://github.com/mkmenta) | Improved `get_all_triplets_indices` (fixed the `INT_MAX` error) | | [AlexSchuy](https://github.com/AlexSchuy) | optimized ```utils.loss_and_miner_utils.get_random_triplet_indices``` | | [JohnGiorgi](https://github.com/JohnGiorgi) | ```all_gather``` in [utils.distributed](https://kevinmusgrave.github.io/pytorch-metric-learning/distributed) | | [Hummer12007](https://github.com/Hummer12007) | ```utils.key_checker``` | From a9f13b189b9d2edb7ea54b55d88b701ead34af6a Mon Sep 17 00:00:00 2001 From: elisim7 Date: Wed, 17 Jul 2024 18:18:35 +0300 Subject: [PATCH 02/10] rename `emb` to `embeddings` --- src/pytorch_metric_learning/utils/distributed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pytorch_metric_learning/utils/distributed.py b/src/pytorch_metric_learning/utils/distributed.py index 93946eed..d301b934 100644 --- a/src/pytorch_metric_learning/utils/distributed.py +++ b/src/pytorch_metric_learning/utils/distributed.py @@ -93,7 +93,7 @@ def __init__(self, loss, efficient=False): def forward( self, - emb, + embeddings, labels=None, indices_tuple=None, ref_emb=None, @@ -101,7 +101,7 @@ def forward( enqueue_mask=None, ): world_size = torch.distributed.get_world_size() - common_args = [emb, labels, indices_tuple, ref_emb, ref_labels, world_size] + common_args = [embeddings, labels, indices_tuple, ref_emb, ref_labels, world_size] if isinstance(self.loss, CrossBatchMemory): return self.forward_cross_batch(*common_args, enqueue_mask) return self.forward_regular_loss(*common_args) From 946eeb8fd336576ba7485257d9f6bb3b8916ff71 Mon Sep 17 00:00:00 2001 From: elisim7 Date: Wed, 17 Jul 2024 18:22:23 +0300 Subject: [PATCH 03/10] warn in non-distributed setting --- src/pytorch_metric_learning/utils/distributed.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pytorch_metric_learning/utils/distributed.py b/src/pytorch_metric_learning/utils/distributed.py index d301b934..ab205f41 100644 --- a/src/pytorch_metric_learning/utils/distributed.py +++ b/src/pytorch_metric_learning/utils/distributed.py @@ -1,3 +1,5 @@ +import warnings + import torch from ..losses import BaseMetricLossFunction, CrossBatchMemory @@ -100,6 +102,12 @@ def forward( ref_labels=None, enqueue_mask=None, ): + if not is_distributed(): + warnings.warn( + "DistributedLossWrapper is being used in a non-distributed setting. Returning the loss as is." + ) + return self.loss(embeddings, labels, indices_tuple, ref_emb, ref_labels) + world_size = torch.distributed.get_world_size() common_args = [embeddings, labels, indices_tuple, ref_emb, ref_labels, world_size] if isinstance(self.loss, CrossBatchMemory): From 7ec404fef590d8b4441ad6beba8c5048c1be4508 Mon Sep 17 00:00:00 2001 From: Kevin Musgrave Date: Thu, 18 Jul 2024 16:22:34 -0400 Subject: [PATCH 04/10] Remove numpy from setup.py --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 66326d46..f63dee62 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,6 @@ ], python_requires=">=3.0", install_requires=[ - "numpy", "scikit-learn", "tqdm", "torch >= 1.6.0", From df3e1f91ed34c4f30f7fbff544b86b373cc66ff9 Mon Sep 17 00:00:00 2001 From: Kevin Musgrave Date: Thu, 18 Jul 2024 17:18:40 -0400 Subject: [PATCH 05/10] Update base_test_workflow.yml --- .github/workflows/base_test_workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/base_test_workflow.yml b/.github/workflows/base_test_workflow.yml index 52fd4429..f81bf485 100644 --- a/.github/workflows/base_test_workflow.yml +++ b/.github/workflows/base_test_workflow.yml @@ -18,8 +18,8 @@ jobs: pytorch-version: 1.6 torchvision-version: 0.7 - python-version: 3.9 - pytorch-version: 2.1 - torchvision-version: 0.16 + pytorch-version: 2.3 + torchvision-version: 0.18 steps: - uses: actions/checkout@v2 From 3cc2f6acc733c91ed4067beaab99d199c3328bef Mon Sep 17 00:00:00 2001 From: Kevin Musgrave Date: Thu, 18 Jul 2024 17:22:14 -0400 Subject: [PATCH 06/10] Update setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index f63dee62..2e8a8dee 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,7 @@ ], python_requires=">=3.0", install_requires=[ + "numpy < 2.0", "scikit-learn", "tqdm", "torch >= 1.6.0", From e3a31a72938b5dec619e47964756c14f672dbb4a Mon Sep 17 00:00:00 2001 From: Kevin Musgrave Date: Tue, 23 Jul 2024 15:27:22 +0200 Subject: [PATCH 07/10] Update base_test_workflow.yml --- .github/workflows/base_test_workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/base_test_workflow.yml b/.github/workflows/base_test_workflow.yml index f81bf485..c8774f40 100644 --- a/.github/workflows/base_test_workflow.yml +++ b/.github/workflows/base_test_workflow.yml @@ -31,6 +31,7 @@ jobs: run: | pip install .[with-hooks-cpu] pip install torch==${{ matrix.pytorch-version }} torchvision==${{ matrix.torchvision-version }} --force-reinstall + pip install numpy<2.0 --force-reinstall pip install --upgrade protobuf==3.20.1 pip install six pip install packaging From d6c55facca777176b674ed2725bc13e332161468 Mon Sep 17 00:00:00 2001 From: Kevin Musgrave Date: Tue, 23 Jul 2024 15:36:56 +0200 Subject: [PATCH 08/10] Update base_test_workflow.yml --- .github/workflows/base_test_workflow.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/base_test_workflow.yml b/.github/workflows/base_test_workflow.yml index c8774f40..b3ac9c21 100644 --- a/.github/workflows/base_test_workflow.yml +++ b/.github/workflows/base_test_workflow.yml @@ -30,8 +30,7 @@ jobs: - name: Install dependencies run: | pip install .[with-hooks-cpu] - pip install torch==${{ matrix.pytorch-version }} torchvision==${{ matrix.torchvision-version }} --force-reinstall - pip install numpy<2.0 --force-reinstall + pip install numpy<2.0 torch==${{ matrix.pytorch-version }} torchvision==${{ matrix.torchvision-version }} --force-reinstall pip install --upgrade protobuf==3.20.1 pip install six pip install packaging From 9ed1d0d67e46e325245fefba5c889a989775254c Mon Sep 17 00:00:00 2001 From: Kevin Musgrave Date: Tue, 23 Jul 2024 15:40:45 +0200 Subject: [PATCH 09/10] Update base_test_workflow.yml --- .github/workflows/base_test_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/base_test_workflow.yml b/.github/workflows/base_test_workflow.yml index b3ac9c21..02367536 100644 --- a/.github/workflows/base_test_workflow.yml +++ b/.github/workflows/base_test_workflow.yml @@ -30,7 +30,7 @@ jobs: - name: Install dependencies run: | pip install .[with-hooks-cpu] - pip install numpy<2.0 torch==${{ matrix.pytorch-version }} torchvision==${{ matrix.torchvision-version }} --force-reinstall + pip install "numpy<2.0" torch==${{ matrix.pytorch-version }} torchvision==${{ matrix.torchvision-version }} --force-reinstall pip install --upgrade protobuf==3.20.1 pip install six pip install packaging From ed2c1e295d91977cebdded9f625bb8afc3ded786 Mon Sep 17 00:00:00 2001 From: Kevin Musgrave Date: Tue, 23 Jul 2024 15:56:19 +0200 Subject: [PATCH 10/10] Update __init__.py --- src/pytorch_metric_learning/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytorch_metric_learning/__init__.py b/src/pytorch_metric_learning/__init__.py index 50062f87..e5e59e38 100644 --- a/src/pytorch_metric_learning/__init__.py +++ b/src/pytorch_metric_learning/__init__.py @@ -1 +1 @@ -__version__ = "2.5.0" +__version__ = "2.6.0"