[codex] Add rectilinear vector calculus functionals#1725
Merged
loliverhennigh merged 6 commits intoJul 8, 2026
Merged
Conversation
44400c0 to
786ce1f
Compare
Contributor
Greptile SummaryThis PR adds three new periodic vector-calculus functionals —
Important Files Changed
Reviews (1): Last reviewed commit: "Add rectilinear vector calculus function..." | Re-trigger Greptile |
786ce1f to
3fa5808
Compare
Collaborator
Author
|
/blossom-ci |
1 similar comment
Collaborator
Author
|
/blossom-ci |
3fa5808 to
44c7b9d
Compare
44c7b9d to
862aec2
Compare
862aec2 to
b47b61d
Compare
ktangsali
reviewed
Jul 7, 2026
Collaborator
There was a problem hiding this comment.
A few notes:
- We should update the Changelog for this.
- Are we documenting somewhere the cast to float32 in Warp implementation path ? (This PR and the already existing functionals). I feel like we should raise a warning for this / document it if not done already
- In the API docs, we should explicitly state that only periodic boundaries are supported
- The flow of the modules introduced in this PR does not match with the earlier functionals. For example, the
uniform_grid_gradienthas below structure. Is it possible to make them consistent, whichever way you prefer?
uniform_grid_gradient/_warp_impl/
├── __init__.py
├── op.py
├── utils.py
├── launch_forward.py
├── launch_backward.py
└── _kernels/
├── __init__.py
├── forward.py
└── backward.py
Collaborator
Author
|
/ok to test e59f78f |
Collaborator
Author
|
/ok to test c93dc09 |
@loliverhennigh, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
Collaborator
Author
|
/ok to test 08c186a |
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.
Summary
Adds rectilinear-grid vector calculus functionals for periodic nonuniform grids:
rectilinear_grid_divergencerectilinear_grid_curlrectilinear_grid_laplacianEach functional follows the existing rectilinear gradient structure with its own package,
FunctionSpec, Torch implementation, fused Warp custom op, custom backward kernels, exports, benchmark registry entries, tests, and docs figures.Details
The Torch paths reuse the low-level rectilinear coordinate validation and finite-difference weight utilities, but implement the vector calculus operators directly. The Warp paths use fused operator-specific kernels and explicit adjoints for nonuniform rectilinear spacing rather than relying on uniform-grid transpose identities.
Curl is scoped to 2D/3D inputs, divergence supports 1D/2D/3D channel-first vector fields, and Laplacian supports 1D/2D/3D scalar fields.
Validation
Local:
uv run --frozen pre-commit run --all-filesuv run --frozen ruff format --check benchmarks/physicsnemo/nn/functional/registry.py physicsnemo/nn/functional/__init__.py physicsnemo/nn/functional/derivatives/__init__.py physicsnemo/nn/functional/derivatives/rectilinear_grid_divergence physicsnemo/nn/functional/derivatives/rectilinear_grid_curl physicsnemo/nn/functional/derivatives/rectilinear_grid_laplacian test/nn/functional/derivatives/test_rectilinear_grid_divergence.py test/nn/functional/derivatives/test_rectilinear_grid_curl.py test/nn/functional/derivatives/test_rectilinear_grid_laplacian.pyuv run --frozen ruff check benchmarks/physicsnemo/nn/functional/registry.py physicsnemo/nn/functional/__init__.py physicsnemo/nn/functional/derivatives/__init__.py physicsnemo/nn/functional/derivatives/rectilinear_grid_divergence physicsnemo/nn/functional/derivatives/rectilinear_grid_curl physicsnemo/nn/functional/derivatives/rectilinear_grid_laplacian test/nn/functional/derivatives/test_rectilinear_grid_divergence.py test/nn/functional/derivatives/test_rectilinear_grid_curl.py test/nn/functional/derivatives/test_rectilinear_grid_laplacian.pyuv run --frozen pytest -q test/nn/functional/derivativesFunctionSpecclasses.RTX 4090 (
torch 2.11.0+cu130, Warp available):/home/oliver/physicsnemo-maxwell-rtx4090/.venv/bin/python -m pytest -q test/nn/functional/derivatives/test_rectilinear_grid_divergence.py test/nn/functional/derivatives/test_rectilinear_grid_curl.py test/nn/functional/derivatives/test_rectilinear_grid_laplacian.py— 62 passed across CPU and CUDA./home/oliver/physicsnemo-maxwell-rtx4090/.venv/bin/python -m pytest -q test/nn/functional/derivatives— 302 passed across CPU and CUDA.Forward timing sanity check on RTX 4090: