Merge branch 'usp' into xdit

This commit is contained in:
ByteDance
2025-03-25 11:45:49 +08:00
6 changed files with 169 additions and 2 deletions

View File

@@ -90,6 +90,7 @@ def rope_apply(x, freqs, num_heads):
x = rearrange(x, "b s (n d) -> b s n d", n=num_heads)
x_out = torch.view_as_complex(x.to(torch.float64).reshape(
x.shape[0], x.shape[1], x.shape[2], -1, 2))
x_out = torch.view_as_real(x_out * freqs).flatten(2)
return x_out.to(x.dtype)