Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.6%) to scientific vocabulary
Repository
jax + rust => a memory safe DL framework
Basic Info
- Host: GitHub
- Owner: viraatdas
- License: apache-2.0
- Language: Python
- Default Branch: main
- Size: 16.5 MB
Statistics
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
RAX: A Safe JAX Frontend
RAX is a compiler-like frontend for JAX that adds shape/type safety and memory correctness guarantees to your JAX code, without requiring any code changes beyond adding type annotations.
Installation
From GitHub
bash
pip install git+https://github.com/viraatdas/rax.git
For Development
bash
git clone -b rax https://github.com/viraatdas/rax.git
cd rax
pip install -e .
Quick Start
- Annotate your functions with jaxtyping:
```python
my_model.py
import jax.numpy as jnp from jaxtyping import Float, Array
def dense(x: Float[Array, "batch 128"], w: Float[Array, "128 64"]) -> Float[Array, "batch 64"]: return jnp.dot(x, w)
def model(x: Float[Array, "batch 128"]) -> Float[Array, "batch 64"]: w = jnp.ones((128, 64)) return dense(x, w)
Run your model
x = jnp.ones((32, 128)) output = model(x) print(f"Output shape: {output.shape}") ```
- Run with RAX:
bash
rax run my_model.py
What RAX Does
When you run rax run script.py, RAX:
- Scans for user-defined functions in your script
- Validates type annotations - Requires all functions to have jaxtyping annotations
- Enforces shapes at runtime via beartype integration
- Traces functions symbolically using
jax.make_jaxprto catch shape/math errors - JIT-compiles by default for performance
- Monkeypatches JAX operations to validate shapes
Safety Guarantees
| Guarantee | Mechanism |
|-----------|-----------|
| Type & shape correctness | @beartype + jaxtyping |
| Math logic validation | jax.make_jaxpr(fn)(*args) |
| Compilation before execution | jax.jit (automatic) |
| Early failure on errors | Compile-time trace validation |
| Memory predictability | Enforced size-consistent ops |
Examples
Valid Code
```python
This runs successfully
def add(x: Float[Array, "10"], y: Float[Array, "10"]) -> Float[Array, "10"]: return x + y
result = add(jnp.ones(10), jnp.ones(10)) ```
Invalid Code (Caught by RAX)
```python
This fails at validation time
def bad_dot(x: Float[Array, "32 100"], w: Float[Array, "128 64"]) -> Float[Array, "32 64"]: return jnp.dot(x, w) # Shape mismatch!
RAX output:
[RAX] Shape/dimension error in function 'bad_dot':
dot shape mismatch: (32, 100) · (128, 64)
```
CLI Options
```bash rax run script.py [options]
Options: --no-jit Disable automatic JIT compilation --no-monkeypatch Disable JAX operation monkeypatching --verbose Enable verbose output ```
Requirements
- JAX code must use jaxtyping annotations for all function parameters and returns
- No other code changes needed - RAX is fully compatible with existing JAX code
Future Extensions
rax compile- Validate without executionrax trace- Output compiled JAXPR for debuggingrax lint- Detect missing annotationsrax export- Export to XLA/MLIR format
Owner
- Name: Viraat Das
- Login: viraatdas
- Kind: user
- Twitter: therealviraat
- Repositories: 14
- Profile: https://github.com/viraatdas
SDE @ Amazon | Purdue CS Alum Machine and deep learning enthusiast
GitHub Events
Total
- Watch event: 1
- Push event: 1
- Create event: 2
Last Year
- Watch event: 1
- Push event: 1
- Create event: 2
Dependencies
- absl-py *
- cmake *
- flatbuffers *
- ipython >=8.8.0
- matplotlib *
- myst-nb >=1.0.0
- numpy *
- pooch *
- pydata-sphinx-theme ==0.14.4
- pytest *
- pytest-xdist *
- rich *
- scikit-learn *
- snowballstemmer <3.0.0
- sphinx >=7.3.2,<8.0
- sphinx-book-theme ==1.1.1
- sphinx-copybutton >=0.5.0
- sphinx-design *
- sphinx-remove-toctrees *
- sphinxext-rediraffe *
- jax *
- flax *
- tensorflow_datasets *
- tensorflow_hub *
- ml_dtypes >=0.5.0
- numpy >=1.26
- scipy >=1.12
- beartype >=0.15.0
- jax >=0.4.0
- jaxlib >=0.4.0
- jaxtyping >=0.2.0
- numpy >=1.20.0