feat(dashboard): favicon, fixed presets, more launch params, chat tab with TPS/TTFT metrics #8

Merged
mikan merged 1 commits from feature/dashboard-v4-favicon-presets-chat-params into master 2026-10-24 01:27:55 +00:00
Collaborator

1. Favicon

Added dashboard/src/app/icon.svg — Next.js App Router автоматически подхватывает src/app/icon.svg и serves as browser tab icon. SVG chip design с градиентом.

2. Presets — fixed 'all resets to original'

Root cause

POST /api/config { action: 'save-preset' } использовал stripPresets(current) для snapshot'a — но current это SERVER-side persisted config, не то что в UI форме сейчас. Если юзер отредактировал форму но не нажал 'Apply' — preset snapshot'ит STARYY persisted config, не то что он видит на экране.

Fix

  • API теперь принимает опциональное config поле в POST body. Если есть — merge в current перед действием.
  • Frontend handleSavePreset() теперь шлёт текущий state формы: { action: 'save-preset', name: '...', config }
  • Refactored merge logic в единый mergeConfig() helper — используется и в PUT, и в POST.

3. More launch parameters — 21 new field

Extended DashboardConfig и wired в buildLlamaExtraArgs() / 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 (используется Chat tab)

UI

  • 5 новых секций в ConfigTab, каждая в styled card
  • ToggleRow компонент для boolean флагов
  • buildPreviewArgs() обновлён чтобы показывать новые параметры в .env preview

4. Chat tab

Новый таб между Config и Models — разговор с running llama model напрямую из дашборда.

Backend

  • POST /api/chat — проксирует llama.cpp /v1/chat/completions. Использует Node native fetch() → http://llama:8080/v1/chat/completions (dashboard на той же Docker сети).
  • Streams SSE response обратно в браузер.
  • Forwards sampling params: temperature, top_p, top_k, min_p, repeat_penalty.

Frontend

  • Streaming chat с abort (Stop button mid-generation)
  • Auto-scroll toggle
  • Ctrl+Enter для отправки
  • System prompt auto-prepended из ConfigTab's systemPrompt
  • Per-message stats под assistant responses:
    • TPS (predicted_per_second)
    • prompt tokens + processing time
    • cache hit rate
    • speculative decoding accept rate (spec_accepted / spec_drafted)

5. Perf tab

Новый таб — live performance metrics.

Slots view (default)

Polls GET /api/slots каждые 1.5s. Показывает 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-* был использован при старте): drafted, accepted, accept rate

Prometheus view

Polls GET /api/metrics (llama.cpp's /metrics endpoint). Renders raw Prometheus exposition format как <pre>. Требует llama started с --metrics flag (теперь toggle в ConfigTab).

Backend

  • GET /api/slots — проксирует llama.cpp http://llama:8080/slots
  • GET /api/metrics — проксирует llama.cpp http://llama:8080/metrics

Verification

  • npm run build — OK, 22 routes (1 page + 1 icon + 1 not-found + 19 API)
  • bash dashboard/validate-build.sh — все 8 COPY источников ✓, standalone ✓

После мержа

git pull && sh build.sh
docker compose up -d --force-recreate dashboard

После старта llama (с включённым --metrics toggle в Config) открой:

  • Chat tab — поговори с моделью, увидишь TPS под каждым ответом
  • Perf tab — live slot metrics + Prometheus output

Todo / следующими PR

  • Tokenizer visualization (показать токены prompt'а)
  • Compare TPS между разными конфигами (preset benchmark)
  • WebSocket-based chat для двусторонней коммуникации
  • ComfyUI workflow viewer/editor
## 1. Favicon Added `dashboard/src/app/icon.svg` — Next.js App Router автоматически подхватывает `src/app/icon.svg` и serves as browser tab icon. SVG chip design с градиентом. ## 2. Presets — fixed 'all resets to original' ### Root cause `POST /api/config { action: 'save-preset' }` использовал `stripPresets(current)` для snapshot'a — но `current` это SERVER-side persisted config, не то что в UI форме сейчас. Если юзер отредактировал форму но не нажал 'Apply' — preset snapshot'ит STARYY persisted config, не то что он видит на экране. ### Fix - API теперь принимает опциональное `config` поле в POST body. Если есть — merge в `current` перед действием. - Frontend `handleSavePreset()` теперь шлёт текущий state формы: `{ action: 'save-preset', name: '...', config }` - Refactored merge logic в единый `mergeConfig()` helper — используется и в PUT, и в POST. ## 3. More launch parameters — 21 new field Extended `DashboardConfig` и wired в `buildLlamaExtraArgs()` / `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 (используется Chat tab) ### UI - 5 новых секций в ConfigTab, каждая в styled card - ToggleRow компонент для boolean флагов - `buildPreviewArgs()` обновлён чтобы показывать новые параметры в `.env` preview ## 4. Chat tab Новый таб между Config и Models — разговор с running llama model напрямую из дашборда. ### Backend - `POST /api/chat` — проксирует llama.cpp `/v1/chat/completions`. Использует Node native `fetch()` → `http://llama:8080/v1/chat/completions` (dashboard на той же Docker сети). - Streams SSE response обратно в браузер. - Forwards sampling params: temperature, top_p, top_k, min_p, repeat_penalty. ### Frontend - Streaming chat с abort (Stop button mid-generation) - Auto-scroll toggle - Ctrl+Enter для отправки - System prompt auto-prepended из ConfigTab's `systemPrompt` - Per-message stats под assistant responses: * **TPS** (predicted_per_second) * prompt tokens + processing time * **cache hit rate** * **speculative decoding accept rate** (spec_accepted / spec_drafted) ## 5. Perf tab Новый таб — live performance metrics. ### Slots view (default) Polls `GET /api/slots` каждые 1.5s. Показывает 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-* был использован при старте): drafted, accepted, accept rate ### Prometheus view Polls `GET /api/metrics` (llama.cpp's /metrics endpoint). Renders raw Prometheus exposition format как `<pre>`. Требует llama started с `--metrics` flag (теперь toggle в ConfigTab). ### Backend - `GET /api/slots` — проксирует llama.cpp `http://llama:8080/slots` - `GET /api/metrics` — проксирует llama.cpp `http://llama:8080/metrics` ## Verification - `npm run build` — OK, 22 routes (1 page + 1 icon + 1 not-found + 19 API) - `bash dashboard/validate-build.sh` — все 8 COPY источников ✓, standalone ✓ ## После мержа ```sh git pull && sh build.sh docker compose up -d --force-recreate dashboard ``` После старта llama (с включённым `--metrics` toggle в Config) открой: - **Chat tab** — поговори с моделью, увидишь TPS под каждым ответом - **Perf tab** — live slot metrics + Prometheus output ## Todo / следующими PR - Tokenizer visualization (показать токены prompt'а) - Compare TPS между разными конфигами (preset benchmark) - WebSocket-based chat для двусторонней коммуникации - ComfyUI workflow viewer/editor
super-z-bot added 1 commit 2026-10-24 01:26:52 +00:00
## 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 ✓
mikan merged commit 405c88f086 into master 2026-10-24 01:27:55 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mikan/GPU-Node#8