feat(dashboard): favicon, fixed presets, more launch params, chat tab with TPS/TTFT metrics
## 1. Favicon
Added `dashboard/src/app/icon.svg` — Next.js App Router auto-detects
`src/app/icon.svg` and serves it as the browser tab icon. SVG chip design
with gradient background.
## 2. Presets — fixed 'all resets to original'
### Root cause
`POST /api/config { action: 'save-preset' }` was using `stripPresets(current)`
to snapshot the config — but `current` is the SERVER-side persisted config,
not what's currently in the UI form. If the user edited the form but didn't
click 'Apply' first, saving a preset would snapshot the OLD persisted config,
not what they see on screen.
### Fix
- API now accepts an optional `config` field in the POST body. If present,
it's merged into `current` before performing the action.
- Frontend `handleSavePreset()` now sends the current form state:
`{ action: 'save-preset', name: '...', config }`
- Refactored merge logic into a single `mergeConfig()` helper used by both
PUT and POST handlers.
This also fixes the same issue for future actions that need the current
form state.
## 3. More launch parameters
Extended `DashboardConfig` with 21 new fields, all wired into
`buildLlamaExtraArgs()` and `parseLlamaExtraArgs()`:
### KV cache
- `ubatchSize` — micro-batch size (`--ubatch-size`)
- `cacheTypeK` — K cache dtype: f16/f32/q8_0/q4_0 (`--cache-type-k`)
- `cacheTypeV` — V cache dtype (`--cache-type-v`)
- `defragThold` — KV cache defrag threshold (`--defrag-thold`)
### Performance flags (boolean toggles)
- `flashAttn` (`--flash-attn`) — enabled by default
- `contBatching` (`--cont-batching`) — enabled by default
- `noMmap` (`--no-mmap`)
- `mlock` (`--mlock`)
- `embeddings` (`--embeddings`)
- `metrics` (`--metrics`)
### RoPE / YaRN context extension
- `ropeFreqScale` (`--rope-freq-scale`)
- `ropeScale` (`--rope-scaling`)
- `yarnExtFactor` (`--yarn-ext-factor`)
- `yarnAttnFactor` (`--yarn-attn-factor`)
- `yarnBetaFast` (`--yarn-beta-fast`, default 32.0)
- `yarnBetaSlow` (`--yarn-beta-slow`, default 1.0)
### Sampling defaults (server applies to /completion by default)
- `topK` (`--top-k`)
- `topP` (`--top-p`)
- `minP` (`--min-p`)
- `temperature` (`--temp`)
- `repeatPenalty` (`--repeat-penalty`)
- `systemPrompt` — default system prompt (used by chat tab)
### UI
- 5 new sections in ConfigTab, each in a styled card with grouped fields
- ToggleRow component for boolean flags
- `buildPreviewArgs()` (the .env preview) updated to include new fields
## 4. Chat tab
New tab between Config and Models — talk to the running llama model
directly from the dashboard.
### Backend
- `POST /api/chat` — proxies llama.cpp `/v1/chat/completions`. Uses Node's
native `fetch()` to call `http://llama:8080/v1/chat/completions`
(dashboard is on the same Docker network).
- Streams SSE response back to the browser.
- Forwards sampling params: temperature, top_p, top_k, min_p,
repeat_penalty.
### Frontend
- Streaming chat with abort support (Stop button mid-generation)
- Auto-scroll toggle
- Ctrl+Enter to send
- System prompt auto-prepended from ConfigTab's `systemPrompt` field
- Per-message stats displayed under assistant responses:
* TPS (predicted_per_second)
* prompt tokens + processing time
* cache hit rate
* speculative decoding accept rate (spec_accepted / spec_drafted)
## 5. Perf tab
New tab — live performance metrics.
### Slots view (default)
Polls `GET /api/slots` every 1.5s. Shows per-slot:
- Status (processing / idle)
- ctx usage (n_past / n_ctx)
- TPS (predicted_per_second)
- TTFT (prompt_ms / 1000)
- Prompt TPS
- Cache hit rate
- Spec decoding stats (if --spec-* was used at startup):
drafted, accepted, accept rate
### Prometheus view
Polls `GET /api/metrics` (llama.cpp's /metrics endpoint). Renders raw
Prometheus exposition format as <pre>. Requires llama started with
`--metrics` flag (now a toggle in ConfigTab).
### Backend
- `GET /api/slots` — proxies llama.cpp `http://llama:8080/slots`
- `GET /api/metrics` — proxies llama.cpp `http://llama:8080/metrics`
## Files changed
- dashboard/src/app/icon.svg — new (favicon)
- dashboard/src/app/page.tsx — added ChatTab + PerfTab + ToggleRow + new
ConfigTab sections + types updates + handleSavePreset sends config
- dashboard/src/app/api/config/route.ts — mergeConfig() helper,
POST accepts optional config field
- dashboard/src/app/api/chat/route.ts — new (chat proxy with SSE streaming)
- dashboard/src/app/api/metrics/route.ts — new (Prometheus proxy)
- dashboard/src/app/api/slots/route.ts — new (slot status proxy)
- dashboard/src/lib/docker.ts — extended DashboardConfig with 21 fields,
updated buildLlamaExtraArgs() and parseLlamaExtraArgs()
## Verification
- `npm run build` — OK, 22 routes (1 page + 1 icon + 1 not-found + 19 API)
- `bash dashboard/validate-build.sh` — all 8 COPY sources ✓, standalone ✓
This commit is contained in:
@@ -194,10 +194,54 @@ export interface DashboardConfig {
|
||||
specType: "none" | "draft-mtp" | "draft-llama";
|
||||
/** Max draft tokens */
|
||||
specDraftNMax: number;
|
||||
/** Batch size */
|
||||
/** Batch size (prompt processing batch) */
|
||||
batchSize: number;
|
||||
/** Micro-batch size (physical batch on GPU) */
|
||||
ubatchSize: number;
|
||||
/** UB / KV cache size etc */
|
||||
contextOverflow: "none" | "shift" | "evict";
|
||||
/** KV cache type for K */
|
||||
cacheTypeK: "f16" | "f32" | "q8_0" | "q4_0";
|
||||
/** KV cache type for V */
|
||||
cacheTypeV: "f16" | "f32" | "q8_0" | "q4_0";
|
||||
/** KV cache defragmentation threshold (0..1) */
|
||||
defragThold: number;
|
||||
/** Enable Flash Attention */
|
||||
flashAttn: boolean;
|
||||
/** Don't mmap model (load to RAM) */
|
||||
noMmap: boolean;
|
||||
/** Lock model in RAM (prevents swap) */
|
||||
mlock: boolean;
|
||||
/** Continuous batching */
|
||||
contBatching: boolean;
|
||||
/** Enable /embeddings endpoint */
|
||||
embeddings: boolean;
|
||||
/** Enable /metrics (Prometheus) endpoint */
|
||||
metrics: boolean;
|
||||
/** RoPE frequency scale (NTK-aware, 1.0 = default) */
|
||||
ropeFreqScale: number;
|
||||
/** RoPE context scaling factor (1.0 = default) */
|
||||
ropeScale: number;
|
||||
/** YaRN extrapolation factor (1.0 = default) */
|
||||
yarnExtFactor: number;
|
||||
/** YaRN attention factor (1.0 = default) */
|
||||
yarnAttnFactor: number;
|
||||
/** YaRN beta fast (32.0 = default) */
|
||||
yarnBetaFast: number;
|
||||
/** YaRN beta slow (1.0 = default) */
|
||||
yarnBetaSlow: number;
|
||||
/** Default system prompt for chat completions (empty = none) */
|
||||
systemPrompt: string;
|
||||
/** Sampling: top-k (0 = disabled) */
|
||||
topK: number;
|
||||
/** Sampling: top-p (1.0 = disabled) */
|
||||
topP: number;
|
||||
/** Sampling: min-p (0 = disabled) */
|
||||
minP: number;
|
||||
/** Sampling: temperature (1.0 = default) */
|
||||
temperature: number;
|
||||
/** Sampling: repeat penalty (1.0 = disabled) */
|
||||
repeatPenalty: number;
|
||||
/** Free-form extra args (advanced) */
|
||||
extraArgs: string;
|
||||
/** Saved presets */
|
||||
@@ -221,7 +265,29 @@ export const DEFAULT_CONFIG: DashboardConfig = {
|
||||
specType: "none",
|
||||
specDraftNMax: 4,
|
||||
batchSize: 512,
|
||||
ubatchSize: 512,
|
||||
contextOverflow: "none",
|
||||
cacheTypeK: "f16",
|
||||
cacheTypeV: "f16",
|
||||
defragThold: 0.1,
|
||||
flashAttn: true,
|
||||
noMmap: false,
|
||||
mlock: false,
|
||||
contBatching: true,
|
||||
embeddings: false,
|
||||
metrics: false,
|
||||
ropeFreqScale: 1.0,
|
||||
ropeScale: 1.0,
|
||||
yarnExtFactor: 1.0,
|
||||
yarnAttnFactor: 1.0,
|
||||
yarnBetaFast: 32.0,
|
||||
yarnBetaSlow: 1.0,
|
||||
systemPrompt: "",
|
||||
topK: 40,
|
||||
topP: 0.95,
|
||||
minP: 0.05,
|
||||
temperature: 0.8,
|
||||
repeatPenalty: 1.1,
|
||||
extraArgs: "",
|
||||
presets: [],
|
||||
};
|
||||
@@ -316,6 +382,86 @@ export function parseLlamaExtraArgs(
|
||||
cfg.batchSize = Number(next) || cfg.batchSize;
|
||||
i++;
|
||||
break;
|
||||
case "--ubatch-size":
|
||||
case "-ub":
|
||||
cfg.ubatchSize = Number(next) || cfg.ubatchSize;
|
||||
i++;
|
||||
break;
|
||||
case "--cache-type-k":
|
||||
cfg.cacheTypeK = (next as DashboardConfig["cacheTypeK"]) || cfg.cacheTypeK;
|
||||
i++;
|
||||
break;
|
||||
case "--cache-type-v":
|
||||
cfg.cacheTypeV = (next as DashboardConfig["cacheTypeV"]) || cfg.cacheTypeV;
|
||||
i++;
|
||||
break;
|
||||
case "--defrag-thold":
|
||||
cfg.defragThold = Number(next) || cfg.defragThold;
|
||||
i++;
|
||||
break;
|
||||
case "--flash-attn":
|
||||
cfg.flashAttn = true;
|
||||
break;
|
||||
case "--no-mmap":
|
||||
cfg.noMmap = true;
|
||||
break;
|
||||
case "--mlock":
|
||||
cfg.mlock = true;
|
||||
break;
|
||||
case "--cont-batching":
|
||||
cfg.contBatching = true;
|
||||
break;
|
||||
case "--embeddings":
|
||||
cfg.embeddings = true;
|
||||
break;
|
||||
case "--metrics":
|
||||
cfg.metrics = true;
|
||||
break;
|
||||
case "--rope-freq-scale":
|
||||
cfg.ropeFreqScale = Number(next) || cfg.ropeFreqScale;
|
||||
i++;
|
||||
break;
|
||||
case "--rope-scaling":
|
||||
cfg.ropeScale = Number(next) || cfg.ropeScale;
|
||||
i++;
|
||||
break;
|
||||
case "--yarn-ext-factor":
|
||||
cfg.yarnExtFactor = Number(next) || cfg.yarnExtFactor;
|
||||
i++;
|
||||
break;
|
||||
case "--yarn-attn-factor":
|
||||
cfg.yarnAttnFactor = Number(next) || cfg.yarnAttnFactor;
|
||||
i++;
|
||||
break;
|
||||
case "--yarn-beta-fast":
|
||||
cfg.yarnBetaFast = Number(next) || cfg.yarnBetaFast;
|
||||
i++;
|
||||
break;
|
||||
case "--yarn-beta-slow":
|
||||
cfg.yarnBetaSlow = Number(next) || cfg.yarnBetaSlow;
|
||||
i++;
|
||||
break;
|
||||
case "--top-k":
|
||||
cfg.topK = Number(next);
|
||||
i++;
|
||||
break;
|
||||
case "--top-p":
|
||||
cfg.topP = Number(next);
|
||||
i++;
|
||||
break;
|
||||
case "--min-p":
|
||||
cfg.minP = Number(next);
|
||||
i++;
|
||||
break;
|
||||
case "--temp":
|
||||
case "--temperature":
|
||||
cfg.temperature = Number(next);
|
||||
i++;
|
||||
break;
|
||||
case "--repeat-penalty":
|
||||
cfg.repeatPenalty = Number(next);
|
||||
i++;
|
||||
break;
|
||||
case "--model-draft":
|
||||
cfg.draftModel = path.basename(next || "");
|
||||
i++;
|
||||
@@ -357,8 +503,35 @@ export function buildLlamaExtraArgs(cfg: DashboardConfig): string {
|
||||
if (cfg.nGpuLayers >= 0) parts.push(`--n-gpu-layers ${cfg.nGpuLayers}`);
|
||||
if (cfg.threads > 0) parts.push(`--threads ${cfg.threads}`);
|
||||
parts.push(`--batch-size ${cfg.batchSize}`);
|
||||
parts.push(`--ubatch-size ${cfg.ubatchSize}`);
|
||||
if (cfg.contextOverflow !== "none")
|
||||
parts.push(`--context-overflow ${cfg.contextOverflow}`);
|
||||
// KV cache types
|
||||
parts.push(`--cache-type-k ${cfg.cacheTypeK}`);
|
||||
parts.push(`--cache-type-v ${cfg.cacheTypeV}`);
|
||||
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");
|
||||
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}`);
|
||||
if (cfg.yarnExtFactor !== 1.0)
|
||||
parts.push(`--yarn-ext-factor ${cfg.yarnExtFactor}`);
|
||||
if (cfg.yarnAttnFactor !== 1.0)
|
||||
parts.push(`--yarn-attn-factor ${cfg.yarnAttnFactor}`);
|
||||
if (cfg.yarnBetaFast !== 32.0)
|
||||
parts.push(`--yarn-beta-fast ${cfg.yarnBetaFast}`);
|
||||
if (cfg.yarnBetaSlow !== 1.0)
|
||||
parts.push(`--yarn-beta-slow ${cfg.yarnBetaSlow}`);
|
||||
// Speculative decoding
|
||||
if (cfg.specType !== "none") {
|
||||
parts.push(`--spec-type ${cfg.specType}`);
|
||||
if (cfg.draftModel) {
|
||||
@@ -366,6 +539,13 @@ export function buildLlamaExtraArgs(cfg: DashboardConfig): string {
|
||||
parts.push(`--spec-draft-n-max ${cfg.specDraftNMax}`);
|
||||
}
|
||||
}
|
||||
// Default sampling (server applies these as defaults for /completion)
|
||||
if (cfg.topK > 0) parts.push(`--top-k ${cfg.topK}`);
|
||||
if (cfg.topP < 1.0) parts.push(`--top-p ${cfg.topP}`);
|
||||
if (cfg.minP > 0) parts.push(`--min-p ${cfg.minP}`);
|
||||
if (cfg.temperature !== 1.0) parts.push(`--temp ${cfg.temperature}`);
|
||||
if (cfg.repeatPenalty > 1.0)
|
||||
parts.push(`--repeat-penalty ${cfg.repeatPenalty}`);
|
||||
if (cfg.extraArgs.trim()) parts.push(cfg.extraArgs.trim());
|
||||
return parts.join(" ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user