fix(reranker): bound the MLX buffer cache (cap + per-request clear)#100
Open
pinglin wants to merge 1 commit into
Open
fix(reranker): bound the MLX buffer cache (cap + per-request clear)#100pinglin wants to merge 1 commit into
pinglin wants to merge 1 commit into
Conversation
**Because** - The reranker server had no MLX cache bound: MLX keeps a reuse buffer per distinct tensor shape, and a reranker sees a new shape on almost every candidate (variable text lengths; variable image grids on the vision path), so the cache grows without limit under sustained load — observed live 2026-07-03: the 2B model ballooned to a 100 GB phys_footprint within two minutes of a benchmark run and filled ~74 GB of host swap. **This commit** - Mirror the proven unified-embedding-server pattern (buckle gate-to-scale): mx.set_cache_limit at worker start (SHUBO_RERANKER_CACHE_LIMIT_GB, default 2 GB) + mx.clear_cache() after every request in the worker loop. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit / PR title (conventional commit): fix(reranker): bound the MLX buffer cache (cap + per-request clear)
Branch name: fix/reranker-mlx-cache-leak
Because
distinct tensor shape, and a reranker sees a new shape on almost every
candidate (variable text lengths; variable image grids on the vision path),
so the cache grows without limit under sustained load — observed live
2026-07-03: the 2B model ballooned to a 100 GB phys_footprint within two
minutes of a benchmark run and filled ~74 GB of host swap.
This commit
mx.set_cache_limit at worker start (SHUBO_RERANKER_CACHE_LIMIT_GB, default
2 GB) + mx.clear_cache() after every request in the worker loop.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com