Sakura
Faster PyTorch training, without rewriting your training loop.
Documentation • Quickstart • Services • Benchmarks • Changelog
Sakura plugs into PyTorch DDP, Lightning and the Hugging Face Trainer, and adds training services you switch on one line at a time: evaluation and checkpointing that run off the training thread, mixed precision, torch.compile and ZeRO-1 optimizer sharding. Your model, data and loop stay as they are.
Try it in one command
git clone https://github.com/zakuro-ai/sakura && cd sakura
uv run demo.py
No GPU, no dataset download, no build step: uv installs the published sakura-ml wheel (and CPU-only PyTorch on Linux) into a throwaway environment, then trains the same small classifier twice, plain PyTorch first and then with Sakura's AsyncEval, and prints both timings. Each setup is first given its own fastest CPU thread count, so plain PyTorch isn't handicapped. On an Apple-silicon Mac it takes about 20 s from git clone to this, install included:
setup threads median time final val acc
plain PyTorch 1 0.43 s 0.779
with Sakura 1 0.32 s 0.779
1.36x faster on this machine (27% less wall-clock), same model, same accuracy:
evaluation now overlaps the next epoch instead of blocking it.
Your numbers will differ (five runs on that Mac: 1.31x to 1.36x). On a 2017 4-core Intel laptop the same demo measures about 1.03x, because training there already keeps every core busy and there is nothing for evaluation to overlap with; the demo says so instead of hiding it. The whole demo is one file, demo.py; the Sakura part is about fifteen lines of run_sakura().
Use it
pip install sakura-ml # wheels for macOS, Linux and Windows, Python 3.10+
pip install 'sakura-ml[lightning,huggingface]' # with the framework integrations
On Linux, add --extra-index-url https://download.pytorch.org/whl/cpu to get the CPU-only PyTorch build instead of the multi-GB CUDA one.
from sakura import SakuraRuntime
from sakura.adapters import DDPAdapter # or LightningAdapter, HFAdapter
from sakura.dispatch import ThreadDispatcher
from sakura.services import AsyncEval
with SakuraRuntime() as rt:
rt.install(AsyncEval(eval_fn=eval_epoch, # eval_fn(epoch, payload) -> dict, run off the training thread
eval_payload=snapshots, dispatcher=ThreadDispatcher()))
loop = DDPAdapter(rt, rank=0, world_size=1)
loop.on_train_begin(model, optimizer, train_loader)
for epoch in range(epochs):
loop.on_epoch_begin(epoch)
train_one_epoch(model, optimizer, train_loader)
snapshots[epoch] = {k: v.detach().clone() for k, v in model.state_dict().items()}
loop.on_epoch_end(epoch, model, optimizer, metrics={}) # evaluation starts in the background
loop.on_train_end(model) # waits for the last evaluation
demo.py is the complete, runnable version. Lightning and the Hugging Face Trainer take a callback instead of hook calls: see the quickstart.
Everything else is in the documentation: install options, services, adapters and dispatchers, benchmarks and migrating from 0.1. Sending work to a separate sakura-worker runs your callable there: read the dispatch trust model first. Sakura is part of Zakuro.
If Sakura saves you time, a ⭐ helps other people find it, and it's the easiest way to follow new releases.
Contributing • Security • BSD-3-Clause
Metadata
Release files for sakura-ml 1.2.2
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 |
|---|---|---|---|---|
| sakura_ml-1.2.2.tar.gz | 453.1 kB | Without provenance | Details for sakura_ml-1.2.2.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| sakura_ml-1.2.2-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for sakura_ml-1.2.2-cp310-abi3-win_amd64.whl |
| sakura_ml-1.2.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for sakura_ml-1.2.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| sakura_ml-1.2.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details for sakura_ml-1.2.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| sakura_ml-1.2.2-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for sakura_ml-1.2.2-cp310-abi3-macosx_11_0_arm64.whl |
Total release size: 8.5 MB
Release files / sakura_ml-1.2.2.tar.gz
| Download URL | sakura_ml-1.2.2.tar.gz |
|---|---|
| Size | 453.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a6979bb897fd94599be7d250c696fcb6f4d98b1ef6187cfd5088ccabbd47a1d
|
|
BLAKE2b-256 checksum How to use checksums |
38d250cc1734a728d73526e28b967bb6a5f2a4c69132dc37020cb0ecde4e01de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Release files / sakura_ml-1.2.2-cp310-abi3-win_amd64.whl
| Download URL | sakura_ml-1.2.2-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
25d7180a584015de6acbe840278147932e19d6798e9a075f42547e604e9fe58c
|
|
BLAKE2b-256 checksum How to use checksums |
b190df439321cb432e3c50f4bae000f4a463b7593d6c18167ced717d515550dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Release files / sakura_ml-1.2.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | sakura_ml-1.2.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
214ff99e8b3aa70a6ab46487adb2c0d7878eeaae2c0a48beb238d106fac13929
|
|
BLAKE2b-256 checksum How to use checksums |
4adf65e4278d9ce20a141f7597a6876ac9582997bc6221c7180f712bb1f3d3c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Release files / sakura_ml-1.2.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | sakura_ml-1.2.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
1910269f7387738e66928f151279eab95fb783a1f3884364fc4c36a4b2be3416
|
|
BLAKE2b-256 checksum How to use checksums |
b526ee4835b4eb96de6185a1f6e4022c1c05e4107fe8c5ff994ee318fb4a3211
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Release files / sakura_ml-1.2.2-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | sakura_ml-1.2.2-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
de1d73ee59ab3f4824df6208be7da155652ef3c09f847377691791f2a678cbac
|
|
BLAKE2b-256 checksum How to use checksums |
78a396b01c93e3fe616af21a8d74546d7aae28d977b6ab64d2d634ec126583a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Security for sakura-ml 1.2.2
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.