A blazingly fast Rust-powered image loader for Python.
Project description
Vantix
A fast image loader for Python, built in Rust.
PyTorch's DataLoader is fine, but it hits a wall pretty fast when you have a lot of images — the Python GIL and slow JPEG decoding eat up a huge chunk of your GPU's potential throughput. Vantix moves all of that work (decoding, resizing, normalizing) into a multi-threaded Rust backend, hands you a ready-to-use float32 tensor, and gets out of the way. On some workloads it's over 9× faster than a standard PyTorch pipeline.
How it works
The Rust core (src/lib.rs) uses:
rayon— spawns one thread per CPU core, each decoding and resizing one image in parallelfast_image_resize— SIMD-accelerated resizing (AVX2 on x86, NEON on ARM) so bilinear resize is basically freepyo3+numpy— the output buffer is handed back to Python as a NumPy array with zero extra copies
On the Python side, VantixLoader (python/vantix/loader.py) wraps everything in a prefetch queue: a background thread keeps up to 3 batches queued so your training loop never waits on I/O. It also supports PyTorch DDP (multi-GPU) out of the box by sharding indices across ranks.
Features
- True parallelism — bypasses the Python GIL entirely, all decoding happens in Rust threads
- SIMD resizing — hardware-accelerated, way faster than Pillow
- Zero-copy tensor handoff — the NumPy array converts to a PyTorch tensor without duplicating memory
- Fused pipeline — resize + optional random horizontal flip + normalize all in one pass
- DDP ready — automatically shards the dataset across GPUs when using distributed training
- Drop-in replacement — same interface as a standard PyTorch
IterableDataset
Quick start
Install (from source, for now)
You need Rust and maturin installed first:
pip install maturin
maturin develop --release
Once it's published on PyPI:
pip install vantixloader
Basic usage
from vantixloader import VantixLoader
import glob
paths = glob.glob("data/train/**/*.jpg", recursive=True)
loader = VantixLoader(
image_paths=paths,
width=224,
height=224,
batch_size=64,
augment=True, # random horizontal flip
shuffle=True,
)
for batch in loader:
# batch is a float32 torch.Tensor of shape [B, 3, H, W]
outputs = model(batch.to("cuda"))
Parameters
| Parameter | Default | Description |
|---|---|---|
image_paths |
— | List of paths to images on disk |
width |
224 |
Target width after resize |
height |
224 |
Target height after resize |
batch_size |
64 |
Images per batch |
augment |
False |
Random horizontal flip (50% chance per image) |
shuffle |
True |
Shuffle order every epoch |
transform |
None |
Optional Python transform applied after loading |
queue_size |
3 |
Number of batches to prefetch in the background |
Benchmarks
See BENCHMARK.md for full results. Short version:
| Dataset | PyTorch (img/s) | Vantix (img/s) | Speedup |
|---|---|---|---|
| CIFAR-Like (32 px) | ~1 750 | ~16 400 | ~9.4× |
| ImageNet (224 px) | ~420 | ~1 020 | ~2.4× |
| 4K Medical (2048→224) | ~65 | ~180 | ~2.8× |
Running the benchmarks yourself
# 1. Build the Rust extension
maturin develop --release
# 2. Download + prep CIFAR-10 test data
python benchmarks/prepare_data.py
# 3. Raw throughput (images/sec)
python benchmarks/benchmark_throughput.py
# 4. End-to-end training speedup
python benchmarks/benchmark_training.py
Charts are saved to assets/.
Project structure
vantix/
├── src/lib.rs # Rust core: parallel decode, resize, normalize
├── python/vantixloader/
│ ├── __init__.py
│ └── loader.py # VantixLoader — Python wrapper + prefetch queue
├── benchmarks/
│ ├── benchmark_throughput.py # Raw img/s benchmark
│ └── benchmark_training.py # Full training loop speedup benchmark
├── assets/ # Benchmark charts
├── Cargo.toml # Rust dependencies
└── pyproject.toml # Python packaging (maturin)
License
MIT — Carl Kemmerich
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 Distributions
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 vantixloader-0.1.1.tar.gz.
File metadata
- Download URL: vantixloader-0.1.1.tar.gz
- Upload date:
- Size: 105.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d59f43b3fb8caf1f152af08a1f41d93f44314c90fb1f54397c3d94934606bcde
|
|
| MD5 |
7fd364b92e3f47c2fc74e4c501a3bc10
|
|
| BLAKE2b-256 |
e7d0a7f584b5b500a43efeda184665bce5406227590c8e7c7468a9c48fe6071e
|
Provenance
The following attestation bundles were made for vantixloader-0.1.1.tar.gz:
Publisher:
CI.yml on carlk13/vantix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vantixloader-0.1.1.tar.gz -
Subject digest:
d59f43b3fb8caf1f152af08a1f41d93f44314c90fb1f54397c3d94934606bcde - Sigstore transparency entry: 997358733
- Sigstore integration time:
-
Permalink:
carlk13/vantix@6210c6f19ef683cd1c176e8a35f415f050748761 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/carlk13
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@6210c6f19ef683cd1c176e8a35f415f050748761 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vantixloader-0.1.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: vantixloader-0.1.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ee9f28c4c7f1e2771dba7af9bd13ed58ed374cdaef5dd62812c576e0001f08a
|
|
| MD5 |
4424264ff9f4b0a6420a78238d53e805
|
|
| BLAKE2b-256 |
b9a8168d170df82f720ab1b01341a56843bbf903064acf5c50eee938acd156b0
|
Provenance
The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-win_amd64.whl:
Publisher:
CI.yml on carlk13/vantix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vantixloader-0.1.1-cp310-cp310-win_amd64.whl -
Subject digest:
6ee9f28c4c7f1e2771dba7af9bd13ed58ed374cdaef5dd62812c576e0001f08a - Sigstore transparency entry: 997358785
- Sigstore integration time:
-
Permalink:
carlk13/vantix@6210c6f19ef683cd1c176e8a35f415f050748761 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/carlk13
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@6210c6f19ef683cd1c176e8a35f415f050748761 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vantixloader-0.1.1-cp310-cp310-win32.whl.
File metadata
- Download URL: vantixloader-0.1.1-cp310-cp310-win32.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.10, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21ef875d03f094e289dc318859fc3f7e9b04a412eea17100355dceed0e87cac9
|
|
| MD5 |
e181492e046244c7af652e76b5b9051d
|
|
| BLAKE2b-256 |
1136a7d0802a03cef4daf4b3afb1f1f17cc87cdeaddb9c3d3beef8a892eff66d
|
Provenance
The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-win32.whl:
Publisher:
CI.yml on carlk13/vantix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vantixloader-0.1.1-cp310-cp310-win32.whl -
Subject digest:
21ef875d03f094e289dc318859fc3f7e9b04a412eea17100355dceed0e87cac9 - Sigstore transparency entry: 997358792
- Sigstore integration time:
-
Permalink:
carlk13/vantix@6210c6f19ef683cd1c176e8a35f415f050748761 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/carlk13
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@6210c6f19ef683cd1c176e8a35f415f050748761 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vantixloader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: vantixloader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f293c7c09ab8541dc22bb7889e93f62af9e37ab2a1ceb875cab2de679d0b355
|
|
| MD5 |
6d5b83144a1d39917fc94b58375d7f00
|
|
| BLAKE2b-256 |
6475cbab25dc2aa40a6de48e7a3dfa3671e4d0ee99a2c000f7a0109319f24ed8
|
Provenance
The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
CI.yml on carlk13/vantix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vantixloader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
1f293c7c09ab8541dc22bb7889e93f62af9e37ab2a1ceb875cab2de679d0b355 - Sigstore transparency entry: 997358774
- Sigstore integration time:
-
Permalink:
carlk13/vantix@6210c6f19ef683cd1c176e8a35f415f050748761 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/carlk13
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@6210c6f19ef683cd1c176e8a35f415f050748761 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vantixloader-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: vantixloader-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21bebf9866143d529c894c0f1a153d6bff42c76eb27083018cdc4c020c611f24
|
|
| MD5 |
4682e48b61785e55ba56228cb4f309dd
|
|
| BLAKE2b-256 |
855f5f37de5001931b79e2f8f9c02e8dae70df14cb4af6c498a2c55c30f34417
|
Provenance
The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
CI.yml on carlk13/vantix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vantixloader-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
21bebf9866143d529c894c0f1a153d6bff42c76eb27083018cdc4c020c611f24 - Sigstore transparency entry: 997358753
- Sigstore integration time:
-
Permalink:
carlk13/vantix@6210c6f19ef683cd1c176e8a35f415f050748761 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/carlk13
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@6210c6f19ef683cd1c176e8a35f415f050748761 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vantixloader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: vantixloader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
add80a98d747bdfc3f995ac1ed762c7ae8478bd37081a743e8064e56b7e96bbb
|
|
| MD5 |
da64e9165fc72e345f8be97a0f0c231c
|
|
| BLAKE2b-256 |
0dcbfca7bd3d6a0586ccfc757c87b73a2d7bca567776708f2552e178161a6c2a
|
Provenance
The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl:
Publisher:
CI.yml on carlk13/vantix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vantixloader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl -
Subject digest:
add80a98d747bdfc3f995ac1ed762c7ae8478bd37081a743e8064e56b7e96bbb - Sigstore transparency entry: 997358744
- Sigstore integration time:
-
Permalink:
carlk13/vantix@6210c6f19ef683cd1c176e8a35f415f050748761 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/carlk13
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@6210c6f19ef683cd1c176e8a35f415f050748761 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vantixloader-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl.
File metadata
- Download URL: vantixloader-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.10, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08d4a6006887efed8ff39791b80f8af23933372467df4c88d1a6aff9655da0c6
|
|
| MD5 |
07cd78c6d8367481f224c2ce10dee937
|
|
| BLAKE2b-256 |
05e87ba0764865d950e3e42f3a4eef1322bf3d242786da8c6920c66df47d059c
|
Provenance
The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl:
Publisher:
CI.yml on carlk13/vantix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vantixloader-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl -
Subject digest:
08d4a6006887efed8ff39791b80f8af23933372467df4c88d1a6aff9655da0c6 - Sigstore transparency entry: 997358767
- Sigstore integration time:
-
Permalink:
carlk13/vantix@6210c6f19ef683cd1c176e8a35f415f050748761 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/carlk13
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@6210c6f19ef683cd1c176e8a35f415f050748761 -
Trigger Event:
push
-
Statement type: