Load persistent RoPE buffers in lm-eval
Browse files- modeling_tiger_alpha.py +7 -2
modeling_tiger_alpha.py
CHANGED
|
@@ -49,8 +49,13 @@ class TigerAlphaRotaryEmbedding(nn.Module):
|
|
| 49 |
positions = torch.arange(config.max_position_embeddings).float()
|
| 50 |
frequencies = torch.outer(positions, inverse)
|
| 51 |
angles = torch.cat((frequencies, frequencies), dim=-1)
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
def forward(
|
| 56 |
self,
|
|
|
|
| 49 |
positions = torch.arange(config.max_position_embeddings).float()
|
| 50 |
frequencies = torch.outer(positions, inverse)
|
| 51 |
angles = torch.cat((frequencies, frequencies), dim=-1)
|
| 52 |
+
# These deterministic caches must be checkpointed. Hugging Face can
|
| 53 |
+
# instantiate remote-code models under a low-memory/meta-device
|
| 54 |
+
# context; non-persistent RoPE buffers can then remain invalid after
|
| 55 |
+
# loading and make every continuation log-probability NaN. This is the
|
| 56 |
+
# same export/load issue fixed in the original partial-Edu model.
|
| 57 |
+
self.register_buffer("cosine", angles.cos(), persistent=True)
|
| 58 |
+
self.register_buffer("sine", angles.sin(), persistent=True)
|
| 59 |
|
| 60 |
def forward(
|
| 61 |
self,
|