fix(gemma4): cast RoPE offset to int before mx.arange() (#4901)
* fix(gemma4): cast RoPE offset to int before mx.arange() * fix(gemma4): use zero-based arange + offset to avoid CPU-GPU sync
This commit is contained in:
parent
324bdf429d
commit
f1041f885f
1 changed files with 1 additions and 1 deletions
|
|
@ -247,7 +247,7 @@ class ProportionalRoPE(nn.Module):
|
|||
def __call__(self, x: mx.array, offset: int = 0) -> mx.array:
|
||||
# x shape: (B, n_heads, L, head_dim)
|
||||
seq_len = x.shape[-2]
|
||||
positions = mx.arange(offset, offset + seq_len, dtype = mx.float32)
|
||||
positions = mx.arange(seq_len, dtype = mx.float32) + offset
|
||||
|
||||
# (L, head_dim//2)
|
||||
freqs = mx.outer(positions, self._inv_freq)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue