Skip to main content

JAX-tqdm

Add a tqdm progress bar to your JAX scans and loops.

Installation

Install with pip:

pip install jax-tqdm

Example usage

in jax.lax.scan

from jax_tqdm import scan_tqdm
from jax import lax
import jax.numpy as jnp

n = 10_000

@scan_tqdm(n)
def step(carry, x):
    return carry + 1, carry + 1

last_number, all_numbers = lax.scan(step, 0, jnp.arange(n))

in jax.lax.fori_loop

from jax_tqdm import loop_tqdm
from jax import lax

n = 10_000

@loop_tqdm(n)
def step(i, val):
    return val + 1

last_number = lax.fori_loop(0, n, step, 0)

Print Rate

By default, the progress bar is updated 20 times over the course of the scan/loop (for performance purposes, see below). This update rate can be manually controlled with the print_rate keyword argument. For example:

from jax_tqdm import scan_tqdm
from jax import lax
import jax.numpy as jnp

n = 10_000

@scan_tqdm(n, print_rate=2)
def step(carry, x):
    return carry + 1, carry + 1

last_number, all_numbers = lax.scan(step, 0, jnp.arange(n))

will update every other step.

Why JAX-tqdm?

JAX functions are pure, so side effects such as printing progress when running scans and loops are not allowed. However, the host_callback module has primitives for calling Python functions on the host from JAX code. This can be used to update a Python tqdm progress bar regularly during the computation. JAX-tqdm implements this for JAX scans and loops and is used by simply adding a decorator to the body of your update function.

Note that as the tqdm progress bar is only updated 20 times during the scan or loop, there is no performance penalty.

The code is explained in more detail in this blog post.

Developers

Dependencies can be installed with poetry by running

poetry install

Pre-Commit Hooks

Pre commit hooks can be installed by running

pre-commit install

Pre-commit checks can then be run using

task lint

Tests

Tests can be run with

task test

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jax_tqdm-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jax_tqdm-0.1.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file jax_tqdm-0.1.1.tar.gz.

File metadata

  • Download URL: jax_tqdm-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.15.0-60-generic

File hashes

Hashes for jax_tqdm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4ae95a1920140e28467e9b187e2ca8c11a3d385e2a0d6bb608ecb62e2ad36c78
MD5 48a7bc842fe4ffcfc57b8837fb592eeb
BLAKE2b-256 83fe93094f94a031ac9281b8f54c0e65fc3eb47cb75effde2e790c9c2b09a0ba

See more details on using hashes here.

File details

Details for the file jax_tqdm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: jax_tqdm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.15.0-60-generic

File hashes

Hashes for jax_tqdm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f3ca93edd82839c35f745b58005f602a5177f9ea170a4cd6d42b362e01b3942
MD5 ab2b1cca834b9a7f5d2bd9f0a7f5c0ed
BLAKE2b-256 3e5c0f24d92fb265f8b7b2230d469e2f9401cc071ebdba1760b312ccbe4d3728

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

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