Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Modal 2 min read How-to mediumAdept

Augment Your LiveKit Agent with Modal GPUs

LiveKit agents can offload custom or open-weights models to Modal serverless GPUs, demonstrated with a BitHuman Expression video avatar voiced by Qwen3-TTS. The BitHuman container's /launch endpoint returns as soon as the avatar joins the room, which conflicts with Modal Servers scaling on in-flight requests. Modal's Sticky Sessions solve this by letting the agent open a session before calling /launch and close it when the call ends, holding the container slot for the session's duration. GPU snapshots hide cold starts that would otherwise require reloading gigabytes of model weights.

Related posts

  • GPU Memory Snapshots: Supercharging sub-second startup

    Modal mediumAdept

    Modal's GPU memory snapshots extend its gVisor-based checkpoint/restore to capture GPU state, using NVIDIA's new CUDA checkpoint API (driver branches 570/575) to lock CUDA processes, copy device memory, kernels, streams, contexts and memory mappings to host memory, then snapshot CPU and GPU state together. Restoring skips expensive warm-up such as torch.compile, CUDA graph capture and moving weights from CPU to GPU, which removes the earlier split between pre- and post-restore setup methods. Reported cold starts drop by up to 10x, for example Parakeet from about 20s to 2s, vLLM with Qwen2.5-0.5B from 45s to 5s, and a compiled ViT from 8.5s to 2.25s. The feature is in alpha and is enabled with an experimental flag.

  • Real-time inference for robots at Physical Intelligence

    Modal mediumAdept

    Physical Intelligence runs closed-loop inference for its Visual-Language-Action robot models on Modal GPUs instead of on-board GPUs, adding only about 10-15 ms of network overhead. Because TCP head-of-line blocking and jitter can disrupt a continuous control loop, Pi and Modal built a QUIC-over-UDP portal in Rust. It uses STUN discovery and UDP hole punching, coordinated through Modal Dict, so robots behind NAT keep a persistent bidirectional stream to GPU containers without relay infrastructure. Checkpoints live in Modal Volumes and load in under 30 seconds, and region-pinned deployments keep round trips short. Off-board inference also lets the team test models too large for robot hardware.

  • How Doppel eliminated ML infrastructure tax with Modal

    Modal mediumAdept

    Doppel, which builds ML models to detect social engineering attacks, moved much of its training and inference from sequential experiments and GCP Cloud Run to Modal. On the training side, independent work such as K-fold cross-validation now runs in parallel via Modal's map(), and coding agents drive the experiment loop through Modal's CLI. For inference, image layer caching and persistent volumes for model weights cut builds from 10–30 minutes by up to 10x, with sub-minute warm builds. Autoscaling absorbs attack-campaign spikes without Cloud Run's one-GPU-per-instance limit, and direct remote calls replace the hand-built Flask HTTP layer around each model.

  • How we achieved truly serverless GPUs

    Modal mediumAdept

    Modal cuts GPU inference replica cold starts from roughly 2,000 seconds to about 50 seconds, a 40x speedup, by attacking each stage of spin-up. A solver-managed buffer of idle, health-checked GPUs, allocated with Google's GLOP linear program, takes instance provisioning out of the hot path. ImageFS, a libfuse filesystem, serves container images lazily from a tiered content-addressed cache, and CPU and CUDA checkpoint/restore skip host- and device-side initialization. The motivation is GPU Allocation Utilization: spiky inference demand leaves fixed allocations at 10-20% use, and fast autoscaling raises utilization and quality of service together.

  • Serverless routing made sticky

    Modal mediumAdept

    Modal's Sticky Sessions pin every request in a session to the same serverless container, which suits stateful workloads like streaming speech-to-text, voice agents, shared rooms and multiplayer games without resorting to max_containers=1. The feature builds on Modal Servers and their stateless proxy (fprs). Routing metadata is encoded in a signed session token, so the proxy holds no session-to-container mapping. Load balancers combine periodic concurrency probes with recent routing decisions to place sessions, and the autoscaler treats sessions rather than requests as the unit of concurrency, queuing new sessions when capacity runs out.

The quest for software engineering knowledge.

Look:
Layout: