Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Piper Offload

Keep reusable PyTorch models in host memory and move their weights onto a GPU when needed. Piper Offload manages whole-model uploads when a model fits in VRAM, and block streaming when it does not. Models and adapters stay cached between uses, including compatible checkpoint mappings.

Use it for workloads that run several models in sequence or repeatedly reuse large models. ModelCache handles caching and activation; ModelOffloader provides direct control over one model's lifecycle.

Installation

Requires Python 3.14 or newer and PyTorch 2.14.

pip install piper-offload

The base dependencies are torch and piper-kernels. Optional integrations are available through the bnb, quanto, gguf, and torchao extras; triton adds accelerated kernels, and all includes every integration. See supported formats for backend requirements.

Quick start

This example runs on CUDA when available and on CPU otherwise. The factory builds a fresh model; the cache retains it for subsequent uses.

import torch
from torch import nn
from piper_offload import ModelCache, ModelSpec


def build_model():
    return nn.Sequential(
        nn.Linear(8, 16), nn.ReLU(), nn.Linear(16, 4),
    ).eval().requires_grad_(False)


cache = ModelCache()
spec = ModelSpec(key="example", factory=build_model)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

for _ in range(2):
    inputs = torch.randn(1, 8, device=device)
    with cache.use(spec, device=device) as model, torch.inference_mode():
        output = model(inputs)

print(output.shape)  # torch.Size([1, 4])
del model  # release the reference returned by the last use
cache.clear()

Each use() activates the model and deactivates it on exit. Place inputs on the compute device yourself. For a model larger than VRAM, select its block lists with ModelSpec(..., block_paths=("transformer_blocks",)); see streaming for the required model structure.

Fit and limitations

  • Each cached model has one runtime and supports sequential use. Concurrent replicas need separately constructed models under distinct keys.
  • ModelCache retains host state until explicit eviction. Pinned memory has a separate budget; cache accounting is not a limit on process RAM.
  • Factories transfer ownership of compatible CPU storage. Set requires_grad before capture and do not mutate factory-produced tensors afterwards.
  • Buffer changes made on CUDA are discarded at deactivation. Models that need persistent buffer state across calls require a different arrangement.
  • Compilation supports declared block forwards. Streamed training requires activation checkpointing and explicit handling of optimizer updates.

Documentation

Both application developers and coding agents can start with the relevant topic. These links point to main; select the matching Git tag when integrating a pinned release.

Task Read
Cache models, manage activation, inspect or release resources Models
Run models larger than VRAM, compile blocks, or train streamed weights Streaming
Apply LoRA, parameter deltas, or parameter values Adapters
Configure checkpoint backing, pinning, and Windows copy retention Memory
Check tensor formats, optional dependencies, or DTensor support Formats
Understand the implementation or contribute changes Development

Contributor instructions are in AGENTS.md. See versioning and releases for compatibility policy and the changelog for release history.

Licensed under the Apache License, Version 2.0.

Metadata

Release files for piper-offload 0.10.0rc11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for piper-offload 0.10.0rc11
File Size Uploaded Provenance Actions
piper_offload-0.10.0rc11.tar.gz 250.1 kB With provenance Details for piper_offload-0.10.0rc11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for piper-offload 0.10.0rc11
File Interpreter ABI Platform Actions
piper_offload-0.10.0rc11-py3-none-any.whl Python 3 none any Details for piper_offload-0.10.0rc11-py3-none-any.whl

Total release size: 564.6 kB

Release files / piper_offload-0.10.0rc11.tar.gz

Download URL piper_offload-0.10.0rc11.tar.gz
Size 250.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9c6a3db60b0f56d2ef24c45c2b5906351da271d66acea983edc9d99039941c14
BLAKE2b-256 checksum
How to use checksums
c4b55929100c68264332102b63ab297c15e0993ac661c7f42a3ade52bb2199f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / piper_offload-0.10.0rc11-py3-none-any.whl

Download URL piper_offload-0.10.0rc11-py3-none-any.whl
Size 314.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49d60a6ce6f0c7b5b85ac723a8ce8f263228ec85b58b460d60ea9a17856e1a5f
BLAKE2b-256 checksum
How to use checksums
59464a62b92a212f439d475f970403469bca6ec2eca79fb376e42fe5c3dcdcb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for piper-offload 0.10.0rc11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for piper_offload-0.10.0rc11.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page