Skip to main content

Load ML models fast

Project description

FlashPack Logo

Disk-to-GPU Tensor loading at up to 25Gbps without GDS

Benchmark Results Run this benchmark in `scripts/run_benchmark.py`
Benchmark Results Run this benchmark in `tests/test_speed_comparison.py`

Updates

  • 2025-11-25: Now supports multiple data types per checkpoint with no regressions in speed!

Integration Guide

Mixins

Diffusers/Transformers

# Integration classes
from flashpack.integrations.diffusers import FlashPackDiffusersModelMixin, FlashPackDiffusionPipeline
from flashpack.integrations.transformers import FlashPackTransformersModelMixin

# Base classes
from diffusers.models import MyModel, SomeOtherModel
from diffusers.pipelines import MyPipeline

# Define mixed classes
class FlashPackMyModel(MyModel, FlashPackDiffusersModelMixin):
    pass

class FlashPackMyPipeline(MyPipeline, FlashPackDiffusionPipine):
    def __init__(
        self,
        my_model: FlashPackMyModel,
        other_model: SomeOtherModel,
    ) -> None:
        super().__init__()

# Load base pipeline
pipeline = FlashPackMyPipeline.from_pretrained("some/repository")

# Save flashpack pipeline
pipeline.save_pretrained_flashpack(
    "some_directory",
    push_to_hub=False,  # pass repo_id when using this
)

# Load directly from flashpack directory or repository
pipeline = FlashPackMyPipeline.from_pretrained_flashpack("my/flashpack-repository")

Vanilla PyTorch

from flashpack import FlashPackMixin

class MyModule(nn.Module, FlashPackMixin):
    def __init__(self, some_arg: int = 4) -> None:
        ...

module = MyModule(some_arg = 4)
module.save_flashpack("model.flashpack")

loaded_module = module.from_flashpack("model.flashpack", some_arg=4)

Direct Integration

from flashpack import pack_to_file, assign_from_file

flashpack_path = "/path/to/model.flashpack"
model = nn.Module(...)

pack_to_file(model, flashpack_path)  # write state dict to file
assign_from_file(model, flashpack_path)  # load state dict from file

CLI Commands

FlashPack provides a command-line interface for converting, inspecting, and reverting flashpack files.

flashpack convert

Convert a model to a flashpack file.

flashpack convert <path_or_repo_id> [destination_path] [options]

Arguments:

  • path_or_repo_id - Local path or Hugging Face repository ID
  • destination_path - (Optional) Output path for the flashpack file

Options:

Option Description
--subfolder Subfolder of the model (for repo_id)
--variant Model variant (for repo_id)
--dtype Target dtype for the flashpack file. When omitted, no type changes are made
--ignore-names Tensor names to ignore (can be specified multiple times)
--ignore-prefixes Tensor prefixes to ignore (can be specified multiple times)
--ignore-suffixes Tensor suffixes to ignore (can be specified multiple times)
--use-transformers Load the path as a transformers model
--use-diffusers Load the path as a diffusers model
-v, --verbose Enable verbose output

Examples:

# Convert a local model
flashpack convert ./my_model ./my_model.flashpack

# Convert from Hugging Face
flashpack convert stabilityai/stable-diffusion-xl-base-1.0 --subfolder unet --use-diffusers

# Convert with specific dtype
flashpack convert ./my_model ./my_model.flashpack --dtype float16

flashpack revert

Revert a flashpack file back to safetensors or torch format.

flashpack revert <path> [destination_path] [options]

Arguments:

  • path - Path to the flashpack file
  • destination_path - (Optional) Output path for the reverted file

Options:

Option Description
-v, --verbose Enable verbose output

Example:

flashpack revert ./my_model.flashpack ./my_model.safetensors

flashpack metadata

Print the metadata of a flashpack file.

flashpack metadata <path> [options]

Arguments:

  • path - Path to the flashpack file

Options:

Option Description
-i, --show-index Show the tensor index
-j, --json Output metadata in JSON format

Examples:

# View basic metadata
flashpack metadata ./my_model.flashpack

# View metadata with tensor index
flashpack metadata ./my_model.flashpack --show-index

# Output as JSON
flashpack metadata ./my_model.flashpack --json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flashpack-0.3.0.tar.gz (949.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flashpack-0.3.0-py3-none-any.whl (49.2 kB view details)

Uploaded Python 3

File details

Details for the file flashpack-0.3.0.tar.gz.

File metadata

  • Download URL: flashpack-0.3.0.tar.gz
  • Upload date:
  • Size: 949.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for flashpack-0.3.0.tar.gz
Algorithm Hash digest
SHA256 281f45666633fc9e7791c48e8a64bb78b57980f8065a94503b753e82961dceed
MD5 f9d5dc1d4a362dd48613805cd051be7a
BLAKE2b-256 bfce82021e5a1af42d4b7d4cc64e9b489a1b1b68da3aa04f0f7e10fbb3cef654

See more details on using hashes here.

Provenance

The following attestation bundles were made for flashpack-0.3.0.tar.gz:

Publisher: pypi.yaml on fal-ai/flashpack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flashpack-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: flashpack-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 49.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for flashpack-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8705df04b181442c07920988a6b4d73be9c628cd9cfd10b23978d2fc8a4898a
MD5 11c00010e1c9a439c55d89e375a86258
BLAKE2b-256 0bba6afff8b40b96efebd359e937e4d6f74178cffaa4acc9f68492b6a58593c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for flashpack-0.3.0-py3-none-any.whl:

Publisher: pypi.yaml on fal-ai/flashpack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page