Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a GPU-Limited Three-Model Pipeline

Run a fixed chain of three models on two GPUs while balancing model-loading cost, bounded waiting, and durable recovery.

Problem statement

For this exercise, assume clients submit asynchronous processing jobs whose immutable input passes through model A, then B, then C. Each stage consumes its predecessor's committed output.

Every job uses the same fixed immutable pipeline release containing exactly these three model artifacts; model-version IDs are retained for lineage. The server pins that sole release at acceptance and rejects any supplied release ID that does not match it.

The worker pool has exactly two identical GPUs; each GPU can hold and execute only one model at a time, so the three models cannot run simultaneously. Switching a GPU's resident model takes 500 milliseconds, while one stage takes 100 milliseconds once its model is resident.

Clients submit with an idempotency key, inspect durable progress, and read a final result only after all three stages succeed. A stage allows at most three execution attempts before the job fails.

Model stages are pure computations and may be recomputed, but a stale attempt cannot advance progress or replace a committed result. Accepted job state and committed intermediate bytes must survive a controller or worker-process restart.

Reuse a GPU only after the previous execution has completed or been confirmed stopped. Under the same confirmed device owner, sequential warm executions may retain a compatible resident model.

Before a model change or owner handoff, confirm the previous execution is stopped and fence the previous executor; unload the old model when changing it. If execution state is uncertain, confirm stop or establish a fenced reset epoch before reuse.

Inputs and intermediate outputs fit CPU-side storage, and the three model artifacts are available. Design admission, stage readiness, GPU ownership and residency, scheduling, progress, result commitment, and recovery.

Concurrent model versions, release changes, deployment and rollout, model training, model internals, GPU kernel design, adding GPUs, custom workflow graphs, cancellation, and real-time vehicle control are outside scope.

What to build

  1. Submit a job pinned to the sole fixed pipeline release idempotently and inspect its durable stage progress or explicit rejection.
  2. Execute A, B, and C in dependency order without overlapping ownership of a GPU, while making progress for admitted jobs under the fixed two-GPU budget.
  3. Expose one authoritative final result only after all three stage outputs commit; report failure when a stage exhausts three attempts.
  4. Recover accepted jobs from controller or worker-process loss using committed intermediates, reject stale completion, and confirm the previous execution has stopped before device reuse, retaining a compatible warm model when safe.

At scale

  • For this exercise, assume two jobs per second in steady operation and bursts of ten jobs per second lasting ten seconds; all jobs share the same three model artifacts and each requires three warm stage executions.
  • For this exercise, admit at most 100 unfinished jobs and reject excess submissions explicitly; an unfinished job consumes admission capacity until it succeeds or fails.
  • For this exercise, target p95 completion below ten seconds during healthy steady operation. During a burst or failure, preserve bounded backlog and eventual progress instead of promising unchanged latency.
  • For this exercise, preserve accepted state and committed intermediate bytes across a controller or worker-process restart; one GPU has at most one active execution or model-change owner.