Raise reconcile_state! kernels to fix GPU segfault#408
Open
xkykai wants to merge 3 commits into
Open
Conversation
On the Reactant GPU backend, reconcile_state!'s plain `@jit` lowers the coupled model's kernel launch through EnzymeXLA's kernel-call ABI rewrite (rewriteKernelCallABI -> gpu.LaunchFuncOp), which segfaults on the large coupled update_state! kernel. Compile with `raise=true` so the kernels are raised to StableHLO instead of lowered to a GPU launch, avoiding the crashing path. This is also the lowering the differentiable examples use for the gradient. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
glwagner
approved these changes
Jul 2, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Collaborator
|
I this is a reasonably fine workaround for the moment, but we should find the underlying cause of the segfault and address it there. |
Added a TODO comment regarding issue resolution for kernel launch segfaults in the reconcile_state! function.
Collaborator
Author
|
ok, will close this once tests pass as a temporary workaround. |
Collaborator
Author
|
for the record tests fail right now because of EnzymeAD/Reactant.jl#3028 |
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.
Closes #407.
On the Reactant GPU backend,
reconcile_state!'s plain@jitlowers the coupled model's kernel launch through EnzymeXLA's kernel-call ABI rewrite (rewriteKernelCallABI→gpu.LaunchFuncOp), which segfaults on the large coupledupdate_state!kernel. This happens at model construction, before any physics runs.This compiles
reconcile_state!withraise=true, so the kernels are raised to StableHLO instead of lowered to a GPU launch, avoiding the crashing path. It's also the lowering the differentiable examples already use for the gradient, so the forward and adjoint passes share the same path.Verification (NVIDIA Tesla T4, Reactant 0.2.268)
∂T/∂𝒫̇ = -1.02e3 K/(kg m⁻² s⁻¹)≈ -0.047 K/mm, matching the CPU-documented ~0.04 K/mm sign and magnitude.🤖 Generated with Claude Code
@dkytezab @glwagner