Leanpub Header

Skip to main content

JAX Programming: From Fundamentals to Large-Scale Systems

A Comprehensive Guide to Accelerated Python Computing

This book is 100% completeLast updated on 2026-08-02

From your first JAX script to large-scale AI systems, this book shows how to write faster, cleaner Python for modern computing. Learn the ideas behind JAX through practical examples, real projects and clear explanations that help you build everything from scientific simulations to distributed machine learning.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
187
Pages
About

About

About the Book

This book takes you from writing your first JAX program to training large-scale machine learning models on clusters of accelerators. Whether you are a software engineer exploring high-performance computing, a data scientist building modern neural networks, or a researcher pushing the boundaries of scientific simulation, this guide provides the conceptual foundation and practical expertise you need. Through careful explanations, complete working code examples, and real-world case studies, you will learn not only how to use JAX but why it works the way it does and when to reach for each of its powerful tools.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 420 engineers and researchers from Ukraine, Belarus and Russia. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

Contents

Table of Contents

A Comprehensive Guide to Accelerated Python Computing

Chapter 1: Why JAX — The Landscape of Python Numerical Computing

  1. The Problem with Existing Tools
  2. Enter JAX: A New Paradigm
  3. What Makes JAX Different
  4. Who Should Use JAX (and Who Should Not)
  5. How to Read This Book

Chapter 2: Getting Started — Installation, Setup, and Your First Program

  1. Python and Environment Prerequisites
  2. Installing JAX for Different Hardware
  3. Verifying Your Installation
  4. Your First JAX Array Operations
  5. Understanding the JAX REPL Experience

Chapter 3: JAX Arrays — The Foundation of Everything

  1. Creating and Inspecting Arrays
  2. Core Array Operations
  3. Broadcasting and Reshaping
  4. Indexing and Slicing
  5. JAX vs NumPy Arrays: Key Differences
  6. Memory Layout and Device Placement

Chapter 4: JIT Compilation — Making Python Code Fly

  1. What Is JIT Compilation
  2. Using @jit in Practice
  3. Static vs Dynamic Arguments
  4. Tracing and the XLA Backend
  5. Common JIT Pitfalls and Solutions
  6. Performance Measurement and Profiling

Chapter 5: Automatic Differentiation — The Engine of Modern ML

  1. How Automatic Differentiation Works
  2. Computing Gradients with jax.grad
  3. Higher-Order Derivatives
  4. Vector-Jacobian and Jacobian Products
  5. Value-and-Gradient Computation
  6. Common Autodiff Patterns in ML

Chapter 6: Functional Programming — Embracing JAX Philosophy

  1. Why Functional Programming Matters
  2. Immutability and No Side Effects
  3. Pure Functions and Determinism
  4. Closures and Function Composition
  5. Thinking Functionally About Data
  6. Anti-Patterns to Avoid

Chapter 7: Vectorization with vmap — Writing Loops Without Loops

  1. The Batch Processing Problem
  2. How vmap Works
  3. In-Axis and Out-Axis Specification
  4. Nested vmapping
  5. Combining vmap with jit and grad
  6. When Not to Use vmap

Chapter 8: Parallelism — pmap, pjit, and Distributed Computing

  1. Understanding Devices in JAX
  2. Device Arrays and Placement
  3. Using pmap for Single-Host Parallelism
  4. Introduction to pjit
  5. Shardings and Mesh Definition
  6. Multi-Host Distributed Training

Chapter 9: Control Flow — Loops and Conditionals That Compile

  1. Why Python Control Flow Fails Under JIT
  2. Conditional Execution with lax.cond
  3. While Loops with lax.while_loop
  4. For Loops with lax.fori_loop
  5. Scan for Sequential Operations
  6. Choosing the Right Primitive

Chapter 10: PyTrees — Structuring Complex Data

  1. What Is a PyTree
  2. Registering Custom Tree Types
  3. Flattening and Unflattening
  4. Operating on PyTrees
  5. PyTrees in Machine Learning Models
  6. Advanced PyTree Patterns

Chapter 11: Randomness — Reproducible Stochasticity

  1. Why JAX Handles Randomness Differently
  2. The PRNG Key System
  3. Splitting Keys for Parallelism
  4. fold_in for Labeling Keys
  5. Seeding and Reproducibility
  6. Common Randomness Pitfalls

Chapter 12: Custom Gradients — Beyond Automatic Differentiation

  1. When You Need Custom Gradients
  2. Using jax.custom_jvp
  3. Using jax.custom_vjp
  4. Gradient Checking Techniques
  5. Practical Examples from Research

Chapter 13: Neural Networks with Flax and Equinox

  1. Building Blocks of Neural Networks in JAX
  2. Introduction to Flax
  3. Introduction to Equinox
  4. Flax vs Equinox: Choosing a Library
  5. Common Architectures and Patterns

Chapter 14: Optimization — Training at Scale

  1. Optimizers in JAX Ecosystem
  2. Learning Rate Scheduling
  3. Gradient Clipping and Normalization
  4. Mixed Precision Training
  5. Checkpointing and Experiment Tracking
  6. Scaling to Large Models

Chapter 15: Advanced Topics — Scientific Computing, Probabilistic Programming, and RL

  1. JAX for Scientific Computing
  2. Introduction to Probabilistic Programming with NumPyro
  3. Reinforcement Learning with JAX
  4. Differentiable Physics Simulations
  5. Case Study: Training a Large Language Model

Chapter 16: Performance Engineering and Deployment

  1. Profiling JAX Programs
  2. Debugging Techniques and Tools
  3. Memory Optimization Strategies
  4. Interoperability with NumPy and Other Libraries
  5. Model Export and Serving
  6. Production Deployment Considerations

Conclusion: The Future of JAX and Accelerated Computing

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub