Merge pull request 'fix(dashboard): llama.cpp CLI arg changes — flash-attn value, load-mode, no-cont-batching' (#11) from fix/llama-cli-args into master

Reviewed-on: #11
This commit was merged in pull request #11.
This commit is contained in:
2026-10-24 02:04:10 +00:00
2 changed files with 81 additions and 12 deletions

View File

@@ -3786,16 +3786,24 @@ function buildPreviewArgs(cfg: DashboardConfig): string {
parts.push(`--cache-type-v ${cfg.cacheTypeV}`);
if (cfg.defragThold >= 0 && cfg.defragThold !== 0.1)
parts.push(`--defrag-thold ${cfg.defragThold}`);
if (cfg.flashAttn) parts.push("--flash-attn");
if (cfg.noMmap) parts.push("--no-mmap");
if (cfg.mlock) parts.push("--mlock");
if (cfg.contBatching) parts.push("--cont-batching");
// --flash-attn takes on/off/auto in modern llama.cpp (bare flag fails)
parts.push(`--flash-attn ${cfg.flashAttn ? "on" : "off"}`);
// --mlock / --no-mmap → unified --load-mode in modern llama.cpp
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.metrics) parts.push("--metrics");
if (cfg.ropeFreqScale !== 1.0)
parts.push(`--rope-freq-scale ${cfg.ropeFreqScale}`);
if (cfg.ropeScale !== 1.0)
parts.push(`--rope-scaling ${cfg.ropeScale}`);
parts.push(`--rope-scale ${cfg.ropeScale}`);
if (cfg.yarnExtFactor !== 1.0)
parts.push(`--yarn-ext-factor ${cfg.yarnExtFactor}`);
if (cfg.yarnAttnFactor !== 1.0)

View File

@@ -368,6 +368,10 @@ export function parseLlamaExtraArgs(
for (let i = 0; i < tokens.length; i++) {
const tok = tokens[i];
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) {
case "--ctx-size":
cfg.ctxSize = Number(next) || cfg.ctxSize;
@@ -410,7 +414,32 @@ export function parseLlamaExtraArgs(
i++;
break;
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;
case "--no-mmap":
cfg.noMmap = true;
@@ -419,8 +448,13 @@ export function parseLlamaExtraArgs(
cfg.mlock = true;
break;
case "--cont-batching":
case "-cb":
cfg.contBatching = true;
break;
case "--no-cont-batching":
case "-nocb":
cfg.contBatching = false;
break;
case "--embeddings":
cfg.embeddings = true;
break;
@@ -431,10 +465,21 @@ export function parseLlamaExtraArgs(
cfg.ropeFreqScale = Number(next) || cfg.ropeFreqScale;
i++;
break;
case "--rope-scaling":
case "--rope-scale":
cfg.ropeScale = Number(next) || cfg.ropeScale;
i++;
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":
cfg.yarnExtFactor = Number(next) || cfg.yarnExtFactor;
i++;
@@ -522,17 +567,33 @@ export function buildLlamaExtraArgs(cfg: DashboardConfig): string {
if (cfg.defragThold >= 0 && cfg.defragThold !== 0.1)
parts.push(`--defrag-thold ${cfg.defragThold}`);
// Performance flags
if (cfg.flashAttn) parts.push("--flash-attn");
if (cfg.noMmap) parts.push("--no-mmap");
if (cfg.mlock) parts.push("--mlock");
if (cfg.contBatching) parts.push("--cont-batching");
// --flash-attn takes a value (on/off/auto) since llama.cpp changed the CLI
// (https://github.com/ggml-org/llama.cpp/issues/...). Passing it as a bare
// flag causes 'unknown value for --flash-attn: <next-flag>'.
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.metrics) parts.push("--metrics");
// RoPE / YaRN
if (cfg.ropeFreqScale !== 1.0)
parts.push(`--rope-freq-scale ${cfg.ropeFreqScale}`);
if (cfg.ropeScale !== 1.0)
parts.push(`--rope-scaling ${cfg.ropeScale}`);
parts.push(`--rope-scale ${cfg.ropeScale}`);
if (cfg.yarnExtFactor !== 1.0)
parts.push(`--yarn-ext-factor ${cfg.yarnExtFactor}`);
if (cfg.yarnAttnFactor !== 1.0)