← Selected systems work

GPU fleet lifecycle for inference

Turning GPU instances on and off to match actual demand instead of running them continuously — coordinated safely across concurrent processes, in service of a pipeline that was built to be low-cost by design.

Where
9AI — DataReel video-generation platform
Role
Designed and implemented
Scale
Part of a platform designed to sustain 2,000+ pipeline-based video generations/day for Indira IVF
Stack
Python, boto3/EC2, IAM, Redis, Hugging Face APIs
boto3 + IAM
on-demand GPU instance start/stop
Redis locks
safe multi-process lifecycle coordination
Async
batched, tensor-parallel inference for throughput

Problem

The video pipeline combined third-party APIs (SyncLabs, ElevenLabs) with self-hosted open-source models that needed GPU compute — LatentSync for lip-sync, Bhashini for voice, and other Hugging-Face-hosted models. Generation demand was bursty and unpredictable, which put GPU cost in tension with itself: running instances continuously to always be ready is wasteful against idle time, but cold-starting one on every request is too slow. This part of the stack was built to be isolated and low-cost, so neither option was acceptable as-is.

Constraints

What I built

IAM-scoped roles paired with the boto3 EC2 SDK to programmatically start and stop GPU instances on demand, rather than leaving them running continuously. Because more than one process could reasonably want to change an instance's state at once, I built an async mechanism guarded by Redis locks, so processes coordinate instance lifecycle safely instead of two of them racing to start or stop the same instance. Once instances were running, requests were batched and executed with tensor parallelization and caching to maximize concurrency and throughput, using Hugging Face APIs for the open-source models, and retries absorbed transient inference failures without failing the whole job.

inference request arrives check instance state (Redis lock) start GPU instance (boto3 / IAM) if needed batched, tensor-parallel inference (Hugging Face APIs) instance no longer needed stop instance
Instance lifecycle checked against a Redis lock before any start/stop, so concurrent requests don't race each other.

The trade-off

Distributed locking and async coordination between processes was the real cost here: every GPU start or stop had to clear a Redis lock first, because two processes reaching for the same instance at the same time was a real possibility, not a hypothetical edge case. That coordination code is complexity that always-on infrastructure would never have needed, but a pipeline built around bursty, unpredictable demand needed GPU spend that tracked actual usage, not a fixed idle cost sitting underneath it by default.

Outcome

On-demand start/stop via boto3 and IAM meant GPU instances only ran while there was work for them to do, with Redis locks keeping that lifecycle safe whenever more than one process reached for the same instance at once. It's one piece of the platform designed to sustain 2,000+ pipeline-based video generations a day for Indira IVF, platform-wide.

boto3EC2IAMRedis locksHugging Facetensor parallelizationasync Python