Skip to main content

Evencut

Find the GPU time your data-parallel training loses to padding and waiting, win it back with a drop-in batch sampler, and pick the machine that finishes the job for the least money.

In data-parallel training every GPU pads its batch to the longest sequence in it, and every optimizer step waits for the slowest GPU. With text of mixed lengths that can be most of the GPU time. Evencut measures how much, removes it without changing which sequences train together in a step, and tells you which machine runs your job for the least money.

Full documentation, with every measurement and its source: README on GitHub (also in Turkish).

Install

pip install "evencut[train]"   # evencut, the evencut-train command, and tokenizers for `evencut-train lengths`
pip install "evencut[hf]"      # adds the Hugging Face Trainer integration

Install PyTorch yourself, in the build that matches your GPU. The sampler and probe need it; diagnose and pick do not. Wheels with the native library are published for Linux (x86-64 and ARM64), Windows (64- and 32-bit) and macOS (Apple Silicon and Intel). Elsewhere pip builds the library from source, which needs a C++20 compiler; if that build fails, pip installs the pure-Python version, which gives the same answers more slowly. python -c "import evencut; print(evencut.backend)" shows which one you have.

Use

# 1. Where does the GPU time go? No GPU needed; takes seconds.
evencut-train diagnose lengths.txt --gpus 8 --per-device-batch 8 --max-len 2048

# 2. Measure a machine for your model shape: about two minutes, run on that machine.
torchrun --standalone --nproc-per-node=gpu -m evencut.train probe \
    --layers 12 --d-model 768 --vocab 32000 --max-len 2048 --price-per-hour 1.90 -o box.json

# 3. Which machine finishes the job for the least money?
evencut-train pick lengths.txt --sequences-per-step 64 --per-device-batch 8 --probe box.json other.json

The fix is one line in the training script:

loader = DataLoader(ds, batch_sampler=BalancedBatchSampler(lengths, per_device_batch=8), collate_fn=pad_to_longest)

Recipes for PyTorch DDP, the Hugging Face Trainer, Lightning and Accelerate are in the README.

Results

Time per optimizer step for four setups: DistributedSampler, Hugging Face group_by_length and batch_rebalance, and Evencut

setup DistributedSampler HF group_by_length HF batch_rebalance Evencut
2x A100 SXM4 80GB, rented. Dolly-15k, 32 sequences × accumulation 8 236.1 ms 149.4 ms (1.58x) not run 139.5 ms (1.69x)
2x RTX 4090, rented. Same job 323.9 ms 308.5 ms (1.05x) not run 308.5 ms (1.05x)
RTX 4060 simulating 8 GPUs. Dolly-15k, 128 sequences × accumulation 8 1,365 ms 395.9 ms (3.45x) 339.7 ms (4.02x) 337.2 ms (4.05x)
RTX 4060 simulating 8 GPUs. Wikipedia-TR, 48 sequences per step 203.2 ms 89.5 ms (2.27x) 76.4 ms (2.66x) 65.7 ms (3.09x)

Time per optimizer step, lower is better. In every Evencut row each step trains on exactly the sequences a shuffled DistributedSampler run puts in it; only which GPU gets which sequence changes. Not every machine gains: on the 2x RTX 4090 box padding fell from 73% to 10% of the tokens, yet the step got only 5% faster, and diagnose with a probe of the machine shows this before you change anything. Where every number comes from is listed in How we tested.

Under the training tools is an exact partitioning engine (C++ header, C ABI, CLI, Python, HTTP service): give it an ordered list of costs and a number of parts, and it returns the proven optimal cut points. See The partitioning engine.

License

Dual-licensed under MIT or Apache 2.0, at your option. Security problems: please report them privately as described in SECURITY.md.

Metadata

Release files for evencut 1.0.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 evencut 1.0.0
File Size Uploaded Provenance Actions
evencut-1.0.0.tar.gz 186.7 kB With provenance Details for evencut-1.0.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for evencut 1.0.0
File Actions
evencut-1.0.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for evencut-1.0.0-py3-none-win_amd64.whl
evencut-1.0.0-py3-none-win32.whl Python 3 none Windows x86-32 Details for evencut-1.0.0-py3-none-win32.whl
evencut-1.0.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details for evencut-1.0.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
evencut-1.0.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details for evencut-1.0.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
evencut-1.0.0-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details for evencut-1.0.0-py3-none-macosx_11_0_x86_64.whl
evencut-1.0.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for evencut-1.0.0-py3-none-macosx_11_0_arm64.whl

Total release size: 1.1 MB

Release files / evencut-1.0.0.tar.gz

Download URL evencut-1.0.0.tar.gz
Size 186.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7f59efcee3868d11d8817ed2a03eea938038450686394fbc9b875e3c13d4d649
BLAKE2b-256 checksum
How to use checksums
9552356057fce2731d7141987766614af458a443d76123c014dbf7b1a26c9123
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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

Transparency log

Release files / evencut-1.0.0-py3-none-win_amd64.whl

Download URL evencut-1.0.0-py3-none-win_amd64.whl
Size 185.2 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
3a40cd0d2cb310164f4221c4958bc023966edf4c8683178326a2a61e914b088a
BLAKE2b-256 checksum
How to use checksums
56e6513a09052704e4829faa64b842ff7e5d39a49b232fae8a6121addc334189
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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

Transparency log

Release files / evencut-1.0.0-py3-none-win32.whl

Download URL evencut-1.0.0-py3-none-win32.whl
Size 177.7 kB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
33a4959ca99eed4176a4906ecb1d3ae9e69eb8c4fcb4bbea729f59153e8f0671
BLAKE2b-256 checksum
How to use checksums
0114b560041e152bb2b1a8f080c34e4abed79c6cf75cc2f57d677aada6e0ac97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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

Transparency log

Release files / evencut-1.0.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL evencut-1.0.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 138.9 kB
Tags Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
226490bc9be42bd78f13b4999c6f64c76abee7649f4da630a02cbee600347304
BLAKE2b-256 checksum
How to use checksums
52a155b31d539eebdb3e352659b66e8e448705292e837e830058b0cd2fc365d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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

Transparency log

Release files / evencut-1.0.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL evencut-1.0.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 133.5 kB
Tags Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
e4af5f7f4f7c2555c40813e4f7263ad5859c2663153d4fdda5dede0b23ec73ad
BLAKE2b-256 checksum
How to use checksums
bce2fc2af393f80898a3dc8863444c4439525862174d5ca9e74067d4c7da3a9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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

Transparency log

Release files / evencut-1.0.0-py3-none-macosx_11_0_x86_64.whl

Download URL evencut-1.0.0-py3-none-macosx_11_0_x86_64.whl
Size 120.3 kB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
14d2c2b7d8414a3e0d54355d52158d531877dcd7d7916a10322e719be4979660
BLAKE2b-256 checksum
How to use checksums
bef9dd9fa314c33b3618747e7f281976a441e43876a77b0a1a86a55f15956cf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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

Transparency log

Release files / evencut-1.0.0-py3-none-macosx_11_0_arm64.whl

Download URL evencut-1.0.0-py3-none-macosx_11_0_arm64.whl
Size 118.6 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
28ddac5b6bbb7f5d371f86b8d0e2120f670dda9b9bef54724c39cc09d7fe1a50
BLAKE2b-256 checksum
How to use checksums
e45c588630904ea6f5c64a5f1b6d4ec49d6504b40c34d112abc289d25028242e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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

Transparency log

Security for evencut 1.0.0

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 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for evencut-1.0.0.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 Nov 5, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

7 release files Full provenance

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