TorchedUp
ProblemsPremium
TorchedUp
Continuous Batching ScheduleHard
ProblemsPremium

Continuous Batching — Schedule a Step

In continuous (in-flight) batching, every decode step we pick the top-priority active sequences to run. Implement the scheduler.

Signature: def schedule_step(active_seqs: list, max_batch: int) -> list

active_seqs is a list of dicts {'id': int, 'remaining': int, 'priority': float}. Return the list of sequence IDs to run this step — top min(max_batch, len(active_seqs)) by descending priority.

Tie-breaking: stable (preserve input order on equal priority).

Example:

  • input: [{'id': 1, 'remaining': 5, 'priority': 0.5}, {'id': 2, 'remaining': 3, 'priority': 0.9}, {'id': 3, 'remaining': 10, 'priority': 0.1}], max_batch=2 → [2, 1]

Math

Asked at

Python (numpy)0/3 runs today

Test Results

○basic priority
○max_batch >= len
○tie-break stable🔒 Premium
○empty🔒 Premium
Advertisement