Skip to content

reactantXLAExec: type an offset view as the tail of its buffer, slice it after the pipeline - #3290

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

wsmoses merged 1 commit into
mainfrom
pb/offset-view-after-refine

Conversation

@wsmoses

@wsmoses wsmoses commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #3286. The slice of the base buffer was built before argument refinement, in the buffer's byte element type, so a view whose kernel argument has another element type received a slice it could not use. BlockOperators:

error: expect operands to be compatible with condition block arguments but got 'tensor<i64>', 'tensor<648xi8>' vs 'tensor<i64>', 'tensor<?xf64>'

Two changes:

  • For refinement, a view argument is typed as the tail of its base buffer from its offset on (tensor<648xi8> for a view at byte 1440 of a 2088-byte buffer). The pass then converts its element type exactly as for any other argument, and after the pipeline the kernel's identity check (ret operand == argument) sees the refined view directly, so a read-only view needs no fold to be recognized.
  • The rewrite to the base buffer happens after the pipeline, in the same loop that decides donation: the argument becomes the whole base, every use reads the static slice at the offset, and a written view's result is written back into the base at that offset with a dynamic_update_slice. A read-only view is neither donated nor returned, as before.

Everything the runtime touches is bytes; the single pass pipeline is unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD

@wsmoses
wsmoses force-pushed the pb/offset-view-after-refine branch from 536bafc to 4cc68c1 Compare September 15, 2026 20:02
@wsmoses wsmoses changed the title reactantXLAExec: slice an offset view after argument refinement reactantXLAExec: type an offset view as the tail of its buffer, slice it after the pipeline Sep 15, 2026
@wsmoses
wsmoses force-pushed the pb/offset-view-after-refine branch from 4cc68c1 to 1db6547 Compare September 15, 2026 20:45
@wsmoses
wsmoses force-pushed the pb/offset-view-after-refine branch from 1db6547 to 3c40e63 Compare September 15, 2026 21:22
… it after the pipeline

The slice of the base buffer was built before refinement in the buffer's
byte element type, so a view whose kernel argument has another element type
received a slice it could not use (BlockOperators: 'tensor<648xi8>' fed to a
'tensor<?xf64>' loop variable).

A view is now typed as the tail of its base buffer from its offset on, so
refinement converts its element type as for any other argument, and the
kernel's identity check sees the refined view directly. The rewrite to the
base buffer (uses read the slice at the offset, a written view's result is
written back at the offset) happens after the pipeline, alongside the
donation bookkeeping, so no fold is needed to recognize a read-only view.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
@wsmoses
wsmoses force-pushed the pb/offset-view-after-refine branch from 3c40e63 to b9de58b Compare September 15, 2026 21:23
@wsmoses
wsmoses merged commit b076817 into main Sep 15, 2026
4 of 14 checks passed
@wsmoses
wsmoses deleted the pb/offset-view-after-refine branch September 15, 2026 21:31
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