Skip to content

Commit 3bef819

Browse files
authored
[Bugfix] fix rope sin/cos cache bug (#1267)
cherry-pick to 0.9.1-dev Signed-off-by: whx-sjtu <2952154980@qq.com>
1 parent d798125 commit 3bef819

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

vllm_ascend/ops/rotary_embedding.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ def _set_cos_sin_cache(self, seq_len, device, dtype):
219219
inv_freq = freq_inter * (1 - inv_freq_mask) + freq_extra * inv_freq_mask
220220
self.register_buffer("inv_freq", inv_freq, persistent=False)
221221

222-
t = torch.arange(seq_len, device=device, dtype=torch.float32)
222+
t = torch.arange(seq_len * self.scaling_factor,
223+
device=device,
224+
dtype=torch.float32)
223225

224226
freqs = torch.outer(t, inv_freq)
225227
cos_cached = torch.cat([freqs, freqs], dim=-1).cos() * self.mscale

0 commit comments

Comments
 (0)