Skip to content

Deprecation Warning in raised when calling gather_all_tensors #3275

@KyleMylonakisProtopia

Description

@KyleMylonakisProtopia

🐛 Bug

I am seeing a deprecated UserWarning being raised inside of torchmetrics. Seems like an easy fix if it hasn't already happened on your main, as the message below gives the fix.

torchmetrics/utilities/distributed.py:150: UserWarning: Using a non-tuple sequence for multidimensional indexing is deprecated and will be changed in pytorch 2.9; use x[tuple(seq)] instead of x[seq]. In pytorch 2.9 this will be interpreted as tensor index, x[torch.tensor(seq)], which will result either in an error or a different result (Triggered internally at /pytorch/torch/csrc/autograd/python_variable_indexing.cpp:306.)
  gathered_result[idx] = gathered_result[idx][slice_param]

To Reproduce

Execute the function gather_all_tensors in torchmetrics/utilities/distributed.py.

Environment

pytorch-lightning==2.5.5
torch==2.8.0
torchmetrics==1.8.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug / fixSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions