Repository navigation
PERF: Compute the regularization on the GPU - #39
Merged
Merged
Conversation
The phase-field regularizations copied the Laplacian (and the consistent double well its three moments and their gradients) to the host and did the sums and gradients in NumPy: in the 4-rank MI300A run at 512^3, 2.7 s per objective evaluation and 0.8 s per Hessian product, 26.6 s of 842. Both regularizations and ConsistentDoubleWell now compute in the fields' array module (cupy on a GPU) in double precision; only the local sums reach the host for the MPI reduction. Results come back like the input: a host array for a host caller, after one copy, or a device array for a device caller, without one. The conduction homogenization gains the xp property the regularization uses. New GPU tests compare gradient, Hessian product and regularization of a GPU problem with the CPU, and check that device input stays on the device. They are skipped without cupy and a GPU build of muGrid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
flake8 E303/E302 in regularization.py. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Step 1 of the plan to keep the optimization loop on the GPU (follows #38).
Why
The phase-field regularizations computed the Laplacian on the device, then copied it to the host. The consistent double well did the same with its 3 moments and their gradients. Sums and gradients were then done in NumPy. In the 4-rank MI300A run at 512³ that was 2.7 s per objective evaluation and 0.8 s per Hessian product: 26.6 s of 842.
What changes
PhaseFieldRegularization,NodalPhaseFieldRegularizationandConsistentDoubleWellcompute in the fields' array module (CuPy on a GPU), in double precision. Only the local sums reach the host for the MPI reduction.HomogenizationConductivitygains thexpproperty the regularization uses.Tests
New
test/test_gpu.py(markergpu):These tests are skipped without CuPy and a GPU build of muGrid, so they have not run yet. Please run
pytest test/test_gpu.pyon MI300A. They also cover PERF: Keep the sensitivity work on the GPU #38's GPU path for the first time.The CPU suite passes (249).
🤖 Generated with Claude Code