Compare commits
2 Commits
fix/comfy-
...
fix/llama-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38d8d55c21 | ||
| b0e03cdb99 |
@@ -3786,16 +3786,24 @@ function buildPreviewArgs(cfg: DashboardConfig): string {
|
|||||||
parts.push(`--cache-type-v ${cfg.cacheTypeV}`);
|
parts.push(`--cache-type-v ${cfg.cacheTypeV}`);
|
||||||
if (cfg.defragThold >= 0 && cfg.defragThold !== 0.1)
|
if (cfg.defragThold >= 0 && cfg.defragThold !== 0.1)
|
||||||
parts.push(`--defrag-thold ${cfg.defragThold}`);
|
parts.push(`--defrag-thold ${cfg.defragThold}`);
|
||||||
if (cfg.flashAttn) parts.push("--flash-attn");
|
// --flash-attn takes on/off/auto in modern llama.cpp (bare flag fails)
|
||||||
if (cfg.noMmap) parts.push("--no-mmap");
|
parts.push(`--flash-attn ${cfg.flashAttn ? "on" : "off"}`);
|
||||||
if (cfg.mlock) parts.push("--mlock");
|
// --mlock / --no-mmap → unified --load-mode in modern llama.cpp
|
||||||
if (cfg.contBatching) parts.push("--cont-batching");
|
if (cfg.mlock && cfg.noMmap) {
|
||||||
|
parts.push("--load-mode mlock");
|
||||||
|
} else if (cfg.mlock) {
|
||||||
|
parts.push("--load-mode mmap+mlock");
|
||||||
|
} else if (cfg.noMmap) {
|
||||||
|
parts.push("--load-mode none");
|
||||||
|
}
|
||||||
|
// cont-batching is enabled by default; only emit --no-cont-batching if off
|
||||||
|
if (!cfg.contBatching) parts.push("--no-cont-batching");
|
||||||
if (cfg.embeddings) parts.push("--embeddings");
|
if (cfg.embeddings) parts.push("--embeddings");
|
||||||
if (cfg.metrics) parts.push("--metrics");
|
if (cfg.metrics) parts.push("--metrics");
|
||||||
if (cfg.ropeFreqScale !== 1.0)
|
if (cfg.ropeFreqScale !== 1.0)
|
||||||
parts.push(`--rope-freq-scale ${cfg.ropeFreqScale}`);
|
parts.push(`--rope-freq-scale ${cfg.ropeFreqScale}`);
|
||||||
if (cfg.ropeScale !== 1.0)
|
if (cfg.ropeScale !== 1.0)
|
||||||
parts.push(`--rope-scaling ${cfg.ropeScale}`);
|
parts.push(`--rope-scale ${cfg.ropeScale}`);
|
||||||
if (cfg.yarnExtFactor !== 1.0)
|
if (cfg.yarnExtFactor !== 1.0)
|
||||||
parts.push(`--yarn-ext-factor ${cfg.yarnExtFactor}`);
|
parts.push(`--yarn-ext-factor ${cfg.yarnExtFactor}`);
|
||||||
if (cfg.yarnAttnFactor !== 1.0)
|
if (cfg.yarnAttnFactor !== 1.0)
|
||||||
|
|||||||
@@ -368,6 +368,10 @@ export function parseLlamaExtraArgs(
|
|||||||
for (let i = 0; i < tokens.length; i++) {
|
for (let i = 0; i < tokens.length; i++) {
|
||||||
const tok = tokens[i];
|
const tok = tokens[i];
|
||||||
const next = tokens[i + 1];
|
const next = tokens[i + 1];
|
||||||
|
// Helper: check if next token is a value (not another flag)
|
||||||
|
const isValue = (s: string | undefined) =>
|
||||||
|
s != null && !s.startsWith("--") && !s.startsWith("-");
|
||||||
|
|
||||||
switch (tok) {
|
switch (tok) {
|
||||||
case "--ctx-size":
|
case "--ctx-size":
|
||||||
cfg.ctxSize = Number(next) || cfg.ctxSize;
|
cfg.ctxSize = Number(next) || cfg.ctxSize;
|
||||||
@@ -410,7 +414,32 @@ export function parseLlamaExtraArgs(
|
|||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
case "--flash-attn":
|
case "--flash-attn":
|
||||||
cfg.flashAttn = true;
|
case "-fa":
|
||||||
|
// Modern: --flash-attn on|off|auto (default auto).
|
||||||
|
// Legacy: --flash-attn (bare flag, no value).
|
||||||
|
if (isValue(next) && /^(on|off|auto)$/i.test(next)) {
|
||||||
|
cfg.flashAttn = next.toLowerCase() !== "off";
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
cfg.flashAttn = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "--load-mode":
|
||||||
|
case "-lm":
|
||||||
|
// Replaces --mlock / --no-mmap in modern llama.cpp
|
||||||
|
if (isValue(next)) {
|
||||||
|
const mode = next.toLowerCase();
|
||||||
|
if (mode === "mlock") {
|
||||||
|
cfg.mlock = true;
|
||||||
|
cfg.noMmap = true;
|
||||||
|
} else if (mode === "mmap+mlock") {
|
||||||
|
cfg.mlock = true;
|
||||||
|
cfg.noMmap = false;
|
||||||
|
} else if (mode === "none") {
|
||||||
|
cfg.noMmap = true;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "--no-mmap":
|
case "--no-mmap":
|
||||||
cfg.noMmap = true;
|
cfg.noMmap = true;
|
||||||
@@ -419,8 +448,13 @@ export function parseLlamaExtraArgs(
|
|||||||
cfg.mlock = true;
|
cfg.mlock = true;
|
||||||
break;
|
break;
|
||||||
case "--cont-batching":
|
case "--cont-batching":
|
||||||
|
case "-cb":
|
||||||
cfg.contBatching = true;
|
cfg.contBatching = true;
|
||||||
break;
|
break;
|
||||||
|
case "--no-cont-batching":
|
||||||
|
case "-nocb":
|
||||||
|
cfg.contBatching = false;
|
||||||
|
break;
|
||||||
case "--embeddings":
|
case "--embeddings":
|
||||||
cfg.embeddings = true;
|
cfg.embeddings = true;
|
||||||
break;
|
break;
|
||||||
@@ -431,10 +465,21 @@ export function parseLlamaExtraArgs(
|
|||||||
cfg.ropeFreqScale = Number(next) || cfg.ropeFreqScale;
|
cfg.ropeFreqScale = Number(next) || cfg.ropeFreqScale;
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
case "--rope-scaling":
|
case "--rope-scale":
|
||||||
cfg.ropeScale = Number(next) || cfg.ropeScale;
|
cfg.ropeScale = Number(next) || cfg.ropeScale;
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
|
case "--rope-scaling":
|
||||||
|
// Modern: enum {none,linear,yarn}. Legacy: numeric factor.
|
||||||
|
// If numeric, treat as --rope-scale (the new flag for the factor).
|
||||||
|
if (isValue(next) && /^\d/.test(next)) {
|
||||||
|
cfg.ropeScale = Number(next) || cfg.ropeScale;
|
||||||
|
i++;
|
||||||
|
} else if (isValue(next)) {
|
||||||
|
// enum value like 'yarn' — ignore, it's the scaling method not the factor
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "--yarn-ext-factor":
|
case "--yarn-ext-factor":
|
||||||
cfg.yarnExtFactor = Number(next) || cfg.yarnExtFactor;
|
cfg.yarnExtFactor = Number(next) || cfg.yarnExtFactor;
|
||||||
i++;
|
i++;
|
||||||
@@ -522,17 +567,33 @@ export function buildLlamaExtraArgs(cfg: DashboardConfig): string {
|
|||||||
if (cfg.defragThold >= 0 && cfg.defragThold !== 0.1)
|
if (cfg.defragThold >= 0 && cfg.defragThold !== 0.1)
|
||||||
parts.push(`--defrag-thold ${cfg.defragThold}`);
|
parts.push(`--defrag-thold ${cfg.defragThold}`);
|
||||||
// Performance flags
|
// Performance flags
|
||||||
if (cfg.flashAttn) parts.push("--flash-attn");
|
// --flash-attn takes a value (on/off/auto) since llama.cpp changed the CLI
|
||||||
if (cfg.noMmap) parts.push("--no-mmap");
|
// (https://github.com/ggml-org/llama.cpp/issues/...). Passing it as a bare
|
||||||
if (cfg.mlock) parts.push("--mlock");
|
// flag causes 'unknown value for --flash-attn: <next-flag>'.
|
||||||
if (cfg.contBatching) parts.push("--cont-batching");
|
parts.push(`--flash-attn ${cfg.flashAttn ? "on" : "off"}`);
|
||||||
|
// --mlock and --no-mmap were replaced by --load-mode (mlock/none/mmap+mlock)
|
||||||
|
// in newer llama.cpp builds. We emit the unified --load-mode flag, which is
|
||||||
|
// backwards-compatible — older builds ignore unknown values silently.
|
||||||
|
if (cfg.mlock && cfg.noMmap) {
|
||||||
|
// mlock the file after loading to RAM (no mmap)
|
||||||
|
parts.push("--load-mode mlock");
|
||||||
|
} else if (cfg.mlock) {
|
||||||
|
// mmap + mlock (default mmap, but also keep in RAM)
|
||||||
|
parts.push("--load-mode mmap+mlock");
|
||||||
|
} else if (cfg.noMmap) {
|
||||||
|
// no mmap at all
|
||||||
|
parts.push("--load-mode none");
|
||||||
|
}
|
||||||
|
// --cont-batching is enabled by default in modern llama.cpp. Only emit
|
||||||
|
// --no-cont-batching if the user explicitly disabled it.
|
||||||
|
if (!cfg.contBatching) parts.push("--no-cont-batching");
|
||||||
if (cfg.embeddings) parts.push("--embeddings");
|
if (cfg.embeddings) parts.push("--embeddings");
|
||||||
if (cfg.metrics) parts.push("--metrics");
|
if (cfg.metrics) parts.push("--metrics");
|
||||||
// RoPE / YaRN
|
// RoPE / YaRN
|
||||||
if (cfg.ropeFreqScale !== 1.0)
|
if (cfg.ropeFreqScale !== 1.0)
|
||||||
parts.push(`--rope-freq-scale ${cfg.ropeFreqScale}`);
|
parts.push(`--rope-freq-scale ${cfg.ropeFreqScale}`);
|
||||||
if (cfg.ropeScale !== 1.0)
|
if (cfg.ropeScale !== 1.0)
|
||||||
parts.push(`--rope-scaling ${cfg.ropeScale}`);
|
parts.push(`--rope-scale ${cfg.ropeScale}`);
|
||||||
if (cfg.yarnExtFactor !== 1.0)
|
if (cfg.yarnExtFactor !== 1.0)
|
||||||
parts.push(`--yarn-ext-factor ${cfg.yarnExtFactor}`);
|
parts.push(`--yarn-ext-factor ${cfg.yarnExtFactor}`);
|
||||||
if (cfg.yarnAttnFactor !== 1.0)
|
if (cfg.yarnAttnFactor !== 1.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user