fix: normalise logits_processors None to [] to avoid mlx-lm crash (#934)#1747
Merged
jundot merged 1 commit intoJun 9, 2026
Merged
Conversation
…ndot#934) mlx-lm's GenerationBatch._step does any(self.logits_processors) and for p in self.logits_processors[e], both of which crash with 'NoneType' object is not iterable when logits_processors is None. Apply three layers of defense: 1. _create_batch_generator: pass [] instead of None to BatchGenerator 2. _patched_generation_batch_step: normalise None → [] before calling the original mlx-lm _step (which crashes at any(None)) 3. _patched_ppb_split: normalise None → [] when splitting batches
Owner
|
Thanks for the defensive cleanup. The scheduler's normal insert path already passes per-row logits processor lists, and this additional normalization keeps the remaining boundaries from leaking None into mlx-lm. The focused scheduler/logits tests and CI look good, so I'm going to merge this. |
efortin
added a commit
to efortin/omlx
that referenced
this pull request
Jun 10, 2026
…erge GenerationBatch.extend() re-creates None row slots on heterogeneous continuous-batch merges (`any([[], []])` is False), undoing the insert-side empty-list shape from jundot#1747 whenever a request without active processors joins a batch serving a grammar-constrained one. The next _step then crashes with "'NoneType' object is not iterable", and the corruption recovery re-merges the same rows, looping until the retry budget fails every in-flight request. Normalise every per-row slot at the _patched_generation_batch_step chokepoint, covering both the insert and merge origins, and pin the invariant with unit, source-level, and integration regression tests. Fixes jundot#1798
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.
Reproduction
OpenAICompatibleprovider to point at a local oMLX endpointDiagnosis
When
logits_processorsisNone(no repetition/presence/frequency penalties configured), mlx-lm'sGenerationBatch._stepcrashes with:This is caught by omlx's cache corruption recovery, but since the root cause persists, requests fail after 3 retries with:
Fix
Three layers of defense to normalise
None→[]:_create_batch_generator— pass[]instead ofNonetoBatchGeneratorconstructor_patched_generation_batch_step— normaliseNone→[]before calling mlx-lm's_step(which crashes atany(None))_patched_ppb_split— normaliseNone→[]when splitting batchesConsistent with the existing fix at line 6528 where
per_row_lps = list(logits_processors) if logits_processors else []was already applied.