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.15 (plus Triton 3.9 for piper-kernels quantized weight formats and GGUF checkpoints).

pip install piper-offload

The base install includes piper-kernels and supports all documented checkpoint and weight formats without optional extras; plain PyTorch tensors, safetensors checkpoints, and MpsWeights do not require Triton. See supported formats for platform and 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, configure offloaded modules with ModelSpec(..., config=OffloadConfig(offload_paths=("transformer_blocks",))) (optionally with vram_budget_bytes=..., or discover paths from an instantiated model with auto_offload_paths(model)); see streaming for the required model structure.

Fit and limitations

  • Each ModelSpec binds one cached model runtime and supports sequential use; concurrent replicas via cache.use() require separately constructed models under distinct keys. To share captured host backing across multiple independently bound shells under one cache key, see Share backing across models.
  • Models and adapters stay cached by default. Set a cache budget to evict inactive entries automatically. Host pinning (max_pinned_bytes) and Tier 2b private overflow (max_private_bytes) have separate budgets.
  • Models must be frozen (requires_grad=False) before capture. Factories transfer ownership of compatible CPU storage; 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 inference block forwards.

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 or compile inference blocks Streaming
Apply LoRA, dense deltas, or optional meta weights Adapters
Configure checkpoint backing, host pinning, and two-tier memory Memory
Check tensor formats and backend requirements 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.11.0rc3

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.11.0rc3
File Size Uploaded Provenance Actions
piper_offload-0.11.0rc3.tar.gz 162.7 kB With provenance Details for piper_offload-0.11.0rc3.tar.gz

Built distribution (wheel)

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

Total release size: 346.3 kB

Release files / piper_offload-0.11.0rc3.tar.gz

Download URL piper_offload-0.11.0rc3.tar.gz
Size 162.7 kB
Tags Source
SHA-256 checksum
How to use checksums
02c2327848c67594308b2798844e8c874ee81c67d26777765f5833b0390c448b
BLAKE2b-256 checksum
How to use checksums
71832bd15a1e2be3b08145fb6479da969fb763ca95c55028d851c8fee26d6c11
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 Dec 3, 2026.

Transparency log

Release files / piper_offload-0.11.0rc3-py3-none-any.whl

Download URL piper_offload-0.11.0rc3-py3-none-any.whl
Size 183.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aaea77d5f30483eb428080e58fa31ae63f61cae050c21fe886c1807778fcc063
BLAKE2b-256 checksum
How to use checksums
33c0cdd930bdb071f44744ba44900bb9ce25e060f49955c79fbbc887676a4f7d
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 Dec 3, 2026.

Transparency log

Security for piper-offload 0.11.0rc3

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.11.0rc3.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 Dec 3, 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