NumPy allowed · plain Python earns 10 bonus points
Softmax(logits) → probability distribution
Maximize GPU compute utilization and eliminate idle bubble time using iteration-level continuous batching.
Implement schedule_continuous_batch(active_requests, waiting_queue, max_batch_size, max_total_tokens). Step 1: For each active request, increment current_tokens by 1. If current_tokens >= max_tokens, add its ID to completed_ids. Otherwise retain it in active and accumulate its tokens. Step 2: In FIFO order, admit requests from waiting_queue into active as long as len(active) < max_batch_size AND current_tokens_used + prompt_tokens <= max_total_tokens. Return dict with scheduled_active_ids, completed_ids, remaining_waiting_ids, and batch_token_budget_used. Raise ValueError if max_batch_size <= 0 or max_total_tokens <= 0.
schedule_continuous_batch(active_requests: list[dict], waiting_queue: list[dict], max_batch_size: int, max_total_tokens: int) -> dict