Files
GPU-Node/dashboard
Z User ab60962d76 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 ✓
2026-10-24 01:26:21 +00:00
..

GPU-Node Dashboard

A small Next.js web dashboard for managing the llama.cpp instance running on the GPU node. Replaces the need to manually edit .env and call gpuctl over SSH.

Features

  • Status overview — live view of all containers (llama, ssh, comfyui, etc.) for the current node instance, with health check + auto-refresh.
  • Models list — scans gpu/llama_models/*.gguf and shows sizes / modified time; click "Use" to switch the active model in the launch config.
  • Launch config — structured form for --ctx-size, --parallel, --n-gpu-layers, --threads, --batch-size, --context-overflow, speculative decoding (--spec-type, --model-draft, --spec-draft-n-max), and a free-form extra args textarea for anything else.
  • Presets — save named configurations and reload them with one click.
  • Start / Restart / Stop / Remove llama container via docker compose.
  • Live logs — streaming docker logs -f with color-coded output.
  • GPU status — runs nvidia-smi via docker exec on the llama container (or falls back to docker compose run --rm gpu-test nvidia-smi ...).
  • Auto-writes .env — every "Apply / Start" persists the current LLAMA_MODEL and LLAMA_EXTRA_ARGS back to .env, so the existing workflow keeps working.

How it integrates

The dashboard runs as a new dashboard service in compose.yaml. It mounts:

  • /var/run/docker.sock → can run docker compose and docker ps commands
  • The host project path (read/write so it can edit .env and save presets)

On every "Start / Apply" action, the dashboard:

  1. Persists the structured config to gpu/dashboard-config.json.
  2. Writes LLAMA_MODEL and LLAMA_EXTRA_ARGS to .env (preserving other vars).
  3. Runs docker compose --profile llama up -d --force-recreate llama with the same env vars inlined — identical to gpuctl start llama <model> <args>.

The dashboard is exposed via Tailscale serve on port 8090.

Local development

cd dashboard
npm install
npm run dev

You will need to set the same env vars the container would set:

export HOST_PROJECT_PATH=/path/to/GPU-Node   # absolute path on host
export PROJECT_DIR=/path/to/GPU-Node         # path mounted inside the dev shell
export NODE_INSTANCE=gpu-node

You also need docker and docker compose available on your $PATH, and the current user must be in a group that can access /var/run/docker.sock.

Building the image

docker build -t gpu-node-dashboard ./dashboard

Or via the project's build.sh after this PR merges — that script will be extended to build the dashboard image as well.

Tech stack

  • Next.js 16 (standalone output, App Router)
  • React 19 + TypeScript 5
  • Tailwind CSS 4 + shadcn-style components
  • Radix UI primitives (select, tabs, switch, label)
  • lucide-react icons