Uh oh!
There was an error while loading. Please reload this page.
[PyTorch][Common] Refactor RoPE - #1626
Conversation
Signed-off-by: Xin Yao <xiny@nvidia.com>
Signed-off-by: Xin Yao <xiny@nvidia.com>
Uh oh!
There was an error while loading. Please reload this page.
tomlifu
commented
Mar 31, 2025
Rotary interleaved part looks good to me. |
Signed-off-by: Xin Yao <xiny@nvidia.com>
yaox12
commented
Apr 1, 2025
/te-ci pytorch |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| if tensor_format == "sbhd": | ||
| output = tex.fused_rope_forward(t, freqs, False) | ||
| elif tensor_format == "bshd": | ||
| output = tex.fused_rope_forward(t.transpose(0, 1), freqs, True).transpose(0, 1) |
There was a problem hiding this comment.
curious where the t.transpose happens now
There was a problem hiding this comment.
Previously, the C++ interface fused_rope_forward only accepts sbhd format, so for bshd we hack it by transposing bshd to sbhd and then transposing the result back. There was a flag called transpose_output_memory to make sure the transpose of result doesn't really do a memory copy. This method is not intuitive. Now I add a new argument qkv_format to support all formats natively.
Uh oh!
There was an error while loading. Please reload this page.
Signed-off-by: Xin Yao <xiny@nvidia.com>
yaox12
commented
Apr 7, 2025
/te-ci pytorch |
yaox12
commented
Apr 7, 2025
CI passed except for irrelevant failures and Blackwell runners got stuck. |
* refactor to add cp support for sbhd/bshd Signed-off-by: Xin Yao <xiny@nvidia.com> * support interleaved Signed-off-by: Xin Yao <xiny@nvidia.com> * format Signed-off-by: Xin Yao <xiny@nvidia.com> * add interleaved to RotaryPositionEmbedding in test Signed-off-by: Xin Yao <xiny@nvidia.com> * update Signed-off-by: Xin Yao <xiny@nvidia.com> * merge sbhd/bshd and thd functions Signed-off-by: Xin Yao <xiny@nvidia.com> --------- Signed-off-by: Xin Yao <xiny@nvidia.com> Signed-off-by: Peter Dykas <wdykas@nvidia.com>
Description
Refactor RoPE to
freqstensor is required to be the full tensor.freqstensor is supposed to be the full tensor with the THD format while sliced (outside of TE) with other formats (sbhd/bshd). This PR unifies them.apply_rotary_pos_embdoesn't acceptcp_sizeandcp_rankfor sbhd and bshd, so passing slicedfreqswithcp_size = 1andcp_rank = 0should still work as before.interleavedmode.Type of change
Changes
Please list the changes introduced in this PR:
Checklist: