Skip to main content

Pruna AI Logo

Element Simply make AI models faster, cheaper, smaller, greener! Element


Documentation   Try our Performance Models


GitHub License GitHub Actions Workflow Status GitHub Actions Workflow Status GitHub Release GitHub commit activity PyPI - Downloads Codacy

Website X (formerly Twitter) URL Devto Reddit Discord Huggingface Replicate


Pruna AI Logo

Pruna Cool Introduction

Pruna is a model optimization framework built for developers, enabling you to deliver faster, more efficient models with minimal overhead. It provides a comprehensive suite of compression algorithms including caching, quantization, pruning, distillation and compilation techniques to make your models:

  • Faster: Accelerate inference times through advanced optimization techniques
  • Smaller: Reduce model size while maintaining quality
  • Cheaper: Lower computational costs and resource requirements
  • Greener: Decrease energy consumption and environmental impact

The toolkit is designed with simplicity in mind - requiring just a few lines of code to optimize your models. It supports various model types including LLMs, Diffusion and Flow Matching Models, Vision Transformers, Speech Recognition Models and more.

Pruna Cool Installation

Pruna is currently available for installation on Linux, MacOS and Windows. However, some algorithms impose restrictions on the operating system and might not be available on all platforms.

Before installing, ensure you have:

  • Python 3.9 or higher
  • Optional: CUDA toolkit for GPU support

Option 1: Install Pruna using pip

Pruna is available on PyPI, so you can install it using pip:

pip install pruna

Option 2: Install Pruna from source

You can also install Pruna directly from source by cloning the repository and installing the package in editable mode:

git clone https://github.com/PrunaAI/pruna.git
cd pruna
pip install -e .

Pruna Cool Quick Start

Getting started with Pruna is easy-peasy pruna-squeezy!

First, load any pre-trained model. Here's an example using Stable Diffusion:

from diffusers import StableDiffusionPipeline
base_model = StableDiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5")

Then, use Pruna's smash function to optimize your model. Pruna provides a variety of different optimization algorithms, allowing you to combine different algorithms to get the best possible results. You can customize the optimization process using SmashConfig:

from pruna import smash, SmashConfig

# Create and smash your model
smash_config = SmashConfig(["deepcache", "stable_fast"])
smashed_model = smash(model=base_model, smash_config=smash_config)

Your model is now optimized and you can use it as you would use the original model:

smashed_model("An image of a cute prune.").images[0]

You can then use our evaluation interface to measure the performance of your model:

from pruna.evaluation.task import Task
from pruna.evaluation.evaluation_agent import EvaluationAgent
from pruna.data.pruna_datamodule import PrunaDataModule

datamodule = PrunaDataModule.from_string("LAION256")
datamodule.limit_datasets(10)
task = Task("image_generation_quality", datamodule=datamodule)
eval_agent = EvaluationAgent(task)
eval_agent.evaluate(smashed_model)

This was the minimal example, but you are looking for the maximal example? You can check out our documentation for an overview of all supported algorithms as well as our tutorials for more use-cases and examples.

Pruna Cool Algorithm Overview

Since Pruna offers a broad range of optimization algorithms, the following table provides a high-level overview of all methods available in Pruna. For a detailed description of each algorithm, have a look at our documentation.

Technique Description Speed Memory Quality
batcher Groups multiple inputs together to be processed simultaneously, improving computational efficiency and reducing processing time. ✅ ❌ ➖
cacher Stores intermediate results of computations to speed up subsequent operations. ✅ ➖ ➖
compiler Optimizes the model with instructions for specific hardware. ✅ ➖ ➖
distiller Trains a smaller, simpler model to mimic a larger, more complex model. ✅ ✅ ❌
quantizer Reduces the precision of weights and activations, lowering memory requirements. ✅ ✅ ❌
pruner Removes less important or redundant connections and neurons, resulting in a sparser, more efficient network. ✅ ✅ ❌
recoverer Restores the performance of a model after compression. ➖ ➖ ✅
factorizer Factorization batches several small matrix multiplications into one large fused operation. ✅ ➖ ➖
enhancer Enhances the model output by applying post-processing algorithms such as denoising or upscaling. ❌ ➖ ✅
distributer Distributes the inference, the model or certain calculations across multiple devices. ✅ ❌ ➖
kernel Kernels are specialized GPU routines that speed up parts of the computation. ✅ ➖ ➖

✅ (improves), ➖ (approx. the same), ❌ (worsens)



Pruna AI Logo


Pruna Sad FAQ and Troubleshooting

If you can not find an answer to your question or problem in our documentation, in our FAQs or in an existing issue, we are happy to help you! You can either get help from the Pruna community on Discord, join our Office Hours or open an issue on GitHub.

Pruna Heart Contributors

The Pruna package was made with 💜 by the Pruna AI team and our amazing contributors. Contribute to the repository to become part of the Pruna family!

Contributors

Pruna Emotional Citation

If you use Pruna in your research, feel free to cite the project! 💜

@misc{pruna,
    title = {Efficient Machine Learning with Pruna},
    year = {2023},
    note = {Software available from pruna.ai},
    url={https://www.pruna.ai/}
}

Pruna AI Logo

Metadata

Release files for pruna 0.3.5

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

Built distribution (wheel)

Table of built distributions (wheels) for pruna 0.3.5
File Interpreter ABI Platform Actions
pruna-0.3.5-py3-none-any.whl Python 3 none any Details for pruna-0.3.5-py3-none-any.whl

Release files / pruna-0.3.5-py3-none-any.whl

Download URL pruna-0.3.5-py3-none-any.whl
Size 423.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da008932f8afe2860f9d1ad2fe926a0ec7b2b2b667f2f5dccf28b9c32569ecef
BLAKE2b-256 checksum
How to use checksums
f7ef7beedd616ff7d00503f7d8876f9b9b4bd89582a50935d3a7eb115f7d91fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for pruna 0.3.5

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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