AI GitHub
JAX for transforming numerical programs
Compose transformations for differentiation, vectorization and compilation around array functions.
Key Takeaways
- JAX transformations work on functions and array inputs.
- Use a supported CPU or accelerator installation and keep function inputs explicit.
- Apply differentiation, batching and compilation to one small function.
- Functions under transformation need compatible control flow and explicit state.
How it works
JAX transformations work on functions and array inputs. Compilation and vectorization can change how a numerical experiment runs without rewriting the model as a separate kernel.
What you need
Use a supported CPU or accelerator installation and keep function inputs explicit. Begin with a pure array calculation before adding model state or random values.
What to try first
Apply differentiation, batching and compilation to one small function. Separate compilation time from steady-state runtime and force completion when timing accelerator work.
Run the same compiled function on two batch shapes. Record when compilation happens again so a new shape is counted separately from a slow numerical kernel.
Where to look for failures
Functions under transformation need compatible control flow and explicit state. Changes in shapes or static arguments can trigger recompilation.
Related Franklin pages
Keep the task and input representation fixed as you move between a model library and tensor frameworks. Separate compile or initialization time from subsequent execution.
- Load supported pretrained models and connect tokenizers and processors to inference or training code. Transformers for using published model architectures
- Build and train neural networks with tensors, automatic differentiation and modules. PyTorch for tensor programs and neural-network training
For the role of multilayer networks and how they learn, see Franklin’s glossary. Deep learning
Project documentation
Try it for your workflow
Explore the project’s documentation for setup and usage, or save this page to a collection for later.
Read the project documentation ↗