Skip to content

Update geotransolver for 2d and 3d use cases#1502

Open
coreyjadams wants to merge 2 commits intoNVIDIA:mainfrom
coreyjadams:geotransolver-2d-3d
Open

Update geotransolver for 2d and 3d use cases#1502
coreyjadams wants to merge 2 commits intoNVIDIA:mainfrom
coreyjadams:geotransolver-2d-3d

Conversation

@coreyjadams
Copy link
Collaborator

PhysicsNeMo Pull Request

This PR adds the same structured 2d and 3d convolutional steps to geotransolver that are available in transolver.

To make sure the code is not overly duplicating, it refactors a few places to ensure the implementation can reuse core components as much as possible.

Description

Checklist

Dependencies

Review Process

All PRs are reviewed by the PhysicsNeMo team before merging.

Depending on which files are changed, GitHub may automatically assign a maintainer for review.

We are also testing AI-based code review tools (e.g., Greptile), which may add automated comments with a confidence score.
This score reflects the AI’s assessment of merge readiness and is not a qualitative judgment of your work, nor is
it an indication that the PR will be accepted / rejected.

AI-generated feedback should be reviewed critically for usefulness.
You are not required to respond to every AI comment, but they are intended to help both authors and reviewers.
Please react to Greptile comments with 👍 or 👎 to provide feedback on their accuracy.

@coreyjadams coreyjadams self-assigned this Mar 14, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 14, 2026

Greptile Summary

This PR extends GeoTransolver with structured 2D and 3D convolutional paths, mirroring the existing Transolver structured mesh support. The refactoring extracts shared logic into reusable functions (_gale_forward_impl, _gale_compute_slice_attention_cross, _SliceToContextMixin) and adds GALEStructuredMesh2D, GALEStructuredMesh3D, and StructuredContextProjector classes.

  • Adds structured_shape parameter to GeoTransolver, GALE_block, and GlobalContextBuilder to enable Conv2d/Conv3d slice projection on structured grids
  • Refactors GALE forward pass and cross-attention into shared module-level functions to avoid code duplication between irregular and structured variants
  • Extracts slice-to-context initialization and computation into _SliceToContextMixin shared by ContextProjector and the new StructuredContextProjector
  • Adds _flatten_for_structured helper in geotransolver.py to handle both spatial (B,H,W,C) and flattened (B,N,C) inputs with proper unflatten on output
  • Correctly disables ball-query local features when structured_shape is set (incompatible paths)
  • New tests cover 2D/3D structured forward passes, spatial-vs-flattened input equivalence, structured+global-context, and rejection of include_local_features with structured_shape
  • New public classes (GALEStructuredMesh2D, GALEStructuredMesh3D, StructuredContextProjector) have minimal docstrings compared to the project's coding standards

Important Files Changed

Filename Overview
physicsnemo/experimental/models/geotransolver/init.py Exports new structured GALE variants (GALEStructuredMesh2D, GALEStructuredMesh3D, StructuredContextProjector). Clean and correct.
physicsnemo/experimental/models/geotransolver/context_projector.py Refactors shared slice logic into _SliceToContextMixin and adds StructuredContextProjector with Conv2d/Conv3d encoding. Well-structured refactoring; StructuredContextProjector.forward lacks docstring.
physicsnemo/experimental/models/geotransolver/gale.py Extracts shared GALE forward/cross-attention into module-level functions; adds GALEStructuredMesh2D/3D via mixin + PhysicsAttentionStructured* inheritance; GALE_block now supports spatial_shape routing. Clean refactoring with correct MRO.
physicsnemo/experimental/models/geotransolver/geotransolver.py Adds structured_shape parameter to GeoTransolver with flatten/unflatten support for 2D/3D grids. Includes proper validation and output reshaping. Well-integrated with existing architecture.
test/models/geotransolver/test_geotransolver.py Adds structured 2D/3D forward tests, rejects-local-features validation, and global-context-with-structured-grid test. Good coverage of new functionality.

Last reviewed commit: a0cd8b0

Comment on lines +432 to +438
class StructuredContextProjector(_SliceToContextMixin, nn.Module):
r"""Context projector with Conv2d/Conv3d geometry encoding on structured grids.

Same output interface as :class:`ContextProjector`—slice tokens
:math:`(B, H, S, D)`—but projects per-cell geometry via spatial convolutions
aligned with structured GALE attention.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Minimal class docstring for public API

StructuredContextProjector is exported in __init__.py as part of the public API, but its class docstring is much shorter than the sibling ContextProjector. Per the project's coding standards (MOD-003c), public class docstrings should include Parameters, Forward, Outputs, See Also, and Examples sections. The forward method (line 507) also lacks a docstring entirely (MOD-003d).

Consider adding documentation to match the level of detail in ContextProjector to help users understand the interface (e.g., expected spatial_shape, how it relates to ContextProjector, and a usage example).

File Used: CODING_STANDARDS/MODELS_IMPLEMENTATION.md (source)

Comment on lines +372 to +373
class GALEStructuredMesh2D(_GALEStructuredForwardMixin, PhysicsAttentionStructuredMesh2D):
r"""GALE with Conv2d slice projection for 2D structured grids (see :class:`GALE`)."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Minimal docstrings on public classes

GALEStructuredMesh2D and GALEStructuredMesh3D (line 402) are exported in __init__.py but have single-line docstrings. Per the project's coding standards (MOD-003c), public classes should have Parameters, Forward, Outputs, See Also, and Examples sections. Consider expanding the docstrings to document the constructor parameters (especially spatial_shape, context_dim, and kernel) and include a usage example, similar to the GALE class above.

File Used: CODING_STANDARDS/MODELS_IMPLEMENTATION.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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