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 entirestate_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 newnn.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
AddFlashPackMixin to your module for save_flashpack and from_flashpack methods:
Diffusers Models
UseFlashPackDiffusersModelMixin for diffusers models with from_pretrained_flashpack and save_pretrained_flashpack:
Transformers Models
Works the same way withFlashPackTransformersModelMixin:
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 usesfrom_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():
GitHub Repository
View source, benchmarks, and contribute on GitHub