What problem does it solve? BrainX/BrainState simulation code written with NumPy loops, Python control flow, and per-neuron objects runs slowly and cannot be compiled or vectorized. This Skill systematically finds those inefficiencies and rewrites them into state-aware BrainState transform patterns such as jit, scan, vmap, and grad while preserving state, RNG, and gradient semantics. ## Core Features & Use Cases - Performance Auditing: Builds a hot-path inventory of loops, states, RNG usage, and host synchronization points, then classifies each inefficiency with labeled patterns like loop-T-python, np-in-transform, and rng-reuse. - Transform Rewrites: Converts Python time loops into scan/for_loop, batch and ensemble loops into vmap with explicit state axes, and finite-difference gradients into grad over ParamState. - Validation Gates: Enforces correctness checks covering outputs, final state, shape stability, RNG independence, gradients, warm timing, and memory before a rewrite is considered done. - Use Case: A researcher has a spiking neural network simulation that loops over 10,000 timesteps in Python and takes hours. Use this Skill to audit the code, rewrite the time loop as a jitted scan, vectorize trials with vmap, and verify numerical equivalence with the original. ## Quick Start Ask the agent to audit my BrainState simulation script for performance bottlenecks and rewrite the slow Python loops using BrainState transforms.