memopro
Run work that does not fit in your machine's memory, with exactly the same results.
한국어 · English
pip install "memopro[llm]"
import memopro
# 16-bit LoRA of a 7B model (14 GB of weights) on an 8 GB MacBook
r = memopro.finetune("Qwen/Qwen2.5-7B-Instruct", texts, budget="2GiB")
print(memopro.generate(r.model, "Hello!"))
When to use it
- 🧠 You want to train or run a language model bigger than your laptop: fine-tune a 7B model on an 8 GB MacBook, or run models bigger than the GPU on free Colab.
- 🖼️ You need a large vision model on little memory: use a downloaded Hugging Face model as it is, even if it is bigger than memory.
- 📊 Your script dies with "out of memory" because the data is bigger than RAM: run it unchanged with one line,
memopro run. - 🎯 The results must stay exactly the same: no 4-bit quantization or other accuracy trade-offs. Outputs and losses are bit-identical.
memopro promises three things:
- ✅ Results do not change. It spends time, not accuracy, to save memory.
- ✅ It runs within the memory ceiling you set. A budget that cannot work is refused before starting. If an unchanged program must pass the ceiling, memopro warns at that moment and reports by how much.
- ✅ It never writes to disk. No swap files, no cache files.
How to use it
1. Fine-tune a language model on a MacBook
import memopro
r = memopro.finetune(
"Qwen/Qwen2.5-7B-Instruct", texts,
budget="2.5GiB", # the memory ceiling
batch="auto", # the largest batch that fits (larger is faster)
)
r.adapter.save_pretrained("my-lora") # a standard PEFT adapter
print(r.losses, r.batch)
7B trains at about 15 tokens/s on an 8 GB M1. Training the same data under another budget gives bit-identical losses.
2. Generate text (faster, same output)
text = memopro.generate(r.model, "Summarize: ...", draft="Qwen/Qwen2.5-1.5B-Instruct")
With a small draft model, the small model guesses ahead and the large one only checks. The output is identical to the large model alone, and 3.8x faster for 7B.
3. Models bigger than an NVIDIA GPU (Colab and others)
# the same code as on a Mac: an NVIDIA GPU is used when present
r = memopro.finetune("mistralai/Mistral-7B-Instruct-v0.3", texts, budget="4GiB", batch="auto")
On a free Colab T4 (15 GB), 16-bit LoRA of a 7B model takes about 6 s per 256-token step.
4. Large vision models
import transformers
import memopro.rt.torch as rtt
m = rtt.stream_model("facebook/dinov2-giant", budget="1GB", device="cuda", # "mps", "cpu"
model_class=transformers.Dinov2Model)
features = m(pixel_values=images).pooler_output # same output as the model loaded plainly
5. Run your script unchanged
memopro run --budget 8GB analysis.py # large NumPy arrays compressed losslessly within the ceiling
memopro run --budget 50% train.py # within half of the measured free memory
memopro run --dry-run train.py # only show what it would do
6. Add one line to your code
import memopro
s = memopro.enable(budget="8GB") # a ceiling for this whole process
print(s.estimate(sample, total="12GB", passes=3)) # before: how many seconds it will add
... # your NumPy / PyTorch code as usual
print(s.measured()) # after: real time and peak memory
7. Check before running
memopro doctor # usable memory per device
memopro check Qwen/Qwen2.5-7B-Instruct --batch-size 4 --seq-len 512 # does this model fit
More examples: user guide
Budgets
Every function, --budget, memopro.toml and the MEMOPRO_BUDGET variable take the same forms.
| Form | Meaning |
|---|---|
"auto" |
measured free memory − 10% (default) |
"6GB", "50%", 0.5 |
a size, or a share of the free memory |
"-2GB" |
everything but 2 GB |
"2GB..6GB" |
at most 6 GB; do not start below 2 GB |
"6GB!" |
6 GB whatever was measured (you accept the swap risk) |
Results
Every result was measured against pass criteria fixed before running. Raw data: docs/research/data/.
🍎 MacBook Air M1 (8 GB)
| What we tried | Result |
|---|---|
| Qwen2.5-7B LoRA (14 GB of weights) | ✅ completed at a 1.5 GiB budget; 15.5 tokens/s with batch=4; same losses under every budget |
| Qwen2.5-3B LoRA vs mlx-tune | ✅ mlx-tune runs out of memory before step 1; memopro trains at 1 GiB, 20 tokens/s |
| Qwen2.5-7B generation with a draft model | ✅ identical output, 8.95 → 2.37 s/token |
| Qwen2.5-3B generation vs llama.cpp | ✅ memopro 1.09 s/token, llama.cpp (CPU) 14.75 s/token |
| NumPy image pipeline at half its memory | ✅ identical result, within the ceiling + 1.8 MiB; slowdown predicted 3.81 s, measured 3.72 s |
🟩 Free Google Colab T4 (15 GB GPU, 12.7 GB RAM)
Installed from PyPI (0.1.4) on a fresh runtime.
| What we tried | Result |
|---|---|
| Five language models: Qwen2.5-1.5B, SmolLM2-1.7B, Phi-3.5-mini, Mistral-7B, Qwen2.5-14B | ✅ generated tokens and training losses identical across budgets |
| Speed of small models (1.5B–3.8B) | training 1.00–1.03x, generation 1.06–1.35x (less memory, nearly the same speed) |
| Mistral-7B 16-bit LoRA | ✅ about 6 s per 256-token step, about 43 tokens/s |
| Qwen2.5-14B 16-bit LoRA | ⚠️ completed, but about 125 s per step (about 1 token/s); plain PyTorch and Unsloth 16-bit failed. Possible, not practical |
| Vision: DINOv2-giant, ConvNeXtV2-Huge, ResNet-152 | ✅ outputs bit-identical to the plain model |
| NumPy, scikit-learn, CSV, image preprocessing at ½ and ¾ of their memory | ✅ identical results; ceiling kept, or warned and reported when it could not be; 1.1–3.4x slower |
What is practical
| Situation | What to expect |
|---|---|
| A model a little bigger than memory (7B on an 8 GB Mac, 7B on a T4) | ✅ practical: 8–45 tokens/s |
| A model that fits in memory | little reason to use memopro: Unsloth and mlx-tune are faster (10–33x on a T4) |
| A model far bigger than memory (14B on a T4) | ⚠️ runs, but storage read speed makes it very slow |
| You can accept a small accuracy loss | 4-bit QLoRA is much faster |
| Data work with lots of random access (sorts, joins, Polars) | ⚠️ results are right, but it can get much slower |
Install and platforms
| Install | For |
|---|---|
pip install memopro |
memopro run, enable, the runtime, diagnostics |
pip install "memopro[llm]" |
finetune, generate (with PyTorch, Transformers, PEFT) |
pip install "memopro[notebook]" |
Jupyter magics (%hibernate, %wake) |
| Platform | Status |
|---|---|
| 🍎 macOS, Apple silicon | main development platform, every feature |
| 🟩 Linux + NVIDIA GPU | verified on a Colab T4 |
| 🐧 Linux CPU | verified in CI |
| 🪟 Windows | basic features only |
Python 3.11+, PyTorch 2.4+. Wheels on PyPI for macOS arm64 and Linux x86_64/aarch64. Also usable from Rust (crates.io) and C (crates/memopro-c).
How is this possible?
memopro empties data you are not using and brings it back when it is needed. For a language model it reads only the weights of the layer being computed from the original file, and drops them afterwards. Other data is compressed losslessly, so it comes back byte for byte. Nothing is approximated or quantized: results stay the same, only time is added. Details: design documents.
Good to know
- On Apple GPUs, call
finetune/stream_modelbefore other MPS work so the memory setting applies (a late call warns). - Using only the vision tower of a combined checkpoint (CLIP, SigLIP) is fixed in the next release.
- This is an alpha: the API may change. See the CHANGELOG.
Development
python3 -m venv .venv && .venv/bin/pip install "maturin>=1.9,<2" pytest ruff
VIRTUAL_ENV=$PWD/.venv .venv/bin/maturin develop --release
.venv/bin/pytest -q
cargo test -p memopro
Citation
If you use memopro in research, please cite it with "Cite this repository" (CITATION.cff).
License
MIT or Apache-2.0, at your option.
Metadata
Release files for memopro 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| memopro-0.1.5.tar.gz | 230.4 kB | With provenance | Details for memopro-0.1.5.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| memopro-0.1.5-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ x86-64 | Details for memopro-0.1.5-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| memopro-0.1.5-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ ARM64 | Details for memopro-0.1.5-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| memopro-0.1.5-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details for memopro-0.1.5-cp311-abi3-macosx_11_0_arm64.whl |
Total release size: 3.3 MB
Release files / memopro-0.1.5.tar.gz
| Download URL | memopro-0.1.5.tar.gz |
|---|---|
| Size | 230.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
309fc31883a341ff0e22de4fc54a7ca1ccafdf79b394ac1ae61e2d20aec3b4b4
|
|
BLAKE2b-256 checksum How to use checksums |
046f0348d128894b725206c26b92736b24fd81893f5be358dfbc4359f98af76e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 14, 2026.
Transparency logRelease files / memopro-0.1.5-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | memopro-0.1.5-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7aef63bea10ecc15b69b534875740ca04ae3297cf47db6e56f1ce6da07d0907f
|
|
BLAKE2b-256 checksum How to use checksums |
bf55d8e823726bb15d145f314af4bd3f439f8c6fadf9534109dfc8f779b3a478
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 14, 2026.
Transparency logRelease files / memopro-0.1.5-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | memopro-0.1.5-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a0f704d4458f86a1b71c5a6ce05cd6588acf73d3006950e5fa3dd33a50cd67e5
|
|
BLAKE2b-256 checksum How to use checksums |
8c18d3468dd75d6b93b83a2c9947f286500697dbf241014f02be20b17e06b901
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 14, 2026.
Transparency logRelease files / memopro-0.1.5-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | memopro-0.1.5-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 876.6 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4a41635748164318b1b57a24506d44d43013491bd5a29152751d4fc17d02ea40
|
|
BLAKE2b-256 checksum How to use checksums |
a00680c87c798df410b7e7d13b0c5e217e5a7f8c3db0f3ebb86ce3cf019fc92d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 14, 2026.
Transparency logSecurity for memopro 0.1.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.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for memopro-0.1.5.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 Oct 14, 2026.
Transparency logA 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.