mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
Provide some guardrails for thread count.
This commit is contained in:
parent
a190041c6e
commit
99cd555743
@ -461,8 +461,6 @@ bool ChatLLM::promptInternal(const QList<QString> &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;
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QUrl>
|
||||
|
||||
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();
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user