Abstract
Biophysical neuron models provide insights into cellular mechanisms underlying neural computations. A central challenge has been to identify parameters of detailed biophysical models such that they match physiological measurements or perform computational tasks. Here we describe a framework for simulating biophysical models in neuroscience—JAXLEY—which addresses this challenge. By making use of automatic differentiation and GPU acceleration, JAXLEY enables optimizing large-scale biophysical models with gradient descent. JAXLEY can learn biophysical neuron models to match voltage or two-photon calcium recordings, sometimes orders of magnitude more efficiently than previous methods. JAXLEY also makes it possible to train biophysical neuron models to perform computational tasks. We train a recurrent neural network to perform working memory tasks, and a network of morphologically detailed neurons with 100,000 parameters to solve a computer vision task. JAXLEY improves the ability to build large-scale data- or task-constrained biophysical models, creating opportunities for investigating the mechanisms underlying neural computations across multiple scales.
Introduction
In neuroscience, a persistent gap exists between artificial neural networks (ANNs) and biophysical models. While ANNs are easily optimized via gradient descent, they lack biological realism. Conversely, biophysical models—which simulate ion channels and complex morphologies—are biologically grounded but notoriously difficult to optimize. Traditionally, fitting these models required gradient-free "black-box" methods like genetic algorithms, which scale poorly as parameter counts increase. Furthermore, standard simulators like NEURON are primarily CPU-based and lack the automatic differentiation (backpropagation) necessary for modern machine learning workflows.
The Jaxley Framework
Jaxley is an open-source Python toolbox built on the JAX framework that makes detailed biophysical simulations fully differentiable. It bridges the gap between biological realism and computational efficiency through several key innovations:
- Differentiable ODE Solvers: Jaxley implements implicit Euler solvers—the gold standard for stiff neural equations—allowing JAX to compute gradients of simulation outputs with respect to any physical parameter, such as ion channel conductance or synaptic weights.
- GPU/TPU Acceleration: Leveraging JAX allows for the parallelization of thousands of simulations across multiple GPUs, providing massive speedups.
- Memory Management: To handle backpropagation through time (BPTT) in complex systems, Jaxley employs multilevel checkpointing, recomputing intermediate states to save memory.
- Robust Optimization: Specialized training techniques, including parameter transformations (e.g., inverse sigmoid), ensure that biological parameters remain within physically realistic bounds during gradient descent.
Key Results and Performance
Jaxley was benchmarked across diverse tasks, including fitting models to real patch-clamp recordings from the Allen Cell Types Database and training networks on MNIST.
Scaling and Efficiency
The introduction of gradients is a game-changer for high-dimensional models. For a model with 1,390 parameters, gradient descent converged in approximately 100 iterations, whereas genetic algorithms remained significantly less accurate even after 500 iterations. Jaxley can compute gradients for a network with 3.2 million parameters in just 144 seconds—a task estimated to take over two years using traditional non-differentiable methods.
Task-Driven Biophysical Modeling
Jaxley enables "task-driven" modeling, where biophysical networks are trained to perform specific computations. On the MNIST classification task, a biophysical network with 100,000 parameters achieved 94.2% accuracy, demonstrating that biological nonlinearities like spikes can be effectively harnessed for complex computation.
Discussion and Future Directions
While Jaxley represents a significant leap forward, challenges remain. Backpropagating through very long simulations (minutes) is difficult due to vanishing gradients. Additionally, the non-convex loss landscape of biophysical models can lead to local minima, necessitating careful initialization. Future work will focus on developing more robust differentiable proxies for discrete neural events like spikes, further enhancing the ability to build large-scale, data-constrained biophysical models.
Source: Deistler, M., et al. (2025). Jaxley: differentiable simulation enables large-scale training of detailed biophysical models of neural dynamics. Nature Methods.
Summary updated