Simulate Step-Level Batching for Diffusion Requests Under a Token Budget
Last updated: November 29, 2026
Quick Overview
Each request needs a fixed number of denoising steps over a canvas of N tokens. A GPU runs iterations that advance every active request by one step at a cost of base + per_request * batch_size milliseconds, admitting waiting requests FCFS at iteration boundaries while total canvas tokens fit in memory. Compute every request's completion time.
Inception
November 29, 20260
0
0 solved
Each request needs a fixed number of denoising steps over a canvas of N tokens. A GPU runs iterations that advance every active request by one step at a cost of base + per_request * batch_size milliseconds, admitting waiting requests FCFS at iteration boundaries while total canvas tokens fit in memory. Compute every request's completion time.
Inception's serving stack batches diffusion requests that differ in canvas size and step count, which is the analogue of continuous batching for autoregressive models. Inference serving engineers must reason about admission, memory limits and head-of-line blocking. The interviewer checks a correct event simulation and an understanding of the policy trade-offs it encodes.
What the Interviewer Expects
- Model time as advancing per iteration, jumping forward when the GPU is idle
- Admit FCFS at iteration boundaries only, respecting the memory budget
- Free memory as soon as a request finishes so the next iteration can admit more
- Reject requests that can never fit instead of looping forever
- Discuss head-of-line blocking and alternatives like skip-ahead admission
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you change admission to minimize mean latency instead of preserving FCFS?
- What if per-iteration cost depends on total tokens rather than request count?
- How would you add priority classes for voice traffic with tight TTFT targets?
- How would you pick max_tokens from GPU memory and model size?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: requests (id, arrival_ms, steps, canvas_tokens), memory budget max_tokens, and an iteration cost model. Output: completion time per id. Admission is FCFS and stops at the first waiting requ...
High-Level Design
Keep a deque of pending requests sorted by arrival, a dict of active requests with remaining steps, and the tokens in use. Loop: if nothing is active, jump the clock to the next arrival. Admit arrived...
Submit Your Answer
Inception Machine Learning Engineer Interview Guide
Interview process, tips, and preparation timeline