From e2b36aa6cf566d0d2dd91b96e6d77a316ce839a5 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Mon, 22 Jul 2024 15:44:34 +0800 Subject: [PATCH] fixed dry loading seq when not in use, set kcppt to -1 layers by default --- gpttype_adapter.cpp | 71 +++++++++++++++++++++++++++------------------ koboldcpp.py | 1 + 2 files changed, 44 insertions(+), 28 deletions(-) diff --git a/gpttype_adapter.cpp b/gpttype_adapter.cpp index 0b05244a3..8b92025a9 100644 --- a/gpttype_adapter.cpp +++ b/gpttype_adapter.cpp @@ -2081,40 +2081,55 @@ generation_outputs gpttype_generate(const generation_inputs inputs) // Parse dry sequence breakers / restart sequences kcpp_params->dry_sequence_breakers.clear(); - for(int x=0;xdry_sequence_breakers.push_back(word); - } - } dry_sequence_breakers.clear(); - if(kcpp_params->dry_sequence_breakers.size()>0) { - // Restrict the maximum length of sequences used as sequence breakers. There are - // very few use cases for a long sequence breaker, and limiting the max length - // prevents a potential denial of service attack in which long repetitive sequence - // breakers could result in slow DRY sampling with a suitably crafted context. - const int MAX_CHAR_LEN = 40; - const int MAX_SEQ_LEN = 20; - if(debugmode==1) { - printf("\nProcessing %zu dry break strings...",kcpp_params->dry_sequence_breakers.size()); - } - for (auto sequence_break: kcpp_params->dry_sequence_breakers) { - if (sequence_break.size() > MAX_CHAR_LEN) { - sequence_break.resize(MAX_CHAR_LEN); + if (kcpp_params->dry_multiplier > 0) + { + for (int x = 0; x < dry_seq_break_max; ++x) + { + std::string word = inputs.dry_sequence_breakers[x]; + if (word != "") + { + kcpp_params->dry_sequence_breakers.push_back(word); } - GetOverlappingTokenSequences(sequence_break, dry_sequence_breakers, MAX_SEQ_LEN); } - if(debugmode==1) { - int trivial = 0, non_trivial = 0; - for (const auto& seq: dry_sequence_breakers) { - if (seq.second.empty()) { - ++trivial; - } else { - ++non_trivial; + if (kcpp_params->dry_sequence_breakers.size() > 0) + { + // Restrict the maximum length of sequences used as sequence breakers. There are + // very few use cases for a long sequence breaker, and limiting the max length + // prevents a potential denial of service attack in which long repetitive sequence + // breakers could result in slow DRY sampling with a suitably crafted context. + const int MAX_CHAR_LEN = 40; + const int MAX_SEQ_LEN = 20; + + if (debugmode == 1) + { + printf("\nProcessing %zu dry break strings...", kcpp_params->dry_sequence_breakers.size()); + } + for (auto sequence_break : kcpp_params->dry_sequence_breakers) + { + if (sequence_break.size() > MAX_CHAR_LEN) + { + sequence_break.resize(MAX_CHAR_LEN); } + GetOverlappingTokenSequences(sequence_break, dry_sequence_breakers, MAX_SEQ_LEN); + } + if (debugmode == 1) + { + int trivial = 0, non_trivial = 0; + for (const auto &seq : dry_sequence_breakers) + { + if (seq.second.empty()) + { + ++trivial; + } + else + { + ++non_trivial; + } + } + printf("\nFound a total of %zu restart heads, %d trivial, %d non-trivial.\n", dry_sequence_breakers.size(), trivial, non_trivial); } - printf("\nFound a total of %zu restart heads, %d trivial, %d non-trivial.\n", dry_sequence_breakers.size(), trivial, non_trivial); } } diff --git a/koboldcpp.py b/koboldcpp.py index 23aa351ad..33086a1f5 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -2742,6 +2742,7 @@ def show_gui(): savdict = json.loads(json.dumps(args.__dict__)) file_type = [("KoboldCpp LaunchTemplate", "*.kcppt")] savdict["istemplate"] = True + savdict["gpulayers"] = -1 filename = asksaveasfile(filetypes=file_type, defaultextension=file_type) if filename == None: return file = open(str(filename.name), 'a')