Skip to content

[Bug]: heat.meshgrid will stop working with upcoming pytorch release #2129

@brownbaerchen

Description

@brownbaerchen

What happened?

Apparently, pytorch have changed their API for torch.meshgrid. In heat.meshgrid, the indexing argument is taken care of by reordering the inputs and outputs and it says that pytorch doesn't support this argument, see here.
Now, pytorch raises a warning that the opposite is the case and torch.meshgrid will stop working without indexing argument in the future. See the pytorch documentation for more details.

We can do one of two things:

  • Just add indexing='ij' to calls to torch.meshgrid in heat.meshgrid. This will keep the current functionality and maybe work with all pytorch versions
  • Remove the reordering and pass the indexing argument directly to torch.meshgrid in heat.meshgrid. This may not be compatible with old pytorch versions, but has the benefit that no resplits are needed in the reordering

The second option is favorable if it works.

By the way, this is another argument in favor of running the CI not just on PR approval. Here, you really need the CI to tell you if the change is compatible with all pytorch versions. If you have to get approval by someone else first, even though you don't know if you approve yourself, that feels strange.

Code snippet triggering the error

python -c "import heat as ht; ht.meshgrid(ht.ones(1), ht.ones(1), indexing='ij')"

Error message or erroneous outcome

/Users/me/micromamba/envs/env/lib/python3.13/site-packages/torch/functional.py:505: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/native/TensorShape.cpp:4319.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]

Version

main (development branch)

Python version

3.13

PyTorch version

2.9

MPI version

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions