Skip to content

Conversation

@junrushao
Copy link
Member

This PR improves the Decode-GEMV scheduling by further analyzing its epilogue pattern.

The existing behavior assumes that the outcome of cross-thread reduction stays in register files local to each thread, which is further used to calculate the epilogue in the same thread.

This strategy means the cross-thread reduction outcome is stored only on thread 0, while the other threads cannot participate in subsequent computation (i.e. epilogue). Related: #15192.

When the epilogue is relatively lightweight, i.e. elementwise add, casting on scalars, this strategy is optimal. However, once the outcome needs to be broadcasted to compute over a non-trivial region, for example, act as a normalizer of np.mean, it would become much slower because only one thread in a thread block is effectively used.

In this case, we will need to broadcast the cross-thread reduction outcome in shared memory, making it visible to other threads, and then bind the compute region to all threads in the threadblock.

This PR improves the Decode-GEMV scheduling by further analyzing its
epilogue pattern.

The existing behavior assumes that the outcome of cross-thread reduction
stays in register files local to each thread, which is further used to
calculate the epilogue in the same thread.

This strategy means the cross-thread reduction outcome is stored only on
thread 0, while the other threads cannot participate in subsequent
computation (i.e. epilogue). Related: apache#15192.

When the epilogue is relatively lightweight, i.e. elementwise add,
casting on scalars, this strategy is optimal. However, once the outcome
needs to be broadcasted to compute over a non-trivial region, for
example, act as a normalizer of `np.mean`, it would become much slower
because only one thread in a thread block is effectively used.

In this case, we will need to broadcast the cross-thread reduction
outcome in shared memory, making it visible to other threads, and then
bind the compute region to all threads in the threadblock.
@tvm-bot
Copy link
Collaborator

tvm-bot commented Jul 6, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@junrushao junrushao marked this pull request as ready for review July 6, 2023 05:45
@junrushao
Copy link
Member Author

CC @MasterJH5574 on cross-thread reduction, @Hzfengsy and @spectrometerHBH for e2e performance

@tqchen tqchen merged commit 15a6b47 into apache:unity Jul 6, 2023
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.

4 participants