Add NPU condition for cosine and sine caching (#25399)

This commit is contained in:
Cheng Wan
2026-05-15 05:21:53 -07:00
committed by GitHub
parent fd9525436b
commit 3f7e538b2f
@@ -413,9 +413,10 @@ class DeepseekScalingRotaryEmbedding(RotaryEmbedding):
cos = freqs.cos() * self.mscale
sin = freqs.sin() * self.mscale
cache = torch.cat((cos, sin), dim=-1)
emb = torch.cat((freqs, freqs), dim=-1)
self.cos_cached_total = torch.cos(emb) * self.mscale
self.sin_cached_total = torch.sin(emb) * self.mscale
if _is_npu:
emb = torch.cat((freqs, freqs), dim=-1)
self.cos_cached_total = torch.cos(emb) * self.mscale
self.sin_cached_total = torch.sin(emb) * self.mscale
return cache
def get_cos_cached_total(self):