Skip to content

1. Expert Double-Buffered(TPS x2.3) 2. Remove KV cache 3. Support Local Model Path - #1

Open
ccckblaze wants to merge 1 commit into
mu-hashmi:mainfrom
ccckblaze:optimize
Open

1. Expert Double-Buffered(TPS x2.3) 2. Remove KV cache 3. Support Local Model Path#1
ccckblaze wants to merge 1 commit into
mu-hashmi:mainfrom
ccckblaze:optimize

Conversation

@ccckblaze

@ccckblaze ccckblaze commented Mar 23, 2026

Copy link
Copy Markdown

Compared to main branch with the following improvements:

  1. Expert Double-Buffered
  • Implemented double buffering mechanism (Buffer A/B) in PredictiveExpertCache
  • Supports async expert prefetching (prefetch_async) and buffer swapping (swap_buffers)
  • Prefetches next-layer experts to optimize inference throughput
Pytnon $ cd UsersstevenProjectsmlx-moe   uv run

TPS from ~ 12-15 tok/s to ~28 tok/s(up to 2.3x) on my M4 mac

notice: 8-bit model not 4-bit

  1. Removed KV Cache
  • Removed server-side KV cache mechanism (kv_cache_slots parameter)
  • Reason: KV cache can cause context confusion in certain conditions
  • Related changes:
    • cli.py: Removed --kv-cache-slots parameter
    • server.py: Removed KV cache related code (_put_kv_cache, _kv_cache dict)
  1. Support Local Model Path
  • Added local path support in generate.py, allowing direct model directory paths
  • Supports loading models from local filesystem without requiring HuggingFace IDs
  1. Other Improvements
  • pyproject.toml: Lowered Python version requirement to 3.12, upgraded mlx/mlx-lm version dependencies
  • Cache path fix: Properly handles cache directory naming for local paths
  • Dynamic prefetch: Added logic in dynamic_cache_update to predict next-layer experts based on current layer requests

…ion in some condition 3. Allow specific model directly from PATH
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