Runtime compression tuning utilities for PyTorch
Project description
rasnatune
rasnatune is a lightweight PyTorch compression helper based on forward hooks.
Installation
pip install rasnatune
What It Does
- Applies compression at runtime using hooks (no permanent weight rewrite).
- Supports quantization and unstructured sparsification.
- Targets
torch.nn.Conv2dandtorch.nn.Linear.
Quick Start
import torch
from rasnatune import Compression, SparseWeightUnstructured
model = torch.nn.Sequential(
torch.nn.Linear(128, 64),
torch.nn.ReLU(),
torch.nn.Linear(64, 10),
)
wrapped = Compression(model)
wrapped.attach(
SparseWeightUnstructured,
filter=lambda m: isinstance(m, torch.nn.Linear),
sparsity=0.5,
)
x = torch.randn(128)
y = wrapped(x)
Public API
Top-level exports:
rasnatune.Compressionrasnatune.Compressorrasnatune.QuantizeWeightrasnatune.QuantizeActivationrasnatune.SparseWeightUnstructuredrasnatune.SparseActivationUnstructured
Compression Classes
QuantizeWeight(min=-128, max=127): Quantizes layer weights only during forward, then restores original weights.QuantizeActivation(min=-128, max=127): Quantizes the first input activation of the layer before forward.SparseWeightUnstructured(sparsity=0.5): Applies unstructured sparsity to layer weights only during forward, then restores.SparseActivationUnstructured(sparsity=0.5): Applies unstructured sparsity to the first input activation before forward.
Notes
Compression.attachusesfilter=to choose target modules.- If
filteris omitted, it will try all submodules, and unsupported modules will raise an assertion. - Supported module types for built-in compressors are
torch.nn.Conv2dandtorch.nn.Linear.
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 Distribution
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 rasnatune-0.0.1.tar.gz.
File metadata
- Download URL: rasnatune-0.0.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98fd9d69080d720b5e7d350f46fb4c81ff7ac2dfbdd0b3996bf4873a7257d291
|
|
| MD5 |
90ff13f45dee6db59f06f11e1a52c57e
|
|
| BLAKE2b-256 |
9b6831356fb8a07d83095aed9aa4dac55114e7666e69b4c4fcf9dd9a7566f1d5
|
Provenance
The following attestation bundles were made for rasnatune-0.0.1.tar.gz:
Publisher:
rasnatune-pypi-publish.yml on spiceengine/rasnatune
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rasnatune-0.0.1.tar.gz -
Subject digest:
98fd9d69080d720b5e7d350f46fb4c81ff7ac2dfbdd0b3996bf4873a7257d291 - Sigstore transparency entry: 1459571624
- Sigstore integration time:
-
Permalink:
spiceengine/rasnatune@bc8e6f38bebccfc7cf5e62dc404e749fcd8bef10 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/spiceengine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
rasnatune-pypi-publish.yml@bc8e6f38bebccfc7cf5e62dc404e749fcd8bef10 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rasnatune-0.0.1-py3-none-any.whl.
File metadata
- Download URL: rasnatune-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80fcedef8fa4c929b2fa8bcccb00b282eae6f945882afe061e83b3391fb01718
|
|
| MD5 |
1afea827c8bed943478c65a0ff058439
|
|
| BLAKE2b-256 |
e44b43ca885400d0acf6af8bc10d5281ad569f5a5c9bb452397a7491465a989c
|
Provenance
The following attestation bundles were made for rasnatune-0.0.1-py3-none-any.whl:
Publisher:
rasnatune-pypi-publish.yml on spiceengine/rasnatune
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rasnatune-0.0.1-py3-none-any.whl -
Subject digest:
80fcedef8fa4c929b2fa8bcccb00b282eae6f945882afe061e83b3391fb01718 - Sigstore transparency entry: 1459571717
- Sigstore integration time:
-
Permalink:
spiceengine/rasnatune@bc8e6f38bebccfc7cf5e62dc404e749fcd8bef10 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/spiceengine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
rasnatune-pypi-publish.yml@bc8e6f38bebccfc7cf5e62dc404e749fcd8bef10 -
Trigger Event:
push
-
Statement type: