Skip to content

Initial PR of IdModel-based indexing#2344

Merged
naoyam merged 10 commits intomainfrom
idmodel_indexing_part1
Jun 6, 2024
Merged

Initial PR of IdModel-based indexing#2344
naoyam merged 10 commits intomainfrom
idmodel_indexing_part1

Conversation

@naoyam
Copy link
Collaborator

@naoyam naoyam commented Jun 5, 2024

This is the first of a series of IdModel-based indexing PRs. The overall algorithm is exactly what I presented at the nvfuser meeting and is based on the shortest path traversal introduced at #2270. This PR only includes minimum logic for basic indexing. However, pointwise and reduction ops with TID/BID parallelization as well as reshape should work.

Notable missing support:

  • Broadcast
  • Vectorize, Unswitch, Unroll
  • Contiguous indexing

Note that the new indexing interface is not plugged into the lowering yet. Currently, it's only used by the new unit tests. In subsequent PRs, there'll be a switch to use the new indexer instead of the existing one.

Overall tracking PR: #2238

naoyam added 2 commits June 5, 2024 00:18
Only includes minimum logic for basic indexing. Notably, no support for
broadcast in this PR.
@naoyam naoyam added the idmodel label Jun 5, 2024
@naoyam naoyam requested a review from jacobhinkle June 5, 2024 07:44
@naoyam
Copy link
Collaborator Author

naoyam commented Jun 5, 2024

@jacobhinkle Please review this PR. Of course, feel free to ask any questions. As I mentioned above, this PR has lots of missing pieces but should work for indexing pointwise and reduction fusions like those used in the new unit tests. I'll continue preparing a next set of PRs.

CC: @zasdfgbnm

if (!ir_utils::isTvOp(expr)) {
continue;
}
auto tv_output = ir_utils::getTvOutput(expr);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's safe to look at only the first output because we require that any sibling tensors must be loop mapped together with one another in all dimensions since they're produced by the same expression right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, but that reminds me of the SDPA issue.

Comment on lines +678 to +687
case MemoryType::Local:
// Nothing is shared if it's Local
return false;
case MemoryType::Shared:
// Only TID parallelized domains are shared if it's Shared
return isParallelTypeThreadDim(parallel_type);
case MemoryType::Global:
// Only TID and BID parallelized domains are shared if it's Global
return isParallelTypeThreadDim(parallel_type) ||
isParallelTypeBlockDim(parallel_type);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems to me that this is related to isPartitionedMemory since isSharedMemory(memory_type, parallel_type) == (isParallelTypeThread(parallel_type) || isParallelTypeDeviceDim(parallel_type)) && !isPartitionedMemory(memory_type, parallel_type). It might be nice to write it this way since it clearly indicates that at least for the "parallelized" dimensions above serial or vectorized the notion of memory partitioning is just the inverse of sharing.

Copy link
Collaborator

@jacobhinkle jacobhinkle 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 the explanations.

@naoyam naoyam merged commit 6f9139f into main Jun 6, 2024
@naoyam naoyam deleted the idmodel_indexing_part1 branch June 6, 2024 20:02
naoyam added a commit that referenced this pull request Jun 8, 2024
Stacked on top of #2344. Adds support of broadcast indexing with loop
promotion. The main change is just the use of promoted domains in loop
and allocation domains.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants