FlexTensor: Tensor offloading and management library
Project description
FlexTensor
FlexTensor is a tensor offloading and management library for PyTorch that enables running large models on limited GPU memory by intelligently offloading tensors between GPU and CPU memory.
Features
- Simplified API: Easy-to-use high-level API for automatic tensor offloading
- Automatic Model Patching: Offload model layers without modifying model code
- Manual Control: Fine-grained control with
offload_blockcontext managers - Smart Profiling: Automatic warmup and profiling for optimal performance
- Wildcard Support: Use patterns like
"layers.*"to offload multiple modules - Profile Persistence: Save and load offloading profiles for faster startup
- Lazy Model Initialization: Load models from saved profiles with optimized weight loading
- Shared Memory: Optional shared memory subsystem for cross-process tensor coordination
Documentation
For detailed guides, API reference, and more, visit our Documentation.
Quick Installation
To install FlexTensor from PyPI:
pip install flextensor
For more installation options (source, dev, optional dependencies), see the Installation Guide.
Quick Example
import flextensor
from flextensor import OffloadConfig
# Your existing model
model = YourModel()
# Configure offloading
config = OffloadConfig(
gpu_device=0, # GPU to use
warmup_iters=1, # Iterations for tensor discovery
profile_iters=10, # Iterations for timing measurement
module_patterns=["layers.*"], # Which modules to offload
)
# Patch the model
model = flextensor.offload(model, config=config)
# Use normally - first warmup_iters + profile_iters iterations are warmup/profile
for batch in dataloader:
output = model(batch) # FlexTensor handles everything
See the Quick Start for more examples.
License
FlexTensor is licensed under the Apache License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flextensor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flextensor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 177.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2155738382659e9a7d9fa5d06581f0d716021799a0141022b87d32265e83e55f
|
|
| MD5 |
b7ef8f494e52c60c87592705f144ee47
|
|
| BLAKE2b-256 |
b5a3117d4f6bce7f272fd147a888be87fcdfe5703b852dfede7ba94f60c220c7
|