Skip to content

reactantXLAExec: address an offset argument view as a slice of its base buffer - #3286

Merged
wsmoses merged 1 commit into
mainfrom
pb/offset-view-slices
Sep 15, 2026
Merged

wsmoses merged 1 commit into
mainfrom
pb/offset-view-slices

Conversation

@wsmoses

@wsmoses wsmoses commented Sep 14, 2026

Copy link
Copy Markdown
Member

Replaces #3240's host staging. Depends on the read-only-argument change (the PR this branch is stacked on).

A kernel argument may point into the middle of an allocation: MFEM's BlockVector blocks are MakeRef views into one buffer, and everything launched on a block (LinearForm::Assemble on rhs.GetBlock(1), the sub-operator Mults in BlockOperator::Mult) receives base + offset. Instead of copying the tail out to a temporary buffer and back around every launch, the executable takes the base buffer itself. Before the pipeline runs, the argument's type becomes the base buffer's type, every use of it reads stablehlo.slice %base[offset : size], and the value returned for it becomes stablehlo.dynamic_update_slice(%base, %result, offset). The optimizer then folds the update of an unchanged view back to the base argument, so a read-only view is recognized by identity like any other argument (not donated, not returned), and a written view donates its base buffer and returns the updated base, which the runtime stores back into the allocation. The offsets are part of the executable cache key.

No host round trip, the parent buffer keeps aliasing with its blocks, and XLA fuses the slice and the update into the kernel. A view that is not a whole number of elements into a 1-D buffer aborts with a message.

Validation on the MFEM GPU unit-test suite (BlockOperators is the test that exercises this) is running; will update.

🤖 Generated with Claude Code

https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD

@wsmoses
wsmoses force-pushed the pb/offset-view-slices branch from de66af3 to 17aa37b Compare September 14, 2026 14:35
@wsmoses
wsmoses force-pushed the pb/donate-only-written branch 2 times, most recently from 0375f13 to 96aa666 Compare September 14, 2026 14:40
@wsmoses
wsmoses force-pushed the pb/offset-view-slices branch from 17aa37b to a632632 Compare September 14, 2026 14:40
@wsmoses
wsmoses force-pushed the pb/donate-only-written branch from 96aa666 to ff47913 Compare September 14, 2026 14:43
@wsmoses
wsmoses force-pushed the pb/offset-view-slices branch from a632632 to 99d8b56 Compare September 14, 2026 14:43
Base automatically changed from pb/donate-only-written to main September 14, 2026 14:44
@wsmoses
wsmoses force-pushed the pb/offset-view-slices branch 4 times, most recently from 321e53a to a6a389c Compare September 15, 2026 07:09
@wsmoses
wsmoses force-pushed the pb/offset-view-slices branch from a6a389c to dc71ef6 Compare September 15, 2026 17:14
@wsmoses
wsmoses merged commit 5a0a213 into main Sep 15, 2026
19 of 29 checks passed
@wsmoses
wsmoses deleted the pb/offset-view-slices branch September 15, 2026 19:26
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