diff --git a/gpt4all-chat/chatllm.cpp b/gpt4all-chat/chatllm.cpp index cdb89fe8..4f87d150 100644 --- a/gpt4all-chat/chatllm.cpp +++ b/gpt4all-chat/chatllm.cpp @@ -461,8 +461,6 @@ bool ChatLLM::promptInternal(const QList &collectionList, const QString QString instructPrompt = augmentedTemplate.join("\n").arg(prompt); int n_threads = MySettings::globalInstance()->threadCount(); - if (n_threads <= 0) - n_threads = std::min(4, (int32_t) std::thread::hardware_concurrency()); m_stopGenerating = false; auto promptFunc = std::bind(&ChatLLM::handlePrompt, this, std::placeholders::_1); @@ -773,8 +771,6 @@ void ChatLLM::processSystemPrompt() const float repeat_penalty = MySettings::globalInstance()->modelRepeatPenalty(m_modelInfo); const int32_t repeat_penalty_tokens = MySettings::globalInstance()->modelRepeatPenaltyTokens(m_modelInfo); int n_threads = MySettings::globalInstance()->threadCount(); - if (n_threads <= 0) - n_threads = std::min(4, (int32_t) std::thread::hardware_concurrency()); m_ctx.n_predict = n_predict; m_ctx.top_k = top_k; m_ctx.top_p = top_p; diff --git a/gpt4all-chat/mysettings.cpp b/gpt4all-chat/mysettings.cpp index 6d40d76a..9a4e17ff 100644 --- a/gpt4all-chat/mysettings.cpp +++ b/gpt4all-chat/mysettings.cpp @@ -8,7 +8,7 @@ #include #include -static int default_threadCount = 0; +static int default_threadCount = std::min(4, (int32_t) std::thread::hardware_concurrency()); static bool default_saveChats = false; static bool default_saveChatGPTChats = true; static bool default_serverChat = false; @@ -349,7 +349,10 @@ int MySettings::threadCount() const { QSettings setting; setting.sync(); - return setting.value("threadCount", default_threadCount).toInt(); + int c = setting.value("threadCount", default_threadCount).toInt(); + c = std::max(c, 1); + c = std::min(c, QThread::idealThreadCount()); + return c; } void MySettings::setThreadCount(int c) @@ -357,6 +360,8 @@ void MySettings::setThreadCount(int c) if (threadCount() == c) return; + c = std::max(c, 1); + c = std::min(c, QThread::idealThreadCount()); QSettings setting; setting.setValue("threadCount", c); setting.sync(); diff --git a/gpt4all-chat/qml/ApplicationSettings.qml b/gpt4all-chat/qml/ApplicationSettings.qml index b0208aac..15333b7c 100644 --- a/gpt4all-chat/qml/ApplicationSettings.qml +++ b/gpt4all-chat/qml/ApplicationSettings.qml @@ -101,7 +101,7 @@ MySettingsTab { MyTextField { text: MySettings.threadCount color: theme.textColor - ToolTip.text: qsTr("Amount of processing threads to use, a setting of 0 will use the lesser of 4 or your number of CPU threads") + ToolTip.text: qsTr("Amount of processing threads to use bounded by 1 and number of logical processors") ToolTip.visible: hovered Layout.row: 3 Layout.column: 1