Skip to main content

Raafeli (CPU Turbo)

Zero-config Python decorator to speed up Deep Learning models on CPU by up to 300%.

Python License


⚡ The Problem: GPU-less Deployments

Deploying large AI models or running them on local machines without a dedicated GPU is painfully slow. Matrix multiplications inside torch.nn.Linear layers bottleneck heavily on CPU architectures because they process 32-bit floats natively.

🚀 The Solution: Raafeli

Raafeli automatically transforms your heavy FP32 PyTorch models into highly optimized INT8 (Dynamic Quantized) representations under the hood. All it takes is a single decorator. You do not need to change your architecture, deployment pipeline, or weights.

Quick Start

import torch
import torch.nn as nn
from raafeli import optimize_cpu

# 1. Your heavy model
class HeavyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(1024, 4096)
        self.fc2 = nn.Linear(4096, 1024)
        
    def forward(self, x):
        return self.fc2(torch.relu(self.fc1(x)))

model = HeavyModel()
input_data = torch.randn(1, 1024)

# 2. Decorate your prediction function
@optimize_cpu(model_arg="model", precision="int8")
def predict(model, data):
    return model(data)

# 3. Magic! First run takes a tiny fraction of a second to optimize,
#    all subsequent runs execute in INT8 natively on your CPU!
output = predict(model, input_data)

How It Works

When you call @optimize_cpu, Raafeli hooks into the execution stack. It intercepts the model object passed to your function, and aggressively applies torch.quantization.quantize_dynamic targeting performance-bound layers (like Linear and LSTM).

It caches the optimized model graph back into the object, ensuring the overhead is $0$ on every subsequent call. Your model footprint drops by ~75% and throughput spikes significantly.

Support This Project

Raafeli is an open-source project built out of passion. If it has saved you valuable GPU hours, deployment costs, or debugging time, consider supporting the creator by following on Instagram!

Follow on Instagram


Contributing & Testing

We welcome PRs! To run the test suite locally and verify your changes:

# Clone the repository
git clone https://github.com/ginganomercy/raafeli.git
cd raafeli

# Install with development dependencies
pip install -e .[dev]

# Run tests
pytest tests/

Metadata

Release files for raafeli 0.1.0

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

Source distribution (sdist)

Source distribution for raafeli 0.1.0
File Size Uploaded
raafeli-0.1.0.tar.gz 4.4 kB Details

Built distribution (wheel)

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

Total release size: 9.1 kB

Release files / raafeli-0.1.0.tar.gz

Download URL raafeli-0.1.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
efa68f349afeab2460136d7a979c745e467bd591017364d8bd4742283067e607
BLAKE2b-256 checksum
How to use checksums
cba645d3537f062b359e07ba3d90ada453d1f53ea1e8b0a95c5d1c1bf74e31e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 5, 2026.

Transparency log

Release files / raafeli-0.1.0-py3-none-any.whl

Download URL raafeli-0.1.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f175ef483ecd5aae91c214c1ad446f3853fca4ce06b0cfae6f6a6e9db18f2449
BLAKE2b-256 checksum
How to use checksums
6ee0df3faa4cba39e7f36e90ba419d4ca7bee06208e20c9931c12669a3655bb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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