Skip to main content
FlashPack is an open-source library by fal that dramatically speeds up model loading by streaming weights directly from disk to GPU with zero-copy reconstruction. Use it in your setup() method to reduce cold start times.

How It Works

1. Flatten weights into contiguous macroblocks

At save/convert time, FlashPack takes the model’s entire state_dict, groups tensors by data type, then flattens them into one contiguous stream of bytes. A compact weight map at the end of the file stores every parameter’s key, shape, and offset.

2. Stream with overlapping disk, CPU, and GPU transfers

When loading, FlashPack memory-maps the file and divides it into mid-sized CPU buffers (up to 64MB each). These buffers load in a round-robin pattern, keeping disk reads continuous. Each CPU buffer is paired with a dedicated CUDA stream — while one stream writes to VRAM, another buffer is already being loaded from disk.

3. Rebuild parameters as zero-copy views

Once data is on the GPU, FlashPack reconstructs each tensor as a view into the flat memory block and creates new nn.Parameter instances with direct references to the loaded bytes. No copies, no moves — the model is immediately ready to run.

Integration Methods

Direct Function Calling

The simplest approach when you don’t want to modify your module code:

PyTorch Mixin

Add FlashPackMixin to your module for save_flashpack and from_flashpack methods:

Diffusers Models

Use FlashPackDiffusersModelMixin for diffusers models with from_pretrained_flashpack and save_pretrained_flashpack:

Transformers Models

Works the same way with FlashPackTransformersModelMixin:

Diffusers Pipelines

FlashPack pipelines are made of FlashPack-enabled models. You don’t need to enable FlashPack on every model in a pipeline — it automatically uses from_pretrained_flashpack for FlashPack-enabled models and from_pretrained for the rest.
Use Optional[] syntax (not | None) for optional pipeline parameters. This is a limitation in diffusers, not FlashPack.

CLI Commands

FlashPack includes a CLI for converting, inspecting, and reverting files.

Convert a model

Inspect metadata

Revert to safetensors


Using FlashPack on fal

Convert your model to FlashPack format, store it on /data or HuggingFace, and load in setup():
Or with the Diffusers integration:
Store FlashPack files on /data for automatic caching across cold starts. The first runner downloads the file, and subsequent runners load from the cached copy.

GitHub Repository

View source, benchmarks, and contribute on GitHub