fix(dashboard): llama.cpp CLI arg changes — flash-attn value, load-mode, no-cont-batching
## Problem
llama.cpp latest (ghcr.io/ggml-org/llama.cpp:server-cuda) changed several CLI
flags, breaking llama launch from the dashboard:
error while handling argument "--flash-attn": error: unknown value for
--flash-attn: '--cont-batching'
usage:
-fa, --flash-attn [on|off|auto] set Flash Attention use ('on', 'off', or
'auto', default: 'auto')
The dashboard was emitting bare flags like `--flash-attn` and the next
token (`--cont-batching`) was being consumed as the value, causing a parse
error.
## Changes in llama.cpp server
After checking the latest llama.cpp/tools/server/README.md and manpage:
- `--flash-attn` → now takes a value: `[on|off|auto]`. Bare flag fails.
- `--mlock` and `--no-mmap` → deprecated, replaced by unified
`--load-mode {auto|none|mmap|mlock|mmap+mlock|dio}`.
- `--cont-batching` → enabled by default; disable with `--no-cont-batching`.
- `--rope-scaling` → was numeric (factor), now enum {none,linear,yarn}.
Numeric factor moved to `--rope-scale`.
- `--metrics`, `--embeddings` → still bare flags (unchanged).
## Fix
### buildLlamaExtraArgs() (server-side, in src/lib/docker.ts)
- `--flash-attn` now emits `--flash-attn on` or `--flash-attn off`
(always, never bare).
- `--mlock` + `--no-mmap` → unified `--load-mode`:
- both set → `--load-mode mlock`
- mlock only → `--load-mode mmap+mlock`
- no-mmap only → `--load-mode none`
- neither → emit nothing (default auto)
- `--cont-batching` no longer emitted (default-on). Only emit
`--no-cont-batching` if user explicitly disabled cont-batching.
- `--rope-scaling <N>` → `--rope-scale <N>` (numeric factor uses new flag).
### parseLlamaExtraArgs() (reads .env)
Updated to handle both legacy and modern syntax:
- `--flash-attn on|off|auto` → set cfg.flashAttn accordingly.
- `--flash-attn` (bare, legacy) → treated as 'on'.
- `--load-mode mlock` → set mlock=true, noMmap=true.
- `--load-mode mmap+mlock` → set mlock=true (noMmap stays false).
- `--load-mode none` → set noMmap=true.
- `--mlock` / `--no-mmap` (legacy) → still parsed for backward compat.
- `--no-cont-batching` / `-nocb` → set contBatching=false.
- `--cont-batching` / `-cb` (legacy) → set contBatching=true (default anyway).
- `--rope-scaling <number>` → treated as `--rope-scale <number>`.
- `--rope-scaling {none,linear,yarn}` → ignored (it's the method, not the factor).
- `--rope-scale <number>` → parsed directly.
Helper `isValue(s)` added to detect whether the next token is a value or
another flag (avoids consuming a following flag as a value).
### buildPreviewArgs() (frontend, in src/app/page.tsx)
Same changes as buildLlamaExtraArgs — kept in sync so the .env preview in
the Config tab shows the exact args that will be passed.
## Verification
- `npm run build` — OK, all 26 routes
- `bash dashboard/validate-build.sh` — all 8 COPY sources ✓, standalone ✓
- Manually verified the generated args by calling buildLlamaExtraArgs() with
default config — produces valid llama.cpp server CLI.
## After deploy
```sh
git pull && sh build.sh
docker compose up -d --force-recreate dashboard
```
Then click 'Start Llama' — should now launch without the flash-attn error.
## Files changed
- dashboard/src/lib/docker.ts — buildLlamaExtraArgs + parseLlamaExtraArgs
- dashboard/src/app/page.tsx — buildPreviewArgs (frontend copy)
This commit is contained in:
@@ -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