to_neural_lam() to wmg.save for neural-lam tensor-on-disk format#123
Open
prajwal-tech07 wants to merge 1 commit intomllam:mainfrom
Open
to_neural_lam() to wmg.save for neural-lam tensor-on-disk format#123prajwal-tech07 wants to merge 1 commit intomllam:mainfrom
prajwal-tech07 wants to merge 1 commit intomllam:mainfrom
Conversation
…ormat Add o_neural_lam() function that saves graph components to the tensor-on-disk format expected by eural_lam.utils.load_graph(). Supports all three archetypes: - Keisler (flat single-scale) - GraphCast (flat multiscale) - Oskarsson (hierarchical) Output files: - g2m/m2g: single tensors (edge_index, features) - m2m: lists of tensors per level - mesh_features: position-normalized node features per level - mesh_up/mesh_down: hierarchical inter-level edges (when hierarchical=True) Edge features are written raw (unnormalized) - neural-lam normalizes at load time. Mesh node positions are pre-normalized by max(abs(pos)). Includes comprehensive tests covering all 3 archetypes, shape validation, dtype checks, normalization verification, and edge cases. Refs: mllam/neural-lam#384
88fdd98 to
c2e7b5e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Add a
to_neural_lam()function towmg.savethat serializes graph components (fromwmg.create.archetype.*(..., return_components=True)) to the tensor-on-disk.ptformat expected byneural_lam.utils.load_graph().This is the first step in bridging
weather-model-graphsandneural-lam— putting the serialization logic in wmg so that neural-lam's CLI can remain a thin wrapper.What it does:
{"g2m", "m2m", "m2g"}dict returned by any archetype withreturn_components=True.ptfiles (g2m/m2g as single tensors, m2m/mesh_features as lists)max(abs(pos)), matching the existing neural-lam conventionSupports all three archetypes:
Also adds two internal helpers (
_graph_to_edge_tensors,_graph_to_node_features) that cleanly strip heterogeneous node/edge attributes before PyG conversion.Tests: 22 new tests across 4 test classes covering all archetypes, shape/dtype validation, normalization checks, and edge cases.
No new dependencies — uses the existing
[pytorch]optional extras (torch, torch-geometric).Issue Link
Refs mllam/neural-lam#384
Type of change
Checklist before requesting a review
pullwith--rebaseoption if possible).Checklist for reviewers
Each PR comes with its own improvements and flaws. The reviewer should check the following:
Author checklist after completed review
reflecting type of change (add section where missing):
Checklist for assignee