Skip to content
Draft
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
7 changes: 7 additions & 0 deletions sendnn_inference/v1/core/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ def schedule(self) -> "SchedulerOutput":
while self.skipped_waiting:
holdback_queue.append(self.skipped_waiting.pop_request())

# Greedily pick the request whose prompt length is closest to the
# current batch TKV so the incoming sequence aligns with the running
# decode batch as tightly as possible. May starve outliers — intentional.
holdback_queue = deque(
sorted(holdback_queue, key=lambda r: abs(r.num_prompt_tokens - self.tkv))
)

# Check if new requests can be scheduled for prefill
while holdback_queue:
if self.can_schedule_prefill(holdback_queue[0]):
Expand Down
Loading