Raising: drop accesses through null buffers - #3010
Open
wsmoses wants to merge 3 commits into
Open
Conversation
Staging helpers (mfem's Read/Write) return null for empty buffers, so a captured device pointer reaches the kernel as select(size > 0, ptr, null) and the raising fails on the select. When the pointer's value is only ever consumed as the address of a memory access, the null arm can only fault, so the select collapses to the real pointer. Pointers whose value is observed directly (compared, cast to int, stored as data, passed to a call) are left alone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
# Conflicts: # src/enzyme_ad/jax/Passes/AffineToStableHLORaising.cpp
An empty optional buffer arrives as a null base pointer - directly, behind offset arithmetic in a select arm, or as a mixed-typed view of the null. Every access through it sits on a path that can only fault: loads read as zero, stores vanish, and the null never has to become a kernel argument. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
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.
Stacks on #3006 and includes #2992's null-select fold (will rebase when those merge).
mfem's staging helpers return null for empty buffers, so a captured device pointer can arrive as a null base pointer — directly, hidden behind offset arithmetic in a select arm (
select(p, gep(buf, i), gep(null, i))), or as mixed-typed views of the null (an emptyAhat_iiviewed as both?xi32pivots and?xf64data). Every access through it sits on a path that can only fault: loads read as zero, stores vanish, and the null never has to become a kernel argument.Part of #2968 (hybridization/derefmat triage).
🤖 Generated with Claude Code
https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD