Skip to content

Commit 719a2fa

Browse files
committed
llama : warn when a sequence crosses n_ctx_orig_yarn on LongRoPE models
1 parent 9615831 commit 719a2fa

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/llama-context.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,12 @@ int llama_context::decode(const llama_batch & batch_inp) {
18181818
do {
18191819
const auto & ubatch = mctx->get_ubatch();
18201820

1821+
const int32_t pos_max = ubatch.pos_max();
1822+
if (model.layers[0].rope_freqs == nullptr && model.layers[0].rope_long != nullptr &&
1823+
pos_max >= (int32_t) model.hparams.n_ctx_orig_yarn) {
1824+
LLAMA_LOG_WARN("%s: LongRoPE: sequence length (%d) reached n_ctx_orig_yarn (%u), switching to long rope factors, which may give approximate output\n", __func__, pos_max + 1, model.hparams.n_ctx_orig_yarn);
1825+
}
1826+
18211827
// count the outputs in this ubatch
18221828
{
18231829
int32_t n_outputs_new = 0;

0 commit comments

Comments
 (0)