Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] allow multiple edge builders #70

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

JPXKQX
Copy link
Member

@JPXKQX JPXKQX commented Oct 25, 2024

This PR extends the current functionality to support multiple edge builders between 2 sets of nodes.

  • The edge_builder field is renamed to edge_builders, which now requires a list.
  • The source/target_mask_attr_name fields are now specified inside each edge builder.

The current implementation lacked support for custom limited-area graphs, which required 2 cutoff_factor's to connect nodes both within the limited area and along its boundary. They could be instantiated twice in the list of edges. However, edge attribute normalization occurs after each block. Then, we would have to define edge attributes outside of the edge definitions, leading to a loss of flexibility.

One new functionality that had to be implemented is concat_edges() to concatenate the two sets of edges, dropping the repeated edges.

The current config file for a LAM experiment would look like this (including only nodes & encoder edges):

nodes:
  data:
    node_builder:
      _target_: anemoi.graphs.nodes.ZarrDatasetNodes
      dataset: 
        cutout:
        - dataset:${hardware.paths.data}/${hardware.files.dataset}
          thinning: 25
        - dataset: ${hardware.paths.data}/${hardware.files.forcing_dataset}
        adjust: all
    attributes:
      cutout_mask:
        _target_: anemoi.graphs.nodes.attributes.CutOutMask
  hidden:
    node_builder:
      _target_: anemoi.graphs.nodes.LimitedAreaTriNodes
      resolution: 5 
      reference_node_name: data
      mask_attr_name: cutout_mask

edges:
  - source_name: data
    target_name: hidden
    edge_builders:
    - _target_: anemoi.graphs.edges.CutOffEdges
      cutoff_factor: 0.6 # only for cutoff method
    - _target_: anemoi.graphs.edges.CutOffEdges # connects only boundary nodes
      cutoff_factor: 6 # only for cutoff method
      source_mask_attr_name: cutout
    attributes:
      edge_length:
        _target_: anemoi.graphs.edges.attributes.EdgeLength
        norm: unit-std

NOTE: This change will break compatibility with graph configurations of previous versions.

@JPXKQX JPXKQX self-assigned this Oct 25, 2024
@JPXKQX JPXKQX added the enhancement New feature or request label Oct 25, 2024
@JPXKQX JPXKQX marked this pull request as ready for review October 28, 2024 08:17
@JPXKQX JPXKQX requested a review from HCookie November 11, 2024 14:59
@JPXKQX JPXKQX requested a review from HCookie November 13, 2024 10:39
Copy link
Member

@HCookie HCookie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a code perspective, this looks good to me, however, I am not familiar with the overall design of graphs, so I would suggest getting another review focusing on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants