From 9cd91725a365fe2bb9fa034ae7441f6610d98bce Mon Sep 17 00:00:00 2001 From: szibis <329831+szibis@users.noreply.github.com> Date: Mon, 11 May 2026 14:13:00 +0200 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20v0.9.0=20=E2=80=94=20SSD=20KV=20cac?= =?UTF-8?q?he,=20prefix=20trie,=20telemetry,=20DFlash=20improvements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- mlx-flash-server/src/dashboard.rs | 78 ++++- mlx-flash-server/src/server.rs | 40 +++ mlx_flash_compress/__init__.py | 16 + mlx_flash_compress/dflash_model.py | 225 +++++++++--- mlx_flash_compress/draft_expert_prefetch.py | 150 ++++++++ mlx_flash_compress/kv_cache_backend.py | 20 +- mlx_flash_compress/prefix_cache.py | 268 +++++++++++++++ mlx_flash_compress/serve.py | 38 +++ mlx_flash_compress/ssd_kv_cache.py | 199 +++++++++++ mlx_flash_compress/telemetry.py | 340 ++++++++++++++++++ scripts/train_dflash_drafter.py | 209 +++++++++--- tests/test_dflash_acceptance.py | 359 ++++++++++++++++++++ tests/test_draft_expert_prefetch.py | 201 +++++++++++ tests/test_imports.py | 7 + tests/test_prefix_cache.py | 325 ++++++++++++++++++ tests/test_ssd_kv_cache.py | 313 +++++++++++++++++ tests/test_telemetry.py | 330 ++++++++++++++++++ 17 files changed, 3023 insertions(+), 95 deletions(-) create mode 100644 mlx_flash_compress/draft_expert_prefetch.py create mode 100644 mlx_flash_compress/prefix_cache.py create mode 100644 mlx_flash_compress/ssd_kv_cache.py create mode 100644 mlx_flash_compress/telemetry.py create mode 100644 tests/test_dflash_acceptance.py create mode 100644 tests/test_draft_expert_prefetch.py create mode 100644 tests/test_prefix_cache.py create mode 100644 tests/test_ssd_kv_cache.py create mode 100644 tests/test_telemetry.py diff --git a/mlx-flash-server/src/dashboard.rs b/mlx-flash-server/src/dashboard.rs index 7056935..97a8a0b 100644 --- a/mlx-flash-server/src/dashboard.rs +++ b/mlx-flash-server/src/dashboard.rs @@ -184,6 +184,7 @@ const DASHBOARD_HTML: &str = r##"