fix(dashboard): llama.cpp CLI arg changes — flash-attn value, load-mode, no-cont-batching #11
Reference in New Issue
Block a user
Delete Branch "fix/llama-cli-args"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
llama.cpp latest (ghcr.io/ggml-org/llama.cpp:server-cuda) изменил несколько CLI флагов, ломая запуск llama из дашборда:
Дашборд эмитил bare флаги типа
--flash-attn, и следующий токен (--cont-batching) потреблялся как значение → parse error.Изменения в llama.cpp server
Проверил в актуальном llama.cpp/tools/server/README.md и manpage:
--flash-attn→ теперь принимает значение:[on|off|auto]. Bare флаг падает.--mlockи--no-mmap→ deprecated, заменены на unified--load-mode {auto|none|mmap|mlock|mmap+mlock|dio}.--cont-batching→ enabled по умолчанию; отключается через--no-cont-batching.--rope-scaling→ было числовое (factor), теперь enum {none,linear,yarn}. Числовой factor перенесён в--rope-scale.--metrics,--embeddings→ всё ещё bare флаги (без изменений).Fix
buildLlamaExtraArgs() (server-side, src/lib/docker.ts)
--flash-attnтеперь эмитит--flash-attn onили--flash-attn off(всегда, никогда не bare).--mlock+--no-mmap→ unified--load-mode:--load-mode mlock--load-mode mmap+mlock--load-mode none--cont-batchingбольше не эмитится (default-on). Только--no-cont-batchingесли юзер явно отключил cont-batching.--rope-scaling <N>→--rope-scale <N>(числовой factor использует новый флаг).parseLlamaExtraArgs() (читает .env)
Обновлён чтобы handle'ить и legacy, и modern синтаксис:
--flash-attn on|off|auto→ set cfg.flashAttn соответственно.--flash-attn(bare, legacy) → treated as 'on'.--load-mode mlock→ set mlock=true, noMmap=true.--load-mode mmap+mlock→ set mlock=true (noMmap остаётся false).--load-mode none→ set noMmap=true.--mlock/--no-mmap(legacy) → всё ещё парсятся для backward compat.--no-cont-batching/-nocb→ set contBatching=false.--cont-batching/-cb(legacy) → set contBatching=true (default всё равно).--rope-scaling <number>→ treated as--rope-scale <number>.--rope-scaling {none,linear,yarn}→ игнорируется (это method, не factor).--rope-scale <number>→ парсится напрямую.Добавлен helper
isValue(s)чтобы detect'ить является ли следующий токен значением или другим флагом (избегает потребление следующего флага как значения).buildPreviewArgs() (frontend, src/app/page.tsx)
Те же изменения что в buildLlamaExtraArgs — держим в sync чтобы .env preview в Config tab показывал точные args которые бу��ут переданы.
Verification
npm run build— OK, все 26 routesbash dashboard/validate-build.sh— все 8 COPY источников ✓, standalone ✓После мержа
Затем кликни 'Start Llama' — должно запуститься без ошибки flash-attn.
Files changed
dashboard/src/lib/docker.ts— buildLlamaExtraArgs + parseLlamaExtraArgsdashboard/src/app/page.tsx— buildPreviewArgs (frontend копия)## 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)