Skip to content

[Design discussion] Supporting pyg.HeteroData use internally in neural-lam #385

Description

@leifdenby

The aim of this issue to continue the discussion on whether and how to support use of pyg.HeteroData objects to represent the graph when working with neural-lam (rather than the dictionary of edge-indexes and node/edge features currently used)

To start of the discussion here are some things I have been wondering about:

  1. My view is that we will eventually want to use pyg.HeteroData objects to represent the graph internally in neural-lam. This is what I did in https://github.com/leifdenby/weatherduck which was a prototype implementation trying that approach out (and also trying out fiddle-based config, which is a different conversation). It is also what @matschreiner does in https://github.com/matschreiner/equicast/tree/main?tab=readme-ov-file#data-handler. I think it simplifies the code a lot (only a single object is passed around representing the entire graph) and enables us to eventually also put the model inputs (state/forcing etc) as node features on this graph object, rather than as separate tensors being passed around (which I think is a nice design for implementing new architectures in neural-lam)
    • Is there an interest in moving towards this?
    • Have some people already started this work?
    • @SimonKamuk you and I have discussed this, have you looked at refactoring neural-lam in this way?
    • If we agree this should be done, maybe we could plan a first step in this direction to be loading the tensor-based format into a pyg.HeteroDataobject that is then passed to the torch.nn.Module-derived classes that implement the forecasting model (currently ARModel). What do people think of that?
  2. Does it make sense trying to export from weather-model-graphs to pyg.HeteroData objects and pickling these to disk?
    • If so, what would the drawbacks of these be? To me a clear drawback is that the format (pickled python objects) isn't a self-describing format, unlike what a xr.DataTree netCDF/zarr dataset could be. And it relies on torch-geometric which seems a bit overkill for something that just describes a static graph with edge and node features.
    • If we instead opt for writing xr.DataTrees to disk to represent the graph what would the pros/cons there be? Is the xr.DataTree functionality I have already drafted (Feat/xr datatree output format weather-model-graphs#47) fit-for-purpose or is there something wrong/missing?

This issue is meant as a continuation that started on #339 on bridging the gap between weather-model-graphs and neural-lam.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions