Skip to content

fix(reranker): bound the MLX buffer cache (cap + per-request clear)#100

Open
pinglin wants to merge 1 commit into
mainfrom
fix/reranker-mlx-cache-leak
Open

fix(reranker): bound the MLX buffer cache (cap + per-request clear)#100
pinglin wants to merge 1 commit into
mainfrom
fix/reranker-mlx-cache-leak

Conversation

@pinglin

@pinglin pinglin commented Jul 3, 2026

Copy link
Copy Markdown
Member

Commit / PR title (conventional commit): fix(reranker): bound the MLX buffer cache (cap + per-request clear)
Branch name: fix/reranker-mlx-cache-leak

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

**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>
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