Repository navigation
Fix empty samplers and logits_processors not filtered in GenerationBatch.filter - #1772
Merged
zcbenz merged 2 commits intoAug 25, 2026
Merged
Conversation
zcbenz
approved these changes
Aug 25, 2026
…ch.filter GenerationBatch.filter pruned its per-sequence `samplers` and `logits_processors` lists only `if any(...)`. A request with no processors leaves an empty entry, `any([[]])` is False, and the finished request's entry survives the prune. The next request that does carry a processor is then appended under the wrong index: its processor runs on the batch's own first step and never again (the same for a per-request sampler after a request without one). In mlx_lm.server this shows up as a response_format / logits_processors request being honored only when it is the first request to a fresh server. PromptProcessingBatch.filter already handles this with an `else` branch; this applies the same fix to GenerationBatch.filter and adds a test that fails on main and passes with the fix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
zcbenz
force-pushed
the
fix-generation-batch-filter
branch
from
August 25, 2026 10:37
6a25cdd to
c6062cc
Compare
azamamirza
added a commit
to azamamirza/mlx-lm
that referenced
this pull request
Aug 27, 2026
Rebased onto upstream/main 74e7cf9 (adds ml-explore#1673 ChunkedKVCache valid-length trim — which supersedes and retires our own fix — plus ml-explore#1772 GenerationBatch filter, ml-explore#1775 decode-loop thread-safety, and new model support). Our two qwen3_moe patches (tensor-parallel ml-explore#1774 submitted, pipeline staged) ride on top unchanged and rebased clean.
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.
GenerationBatch.filterprunes its per-sequencesamplersandlogits_processorslists onlyif any(...). A request with no processors leaves an empty entry,any([[]])is False, and the finished request's entry survives the prune. The next request that does carry a processor is then appended under the wrong index: its processor runs on the batch's own first step and never again. The same happens to a per-request sampler after a request without one.In
mlx_lm.serverthis shows up as alogits_processors/response_format-style request being honored only when it is the first request to a fresh server; after any plain request, later constrained requests come back unconstrained, with no error.PromptProcessingBatch.filteralready handles this with anelsebranch. This applies the same fix toGenerationBatch.filterand addstest_batch_processors_and_samplers_survive_a_request_without_them, which fails onmainand passes with the fix.Disclosure per CONTRIBUTING: the fix and test were written with Claude Code and this description was drafted by it, under my direction; I reproduced the bug and the fix on a served model and take responsibility for every line.