Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Gang-Scheduled GPU Inference Pool

Design an inference request path with explicit latency accounting and one-GPU or all-GPU batches that each complete in 100 milliseconds.

Problem statement

For this exercise, assume clients submit independent inference requests for an immutable model version. A request explicitly eligible for deterministic reuse may be answered by a result cache keyed by model version, normalized request fingerprint, and execution options; every other request follows the cache-miss path.

Misses are grouped into ready batches for one of two workload classes under an explicit size, age, or deadline policy. The worker pool has exactly eight identical GPUs. A large-model batch requires an all-or-nothing allocation of all eight GPUs, while a small-model batch requires one GPU.

Under the interviewer's bounded capacity assumption, every dispatched batch in either class completes in exactly 100 milliseconds.

Large and small ready batches may wait in separate queues, and observed request rate may be an input to priority, but the design must make fairness, starvation protection, admission, and overload outcomes explicit.

Distinguish network transit from service-side time, and distinguish time to first token from end-to-end completion.

Use the exact 100-millisecond duration for the bounded capacity calculation; then explain how real prompt length, response length, and model size would label observed latency distributions and capacity forecasts without changing that exercise premise.

Every accepted request, sealed batch, allocation lease, and execution attempt has a stable identity; one GPU belongs to at most one live allocation, and one logical batch publishes at most one terminal result.

Design the cache-hit and miss paths, batching, queueing, load balancing, GPU allocation, completion, failure recovery, capacity reasoning, and observability. Model training, model-weight distribution, GPU kernel design, KV-cache internals, continuous batching, and multi-region routing are outside scope.

What to build

  1. The service returns an eligible version-scoped cache hit or routes the request through one observable cache-miss path without confusing stale or incompatible results.
  2. Cache misses are grouped into stable ready large-model or small-model batches under an explicit batching-delay and admission policy.
  3. The scheduler assigns one GPU to each small-model batch or all eight GPUs atomically to a large-model batch, and each dispatched batch completes after the exercise's fixed 100-millisecond execution duration.
  4. The service and its telemetry distinguish network transit, cache and batching delay, ready-queue and allocation delay, time to first token, and end-to-end completion.
  5. Clients and operators can distinguish queued, running, completed, rejected, and failed work while observing demand, latency, allocation, and utilization by workload class and model profile.

At scale

  • The worker pool contains exactly eight identical GPUs.
  • A ready large-model batch requires all eight GPUs simultaneously, while a ready small-model batch requires one GPU.
  • Every dispatched batch completes in exactly 100 milliseconds under the bounded exercise model, so a continuously busy pool can complete one large-model batch or as many as eight small-model batches per 100-millisecond interval, ignoring control-plane overhead.
  • Eligible cache hits complete before batching and GPU scheduling, while cache misses, the batch-formation policy, and the arrival mix determine queue pressure.
  • Latency must be decomposed rather than reported as one average: measure network transit separately from service time, and within the service path distinguish cache lookup, batch formation, ready-queue and allocation wait, execution to first token, and remaining execution to the 100-millisecond completion boundary.
  • Real prompt length, response length, and model size may change observed latency outside the bounded premise; represent them as labeled distributions or sensitivity profiles rather than silently replacing the exercise's exact duration.