Skip to content

Conversation

@plognjen
Copy link
Contributor

This PR refactors the extract_slice operation to support two major improvements:

  1. Relaxed Layout Constraints
    The operation now allows more flexible source and destination layouts, aligning better with linear layouts.

  2. Support for Arbitrary Tensor Ranks
    extract_slice is no longer limited to 2D tensors and can now handle tensors of any rank.

The "extract_slice" operation enables extracting a slice of a tensor in registers.
It supports the following arguments:
* source: the base tensor on which to create a view tensor
* offsets: offsets into the base tensor at which to create the view
In distributed layouts, tensors are divided into CTA tiles.
A CTA tile represents the smallest contiguous portion of a tensor that is distributed across all threads and warps within a workgroup. The ExtractSlice operation extracts a portion of the tensor that aligns with CTA tile boundaries.

This op is designed to work on logical tensors directly, avoiding the need for complex layout reinterpretation or reshaping.
For example, the tt.split operation only supports splitting along the innermost dimension,
and requires that the resulting innermost dimension provide 2 elements per thread, distributed across registers.
In contrast, extract_slice op imposes no constraints on the extraction dimension or the size of dimensions.

@antiagainst antiagainst changed the title Complete rewrite of extract_slice op [AMD] Rewrite extract_slice op implementation Jun 12, 2025
@plognjen plognjen force-pushed the extract_slice_rewrite branch from 680299e to f961aff Compare June 12, 2025 20:30
@plognjen
Copy link
Contributor Author

@antiagainst I addressed the comments. Thanks for the review!

Copy link
Collaborator

@antiagainst antiagainst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now. Thanks for tidying up it! Adding @ThomasRaoux to take another look to make sure this also looks good.

@ravil-mobile
Copy link
Contributor

LGTM now. Thanks for tidying up it! Adding @ThomasRaoux to take another look to make sure this also looks good.

Hi @ThomasRaoux. Would you have time to have a look at this PR?

Copy link
Collaborator

@ThomasRaoux ThomasRaoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for improving this

@antiagainst antiagainst merged commit 5b7bc04 into triton-lang:main Jun 20, 2025
9 checks passed
tie-pilot-qxw pushed a commit to tie-pilot-qxw/triton that referenced this pull request Aug 30, 2025
This PR refactors the extract_slice operation to support two major
improvements:

1) Relaxed Layout Constraints
The operation now allows more flexible source and destination layouts,
aligning better with linear layouts.

2) Support for Arbitrary Tensor Ranks
extract_slice is no longer limited to 2D tensors and can now handle
tensors of any rank.

The "extract_slice" operation enables extracting a slice of a tensor in
registers.
It supports the following arguments:
    * source: the base tensor on which to create a view tensor
    * offsets: offsets into the base tensor at which to create the view
In distributed layouts, tensors are divided into CTA tiles.
A CTA tile represents the smallest contiguous portion of a tensor that
is distributed across all threads and warps within a workgroup. The
ExtractSlice operation extracts a portion of the tensor that aligns with
CTA tile boundaries.

This op is designed to work on logical tensors directly, avoiding the
need for complex layout reinterpretation or reshaping.
For example, the tt.split operation only supports splitting along the
innermost dimension,
and requires that the resulting innermost dimension provide 2 elements
per thread, distributed across registers.
In contrast, extract_slice op imposes no constraints on the extraction
dimension or the size of dimensions.

---------

Co-authored-by: Ognjen Plavsic <plognjen@amd.com>
Co-authored-by: Lei Zhang <antiagainst@gmail.com>
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.

5 participants