InferenceAI

Enter at least two characters to search.

Start free

Continuous Batching Admission

hardInference35 min50 XP

An inference scheduler sees waiting requests in arrival order. Each request is [id, new_tokens]. Implement admit_requests(waiting, token_budget, max_requests) and return admitted IDs. Scan in order. Admit a request if its token cost fits the remaining budget and there is an open request slot; otherwise skip it and continue. A later smaller request may fit. Token costs are nonnegative; IDs are unique; budgets are nonnegative. Stop after max_requests admissions.

Examples

EXAMPLE WALKTHROUGHskip oversized

A guided view of the published example, not a trace of your code.

INPUT[[["a",5],["b",9],["c",2]],7,2]
TASKadmit_requests()
EXPECTED OUTPUT["a","c"]

Start with the input values shown in this example.

Example 1 of 2

Input: waiting = [["a",5],["b",9],["c",2]], token_budget = 7, max_requests = 2

Output: ["a","c"]

Explanation: skip oversized

Input: waiting = [["a",1],["b",1]], token_budget = 10, max_requests = 1

Output: ["a"]

Explanation: request limit

Hint 1

Keep scanning after a request does not fit.

Hint 2

Track request slots and token capacity separately.

Topics

PythonContinuous BatchingSchedulingLLM Serving