Disable growth and make the failure explicit

This commit is contained in:
Dipesh Babu 2026-02-28 01:51:31 -05:00 committed by GitHub
parent b661d41ffd
commit 16a679c911
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -179,8 +179,7 @@ class GPT(nn.Module):
# Precompute a reasonably large RoPE cache up front (cheap relative to model weights).
# The cache may also grow lazily in forward() if generation exceeds this length.
self.rotary_seq_len = config.sequence_len * 10
# Bound lazy growth to avoid unbounded memory usage during very long generation runs.
self.max_rotary_seq_len = max(self.rotary_seq_len, config.sequence_len * 64)
self.max_rotary_seq_len = self.rotary_seq_len
head_dim = config.n_embd // config.n_head
cos, sin = self._precompute_rotary_embeddings(self.rotary_seq_len, head_dim)