Skip to content

Add hooks for PyTorch velocity emulator - #186

Draft
trhille wants to merge 26 commits into
MALI-Dev:developfrom
trhille:mali/add_gnn_hooks
Draft

Add hooks for PyTorch velocity emulator#186
trhille wants to merge 26 commits into
MALI-Dev:developfrom
trhille:mali/add_gnn_hooks

Conversation

@trhille

@trhille trhille commented Jun 17, 2026

Copy link
Copy Markdown

This merge adds hooks for PyTorch-based velocity emulator using FTorch.

Add hooks for PyTorch velocity emulator using FTorch.
@trhille
trhille marked this pull request as draft June 17, 2026 02:55
trhille added 25 commits June 17, 2026 13:03
Add `use mpi` to make MPI constants available in GNN velocity hooks
Add build options for when FTORCH=true. User needs to define FTORCH_ROOT
and LIBTORCH_ROOT environment variables.
Add batch tensor to pass to GNN model. For now, this is all zeros
because all nodes in the graph belong to the same batch.
Re-order input features to match definition in GNN. Make units
consistent with GNN, using km, yr, and °C instead of m, s, and K.
Remove garbage boundary cells, which caused an out-of-bounds error
when calling the GNN.
Build a subgraph of ice-filled cells to send to GNN, to be consistent
with the training approach. Non-ice cells get zero velocity. We should
make sure that this does cause issues for code that was based on
Albany's extended cell approach.
Pass single-precision arrays (real(4)) to GNN to match PyTorch's Float weights.
Disable FPE traps around LibTorch call. LibTorch has internal
operations that trigger FPE but are handled internally. Disabling
those traps around the LibTorch call enables us to compile in debug
mode without getting FPE at runtime.
Add layout argument to torch_tensor_from_array to specify the order
of indices.
Gather indexToCellID alongside features, then reorder global_features into
global cell ID order on rank 0. Similarly, reorder velocity back to gathered
order before scattering.
Assign a normalVelocity value at marginal edges that allow advection
to produce ice advance. Without this, ice at the margins will thicken
unphysically because the normalVelocity is an average of the non-zero
upstream cell velocity and the zero downstream cell velocity. This
was causing the seaward margins of the Filchner-Ronne and Ross ice shelves
to become grounded in test simulations!
Update halos on uReconstructX and uReconstructY after populating
them from the GNN prediction on rank 0.
Include ice-free cells that are adjacent to ice-filled cells to give
the model a sense of where boundary conditions are applied.
Add FTORCH_CUDA compile flag to make for flexible build with either
CPU or GPU.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant