Skip to content

Commit f125e72

Browse files
committed
fix off-by-one npast during some instances of fast forwarding
1 parent f10574e commit f125e72

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

gpttype_adapter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3468,7 +3468,7 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
34683468
if (debugmode==1 && !is_quiet)
34693469
{
34703470
std::string outstr = "";
3471-
printf("\n\n[Debug: Dump Raw Input Tokens]\n");
3471+
printf("\n\n[Debug: Dump %d Raw Input Tokens]\n",embd_inp.size());
34723472
outstr += get_tok_vec_str(embd_inp);
34733473
printf("%s\n", RemoveBell(outstr).c_str());
34743474
}
@@ -3615,7 +3615,7 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
36153615
if (debugmode==1 && !is_quiet)
36163616
{
36173617
std::string outstr = "";
3618-
// printf("\n[Debug: Dump Forwarded Input Tokens, format: %d]\n", file_format);
3618+
// printf("\n[Debug: Dump Forwarded Input Tokens]\n");
36193619
// outstr += get_tok_vec_str(embd_inp);
36203620
outstr += "\n\n[Debug: n_past="+std::to_string(n_past)+" Context Size = " + std::to_string(current_context_tokens.size()) + "]\n";
36213621
outstr += get_tok_vec_str(current_context_tokens);

koboldcpp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4367,6 +4367,9 @@ def auto_set_backend_gui(manual_select=False):
43674367
def on_picked_model_file(filepath):
43684368
if filepath and (filepath.lower().endswith('.kcpps') or filepath.lower().endswith('.kcppt')):
43694369
#load it as a config file instead
4370+
if filepath.lower().endswith('.kcpps'):
4371+
global runmode_untouched
4372+
runmode_untouched = False
43704373
with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
43714374
dict = json.load(f)
43724375
import_vars(dict)

model_adapter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,10 @@ void print_tok_vec(std::vector<float> &embd)
464464

465465
//fast forward the past based on identical tokens, stop once a divergence is noted
466466
int embd_inp_len = embd_inp.size();
467+
int cur_ctx_len = current_context_tokens.size();
467468
bool fastforwardok = true;
468469

469-
for (int i = 0; i < current_context_tokens.size(); ++i)
470+
for (int i = 0; i < cur_ctx_len; ++i)
470471
{
471472
if (current_context_tokens[i] == embd_inp[i])
472473
{
@@ -500,6 +501,10 @@ void print_tok_vec(std::vector<float> &embd)
500501
{
501502
break;
502503
}
504+
if ((i + 2) >= cur_ctx_len)
505+
{
506+
break;
507+
}
503508
}
504509
}
505510

0 commit comments

Comments
 (0)