Skip to main content

Execute runtime assertions, indexing checks, and more if jax code is not traced.

Project description

https://github.com/tillahoffmann/ifnt/actions/workflows/build.yml/badge.svg https://readthedocs.org/projects/ifnt/badge/?version=latest https://img.shields.io/pypi/v/jax-ifnt

Execute runtime assertions, indexing checks, and more if jax code is not traced.

Overview

ifnt comprises three core modules, ifnt.util with utility functions, ifnt.testing for runtime assertions, and ifnt.random for stateful random number generation.

>>> import ifnt
>>> import jax
>>> from jax import numpy as jnp
>>>
>>> def safe_log(x):
...     ifnt.testing.assert_array_less(0, x)
...     return jnp.log(x)
>>>
>>> safe_log(-1)
Traceback (most recent call last):
...
AssertionError: Arrays are not strictly ordered `x < y`
<BLANKLINE>
Mismatched elements: 1 / 1 (100%)
Max absolute difference among violations: 1
Max relative difference among violations: 1.
x: array(0)
y: array(-1)
>>>
>>> jax.jit(safe_log)(-1)
Array(nan, dtype=float32, weak_type=True)

Installation

$ pip install jax-ifnt

Relationship to chex

DeepMind’s chex provides similar, often complementary, assertions. While chex requires runtime assertions to be “functionalized” with chex.chexify, ifnt will skip assertions in traced code. This facilitates, for example, verifying that indices are not out of bounds.

Project details


Download files

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

Source Distribution

jax_ifnt-0.1.11.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

jax_ifnt-0.1.11-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file jax_ifnt-0.1.11.tar.gz.

File metadata

  • Download URL: jax_ifnt-0.1.11.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for jax_ifnt-0.1.11.tar.gz
Algorithm Hash digest
SHA256 aff7757360411e7c68b3a9954ce729ff7a50ed3c440e4f90b729a1c73c63b344
MD5 d7d2a77fae4d8ceb188f323aab2fc5f8
BLAKE2b-256 01d27d1e8bbb7e635dfca0f30dd28a5da66cc292e6dfd5129afa8c275efad9d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for jax_ifnt-0.1.11.tar.gz:

Publisher: publish.yml on tillahoffmann/jax-ifnt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jax_ifnt-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: jax_ifnt-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for jax_ifnt-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 1195acd83ec8cfd7f8c788fe0807108e6331cdd8c5a21af88af2f6ed19cf8599
MD5 299a3edcc8b7ec4ebe8d37064f4f2da4
BLAKE2b-256 e0228df1e587909626f838e863e0cfc981ac005d2e50a0cd605666cc466c7de5

See more details on using hashes here.

Provenance

The following attestation bundles were made for jax_ifnt-0.1.11-py3-none-any.whl:

Publisher: publish.yml on tillahoffmann/jax-ifnt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page