MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / usp_attn_forward

Function usp_attn_forward

diffsynth/distributed/xdit_context_parallel.py:108–129  ·  view source on GitHub ↗
(self, x, freqs)

Source from the content-addressed store, hash-verified

106
107
108def 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)

Callers

nothing calls this directly

Calls 1

rope_applyFunction · 0.70

Tested by

no test coverage detected