Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions omlx/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,13 @@ def _patched_generation_batch_step(self):
deltas = [model._uid_rope_deltas.get(uid, 0.0) for uid in self.uids]
model.set_batch_rope_deltas(mx.array(deltas))

# Defensive: mlx-lm's GenerationBatch._step does `any(self.logits_processors)`
# and `for p in self.logits_processors[e]`, both of which crash when
# logits_processors is None. Normalise to [] so the original code path
# works without modification. See #934.
if self.logits_processors is None:
self.logits_processors = []

result = _original_generation_batch_step(self)

# self._next_tokens contains the just-sampled tokens (async eval pending).
Expand Down Expand Up @@ -571,7 +578,9 @@ def _patched_ppb_split(self, indices):
new_batch.prefill_step_size = self.prefill_step_size
new_batch.samplers = self.samplers
new_batch.fallback_sampler = self.fallback_sampler
new_batch.logits_processors = self.logits_processors
# Defensive: normalise None → [] to avoid mlx-lm crash in _step
lps = self.logits_processors if self.logits_processors is not None else []
new_batch.logits_processors = lps
new_batch.state_machines = self.state_machines
new_batch.max_tokens = self.max_tokens

Expand Down Expand Up @@ -2030,7 +2039,7 @@ def _create_batch_generator(
max_tokens=sampling_params.max_tokens,
stop_tokens=stop_tokens_seq,
sampler=sampler,
logits_processors=logits_processors if logits_processors else None,
logits_processors=logits_processors if logits_processors else [],
prefill_batch_size=1,
completion_batch_size=self.config.completion_batch_size,
prefill_step_size=self.config.prefill_step_size,
Expand Down