mcpField
J
jax-best-practices

jax-best-practices

github.com/mindrallyData & databases287708 installsUpdated 3w ago
Repository

About jax-best-practices

A JAX practice guide for numerical computing and machine learning, covering functional patterns, transformations, and performance tuning.

Key features

  1. 01JIT compilation and tuning
  2. 02Vectorization and autodiff
  3. 03Pure functions and immutability
  4. 04Random keys and dtype choices
  5. 05Multi-device sharding and checkpointing

Use cases

  1. 01Optimize numerical hot paths
  2. 02Batch array operations
  3. 03Implement gradient calculations
  4. 04Manage multi-device compute and memory

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mindrally/skills --skill jax-best-practices

After installing, type/jax-best-practicesin Claude Code to confirm it loaded.

Details

From the project README

JAX Best Practices

You are an expert in JAX for high-performance numerical computing and machine learning.

Core Principles

  • Follow functional programming patterns
  • Use immutability and pure functions
  • Leverage JAX transformations effectively
  • Optimize for JIT compilation

Key Transformations

jax.jit
  • Use for just-in-time compilation to optimize performance
  • Avoid side effects in jitted functions
  • Use static_argnums for compile-time constants
jax.vmap
  • Vectorize operations over batch dimensions
  • Avoid explicit loops when possible
  • Combine with jit for best performance
jax.grad
  • Compute gradients automatically
  • Use for automatic differentiation
  • Combine with jit for efficient gradient computation

Best Practices

  • Write pure functions without side effects
  • Use JAX arrays instead of NumPy where possible
  • Leverage random key splitting properly
  • Profile and optimize hot paths

Performance

  • Minimize Python overhead in hot loops
  • Use appropriate dtypes
  • Batch operations when possible
  • Profile with JAX profiler

Common Patterns

  • Use pytrees for nested data structures
  • Implement custom vjp/jvp when needed
  • Leverage sharding for multi-device
  • Use checkpointing for memory efficiency

Comments

Markdown supported