Skip to content

Relax the torch-geometric minimum in the pytorch extra #149

Description

@prajwal-tech07

The pytorch extra pins torch-geometric>=2.5.3:

[project.optional-dependencies]
pytorch = [
    "torch>=2.3.0",
    "torch-geometric>=2.5.3",
]

That floor is higher than anything in the code needs, and it makes the extra unusable from projects pinned lower. neural-lam pins torch-geometric==2.3.1, so weather-model-graphs[pytorch] can't be installed there at all. It came up in mllam/neural-lam#596.

I don't think the pin was ever a compatibility decision. It's been >=2.5.3 since the initial commit in b68158f, back when 2.5.3 was the latest release, so it looks like it was just whatever was newest at the time rather than a considered floor.

The torch-geometric surface here is small. save/neural_lam/deprecated.py uses from_networkx and mentions pyg.data.Data in type hints, and save/base.py imports the package only to set HAS_PYG. Both have been around far longer than 2.5.3. The current save path, to_torch_tensors_on_disk, doesn't import torch-geometric at all, so the extra only matters for the deprecated to_pyg.

I checked that it actually runs. wmg 0.4.0 against torch-geometric 2.3.1:

wmg : 0.4.0
torch-geometric: 2.3.1
HAS_PYG : True
components : ['m2m', 'g2m', 'm2g']
to_pyg wrote : ['g2m_edge_index.pt', 'g2m_features.pt', 'g2m_node_features.pt', ...]
g2m_edge_index : (2, 592) | g2m_features: (592, 3)

All nine files written with the expected shapes. So I'd suggest dropping the minimum to torch-geometric>=2.3.1. That's the version I tested and the one neural-lam pins. Older versions may well work too, I just haven't checked. torch>=2.3.0 can stay as it is.

One thing that probably explains how this drifted: as far as I can tell the extra is never installed in CI. ci-tests.yml installs torch==1.8.1+cpu and then runs pdm install, which doesn't pull in optional groups, so HAS_PYG is False and both to_pyg tests return early. That would mean nothing has ever exercised this floor. Might be worth a follow-up to install the extra in CI so the minimum is actually tested, but happy to keep that separate from this.
Happy to put up the one-line change if that's useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions