Index of every page on this site: llms.txt
All skills
Run it yourself

Write, debug, review, profile, or shard JAX numerical code. Use when the hard part is JAX tracing, autodiff, control flow, PRNGs, compilation, array placement, or runtime performance. Do not impose JAX on a NumPy-only or unrelated GPU task.

Use this Skill: https://skilld.dev/gh/tristanmanchester/agent-skills/jax-development

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesPORTING-PATTERNS.md

≈881 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Porting patterns

Use this file when rewriting NumPy, SciPy, TensorFlow, or PyTorch-style code into idiomatic JAX.

The safe order

  1. make it correct in eager jax.numpy
  2. remove mutation and hidden state
  3. make randomness explicit
  4. add jit
  5. add batching or loop primitives
  6. add sharding only after single-device correctness is clear

Pattern: mutation to functional updates

NumPy / PyTorch style:

x[i] += y

JAX style:

x = x.at[i].add(y)

If the update pattern is large and performance-sensitive, re-think the algorithm rather than translating mutation mechanically.

Pattern: module state to pytrees

Object-heavy code often wants to become a pytree:

  • parameters
  • optimiser state
  • model buffers
  • recurrent carry
  • RNG state

Avoid burying arrays inside objects that are mutated in place.

Pattern: global RNG to explicit keys

Bad:

GLOBAL_KEY = jax.random.key(0)

Better:

def step(state, key, batch):
    key, subkey = jax.random.split(key)
    ...
    return new_state, key

If code is legacy and expects PRNGKey, preserve compatibility, but prefer typed keys in new code.

Pattern: Python data-dependent branch to JAX control flow

Bad:

@jax.jit
def f(x):
    if x.sum() > 0:
        return x
    return -x

Better:

@jax.jit
def f(x):
    return jax.lax.cond(x.sum() > 0, lambda y: y, lambda y: -y, x)

For elementwise choice, prefer jnp.where.

Pattern: long Python loop to scan

Bad:

@jax.jit
def run(state, xs):
    for x in xs:
        state = step(state, x)
    return state

Better:

@jax.jit
def run(state, xs):
    state, ys = jax.lax.scan(step, state, xs)
    return state, ys

This often improves compile time dramatically.

Pattern: per-example Python loop to vmap

Bad:

outs = [f(x) for x in batch]

Better:

outs = jax.vmap(f)(batch)

Pattern: host logging in the hot path

Bad:

@jax.jit
def step(...):
    print(loss)

Better:

  • use jax.debug.print when debugging
  • aggregate metrics and log outside the hot path in production

Pattern: boolean masking that changes shape

Bad inside jit:

x = x[x > 0]

Better:

  • keep the full tensor and mask with where
  • or pad to fixed shape and track a validity mask

Pattern: NumPy helpers inside transformed code

Bad:

np.asarray(x)
float(x)
len(x)

Better:

  • stay in jax.numpy
  • use array ops for shape-aware logic
  • keep Python-only work outside transforms

Pattern: training step design

Strong default:

  • params and opt state are pytrees
  • batch is a pytree
  • key is explicit
  • one value_and_grad call inside one jit
  • metrics are returned as aux
  • donation is considered only after correctness and measurement

Pattern: shape-polymorphic ambitions

Before trying shape polymorphism or export, first ask:

  • can I bucket or pad shapes?
  • can I separate compile-time configuration from runtime values?
  • is the real issue a compile storm caused by accidental shape churn?

Often a simpler fixed-shape design beats a complicated polymorphic one.

Porting checklist

Before calling the port “done”, verify:

  • no hidden mutation
  • no global RNG dependence
  • no host round-trips in the hot path
  • data-dependent loops/branches use JAX primitives
  • tests compare with tolerances rather than exact floating-point equality
  • timings exclude first-call compilation unless compile time is part of the question

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo4 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    The skill provides a suite of JAX development tools. It includes functionality for dynamic loading of local modules for benchmarking and a code scanner that processes user files, which introduces a low risk of dynamic execution and indirect prompt injection.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

  • ZeroLeaks6mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 3323bc9. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Steadyupdated last month
Other metadata
compatibility
Current-release baseline JAX 0.11.1 requires Python >=3.12; wheel/backend support must be checked separately. Diagnostics need Python 3.12+ and the project's JAX environment for runtime probes. Static helpers can run without JAX. Benchmark/probe commands execute trusted project code.
metadata
{
  "version": "3.0.0",
  "reviewed": "2026-09-13",
  "source": "https://github.com/jax-ml/jax/tree/jax-v0.11.1"
}

README badge

README badge for tristanmanchester/agent-skills/jax-development