tqdx
Adds tqdm progress bars to jax.lax.scan and jax.lax.fori_loop. Progress bars commonly used in Python, such as tqdm, are not compatible with JAX's jit-compiled functions due to restrictions on side effects like printing. tqdx addresses this limitation by using callbacks to update progress bars created on the host.
import tqdx
...
carry, ys = tqdx.scan(f, init, xs)
Processing: 100%|███████████████████████████████████████████| 50/50 [02:38<00:00, 3.20s/it]
Features
- Progress bars for JAX: See the progress of your computations when using
jax.lax.scanandjax.lax.fori_loop. - Works with
jax.jit: Progress bars show up even inside jit-compiled code. - Minimal syntax change: Just replace your calls to
jax.lax.scanandjax.lax.fori_loopwithtqdx.scanandtqdx.fori_loop. - No extra dependencies: Only requires JAX and tqdm.
Usage
The following example demonstrates how to use tqdx with jax.lax.scan and jax.lax.fori_loop. You can arbitrarily nest these functions, and the progress bars will still work correctly.
import jax
import tqdx
from time import sleep
def step(carry, x):
def body_fun(i, val):
jax.debug.callback(lambda: sleep(0.5))
return val + i
jax.debug.callback(lambda: sleep(0.5))
carry = tqdx.fori_loop(0, 10, body_fun, carry)
return carry, x + 1
def f(xs):
return tqdx.scan(step, 0, xs)
xs = jax.numpy.arange(10)
result, _ = jax.jit(f)(xs)
100%|███████████████████████████████████████████████████████| 10/10 [00:05<00:00, 2.00it/s]
100%|███████████████████████████████████████████████████████| 10/10 [00:05<00:00, 2.00it/s]
40%|████████████████████ | 2/5 [00:11<00:16, 5.51s/it]
70%|██████████████████████████████████████ | 7/10 [00:03<00:05, 2.00it/s]
Installation
pip install tqdx
Metadata
Release files for tqdx 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 |
|---|---|---|---|---|
| tqdx-0.1.5.tar.gz | 3.9 kB | Without provenance | Details for tqdx-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tqdx-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for tqdx-0.1.5-py3-none-any.whl |
Total release size: 10.6 kB
Release files / tqdx-0.1.5.tar.gz
| Download URL | tqdx-0.1.5.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f933040e0baf7e6020f77057c8097afcfa031d4adc8af5d129c78b5b862a4821
|
|
BLAKE2b-256 checksum How to use checksums |
b7f8d1e0ee6e4c906b6195ebdbe4a846f84fbc4e08fb622075a530044cddf3c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Release files / tqdx-0.1.5-py3-none-any.whl
| Download URL | tqdx-0.1.5-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d35c903494659c7c42ffeacda698ef4cd5b2b0953fb516e7a87ee1a25077135
|
|
BLAKE2b-256 checksum How to use checksums |
cd3328063e386ba4d589c0ea71d5a6f4761deeb8db3e29008edeb02875807415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Security for tqdx 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.
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.