Skip to content

feat: v0.9.0 — SSD KV cache, prefix trie, telemetry, DFlash improvements#15

Open
szibis wants to merge 6 commits into
mainfrom
feat/v0.9.0-ssd-kv-prefix-telemetry
Open

feat: v0.9.0 — SSD KV cache, prefix trie, telemetry, DFlash improvements#15
szibis wants to merge 6 commits into
mainfrom
feat/v0.9.0-ssd-kv-prefix-telemetry

Conversation

@szibis

@szibis szibis commented May 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • SSD KV cache persistence: 2-tier hot/cold KV cache with safetensors serialization. Evicts to SSD when RAM threshold exceeded, restores on cache miss. Session-isolated via prompt prefix hash.
  • Prefix caching trie: RadixAttention-style compressed trie for KV cache sharing across sessions. Longest-prefix matching, LRU eviction, thread-safe.
  • Hardware telemetry: IOReport-based GPU/power/thermal sampling with background daemon thread. New /telemetry endpoints in Python + Rust proxy.
  • Dashboard enhancements: Power (W) chart, temperature (CPU/GPU °C) chart with color coding, ANE utilization display.
  • DFlash acceptance improvements: Soft threshold acceptance, hidden state normalization (quantized↔fp16 bridge), proper top-K verification, block size auto-tuning.
  • Expert prefetch from drafts: Predicts MoE expert assignments from draft tokens, triggers async cache prefetch.
  • DeepSeek V4 Flash: Mini drafter preset, auto preset selector, custom calibration prompts.

New files

  • mlx_flash_compress/ssd_kv_cache.py — SSDKVCache backend
  • mlx_flash_compress/prefix_cache.py — PrefixCacheTrie + get_or_compute_prefix
  • mlx_flash_compress/telemetry.py — HardwareTelemetry + TelemetrySample
  • mlx_flash_compress/draft_expert_prefetch.py — DraftExpertPrefetcher
  • tests/test_ssd_kv_cache.py — 17 tests
  • tests/test_prefix_cache.py — 23 tests
  • tests/test_telemetry.py — 18 tests
  • tests/test_dflash_acceptance.py — 21 tests
  • tests/test_draft_expert_prefetch.py — 9 tests

Test plan

  • 1995 tests passing, 0 failures
  • Ruff format + check clean
  • Rust cargo check clean (0 errors, 0 warnings)
  • GPU benchmark: DFlash acceptance rate with soft threshold + normalization
  • Live dashboard verification with real server

szibis added 6 commits May 11, 2026 14:13
SSD KV cache persistence: 2-tier hot/cold with safetensors serialization
to disk. Evicts oldest entries to SSD when RAM threshold exceeded, restores
on cache miss. Session-isolated via prompt prefix hash.

Prefix caching: RadixAttention-style compressed trie for KV cache sharing
across sessions. Longest-prefix matching with LRU eviction. Thread-safe.

Hardware telemetry: IOReport-based sampling for GPU utilization, power draw,
CPU/GPU temperature, ANE utilization. Background daemon thread with circular
buffer history. New /telemetry endpoints in Python server and Rust proxy.

Dashboard: power consumption chart, temperature chart (CPU/GPU with color
coding), ANE utilization display. Polls /telemetry/current alongside
existing status endpoints.

DFlash acceptance improvements: soft threshold acceptance, hidden state
normalization to bridge quantized/fp16 gap, proper top-K verification in
cached path, block size auto-tuning based on measured acceptance rate.

Expert prefetch from drafts: predicts MoE expert assignments from draft
tokens via router gate weights, triggers async cache prefetch before
target verification.

DeepSeek V4 Flash: added mini preset (3-layer, 1024-hidden), auto preset
selector based on available RAM, custom calibration prompts via --calibration-prompts.

1995 tests passing, 0 failures.
… telemetry integration

Chat UI: fetch models from /v1/models/registry instead of hardcoded list,
SSE streaming with token-by-token rendering, optgroup categories, 502/503
error states. Dashboard: 10-link nav bar, API endpoints card, inline
power/temp/ANE in GPU card, worker session details.
… unsupported

- Registry detects system RAM (sysctl HW_MEMSIZE) and filters dense models
  that won't fit; MoE models always shown (expert streaming)
- Removed unsupported architectures (DeepSeek V4, gemma-4-e2b) from registry
- Added 8 new supported models (Llama 1B/70B, Qwen3 4B/8B, Phi-4, gemma-4-12b, Mixtral)
- Model switch shows real-time progress (downloading/loading/compiling phases)
  via /switch/progress polling endpoint
- Chat UI: cached models marked with checkmark, MoE tag, category size hints
- Python server: SO_REUSEADDR, switch progress tracking, phase updates during load
…orker

Rust proxy was wrapping Python's "data: {...}" lines in another Event::data(),
producing "data: data: {...}" which broke the chat UI's SSE parser.
Now passes raw byte stream through with correct headers.
…s nav

- Token counter updates live during SSE streaming (counts content chunks)
- Status bar shows tokens, tok/s, elapsed time after each message
- Session saved on beforeunload (covers refresh, nav to dashboard, tab close)
- loadSession validates data before restoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant