(self, x, freqs)
| 106 | |
| 107 | |
| 108 | def usp_attn_forward(self, x, freqs): |
| 109 | q = self.norm_q(self.q(x)) |
| 110 | k = self.norm_k(self.k(x)) |
| 111 | v = self.v(x) |
| 112 | |
| 113 | q = rope_apply(q, freqs, self.num_heads) |
| 114 | k = rope_apply(k, freqs, self.num_heads) |
| 115 | q = rearrange(q, "b s (n d) -> b s n d", n=self.num_heads) |
| 116 | k = rearrange(k, "b s (n d) -> b s n d", n=self.num_heads) |
| 117 | v = rearrange(v, "b s (n d) -> b s n d", n=self.num_heads) |
| 118 | |
| 119 | x = xFuserLongContextAttention()( |
| 120 | None, |
| 121 | query=q, |
| 122 | key=k, |
| 123 | value=v, |
| 124 | ) |
| 125 | x = x.flatten(2) |
| 126 | |
| 127 | del q, k, v |
| 128 | torch.cuda.empty_cache() |
| 129 | return self.o(x) |
nothing calls this directly
no test coverage detected