Skip to content

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

Modal 8 min read Case study mediumAdept

Inside Modal Notebooks: How we built a cloud GPU notebook that boots in seconds

Modal Notebooks runs Jupyter kernels inside Modal Sandboxes, using a `modal-kernelshim` daemon that translates ZeroMQ kernel protocol messages into HTTP tunneled through the control plane. Fast GPU boots come from a Rust FUSE lazy-loading container filesystem with a content-addressed tiered cache (page cache, SSD, zonal cache, regional CDN, blob storage). Supporting pieces include shared scheduling with idle-kernel pausing and VolumeFS (file trees in Spanner, eventually consistent ops) for persistent storage. Collaboration uses operational transformation via Rushlight over Redis Streams, with large outputs offloaded to S3 Express One Zone, and the editor adds LSP via Pyright, Ruff formatting compiled to WebAssembly, and AI next-edit suggestions.

Assumes: Jupyter kernelscontainers and imagesFUSE filesystems

Related posts

  • Modal becomes a gVisor maintainer

    Modal mediumAdept

    Google is donating gVisor to the CNCF under maintainer-led governance, and Modal, which launches over 40 million gVisor containers a day for GPU inference, training, and AI sandboxes, is joining as a maintainer. gVisor's Go-based Sentry application kernel implements the Linux syscall interface and is itself confined by namespaces, cgroups and seccomp, giving tenant isolation without hardware virtualization: about 25 ms boot and 12 MB overhead. Modal's upstream work includes nvproxy support for new NVIDIA GPUs, NVLink, MPS and GPUDirect RDMA, plus a new rdmaproxy that reaches ~99% of native NCCL all-reduce bandwidth over InfiniBand, RoCE and EFA. Other contributions are huge-page recycling that lifts PyTorch shared-memory throughput from 2.9 to 22 GB/s and tmpfs work that makes SQLite 2.7x faster. Planned work covers multi-GPU memory snapshots, GPUDirect Storage, MIG/vGPU and sub-minute inference server startup.

  • Memory snapshots: Checkpoint/restore for sub-second startup

    Modal mediumAdept

    Modal cuts serverless container cold starts roughly 2.5x by checkpointing a gVisor container's full process tree and filesystem mutations just before it accepts a request, then restoring it instead of re-running Python's syscall-heavy import path (import torch alone makes 26,000 syscalls through OverlayFS and a FUSE lazy-loading server). Restore speed depends mostly on getting the main process's memory pages into the page cache. gVisor loads pages in the background, prioritizing faulting pages, while the FUSE layer aggressively preloads the pages file. Snapshots are created on demand per worker because of CPU feature, NVIDIA driver and runtime compatibility. GPU state can't be saved, so models are loaded into CPU RAM before the snapshot and moved to the GPU after restore via snap=True/snap=False lifecycle hooks.

  • Modal is a computer

    Modal easyNovice

    Modal is best understood not as a neocloud or inference provider but as a computer: a virtual machine built across dozens of cloud providers, mapped component by component onto a classic computer architecture. Containers play the role of cores, the container runtime acts as the OS loader and scheduler, images are 'compiled' to filesystems with shared files deduplicated like shared libraries, and the storage hierarchy runs from container memory through page cache, ephemeral disk and Volumes to object storage. The Input/Output Plane, Routing Plane and Tunnels correspond to I/O, networking and RDMA-style bypass. The argument is that this extra virtualization layer aggregates and multiplexes demand for better resource efficiency than raw cloud primitives offer.

  • 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.

  • Run GPU jobs from Airflow with Modal

    Modal mediumAdept

    Airflow DAGs can offload GPU-heavy tasks to Modal instead of standing up Celery or Kubernetes executors, using a two-step pipeline that scrapes Reddit ELI5 questions and answers them with an LLM as the example. One approach deploys Modal Functions separately and calls them from Airflow tasks via Function.from_name and remote(), passing intermediate data through a Modal Dict (10GB limit versus roughly 1GB for XComs on Postgres) or a Volume. The other defines a custom ModalOperator that serializes a Python function's source and runs it in a Modal Sandbox with a runtime-defined image, secrets, volumes and GPUs. Either way, task environments stay isolated from the Airflow environment without building Docker images for KubernetesPodOperator.

The quest for software engineering knowledge.

Look:
Layout: