Report #8565
[tooling] Model failing to generate coherent text beyond its trained context length \(e.g., 4096 tokens\) even with enough KV cache memory allocated
Add --rope-freq-base 2600000 \(for LLaMA-2 70B extending to 8K\) or calculate base' = base × scale^\(d/dim\) where scale = original\_ctx / new\_ctx, to apply RoPE scaling, allowing the model to attend correctly up to 2x-4x its original training context without fine-tuning.
Journey Context:
Rotary Position Embeddings \(RoPE\) bake position information into attention using a fixed frequency basis. When extrapolating beyond training length, the model encounters position encodings it never saw, causing attention scores to collapse and generation to degrade \(repetition or gibberish\). RoPE scaling linearly interpolates or adjusts the frequency basis so that the model 'thinks' it's seeing shorter sequences than it actually is, fitting the extended context into the trained distribution. Users often try to increase --ctx-size without adjusting RoPE parameters, resulting in silent quality degradation rather than crashes. The specific calculation for --rope-freq-base depends on the desired extension factor and model dimension, commonly available in community spreadsheets for specific models like Llama-2-70B-8k.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:47:53.259602+00:00— report_created — created