Skip to content

Releases: brainpy/BrainPy

Version 2.7.1

13 Oct 14:40
dfb6a69

Choose a tag to compare

This is a feature release that introduces new neuron and synapse models in the state-based API (brainpy.state) and enhances the Dynamics base class with improved input handling.

Major Changes

New Neuron Models (brainpy.state)

  • LIF (Leaky Integrate-and-Fire) Variants: Added comprehensive set of LIF neuron models

    • LIF: Basic LIF neuron with exponential synaptic input
    • LifRef: LIF with refractory period
    • ExpIF: Exponential Integrate-and-Fire neuron
    • ExpIFRef: ExpIF with refractory period
    • AdExIF: Adaptive Exponential Integrate-and-Fire neuron
    • AdExIFRef: AdExIF with refractory period
    • QuaIF: Quadratic Integrate-and-Fire neuron
    • QuaIFRef: QuaIF with refractory period
    • AdQuaIF: Adaptive Quadratic Integrate-and-Fire neuron
    • AdQuaIFRef: AdQuaIF with refractory period
    • GifRef: Generalized Integrate-and-Fire with refractory period
  • Izhikevich Neuron Models: Added new Izhikevich neuron implementations

    • Izhikevich: Basic Izhikevich neuron model
    • IzhikevichRef: Izhikevich with refractory period
  • Hodgkin-Huxley Model: Added classic biophysical neuron model

    • HH: Classic Hodgkin-Huxley model with Na+ and K+ channels

New Synapse Models (brainpy.state)

  • BioNMDA: Biological NMDA receptor with second-order kinetics
    • Implements two-state cascade dynamics (x and g variables)
    • Slower rise time compared to AMPA (biologically realistic)
    • Comprehensive documentation with mathematical formulation

Features

Model Implementation

  • All new models use the brainstate ecosystem (HiddenState, ShortTermState, LongTermState)
  • Proper unit support with brainunit integration
  • Exponential Euler integration for numerical stability
  • Batch processing support across all models
  • Consistent API design following BrainPy v2.7+ architecture

Dynamics Class Enhancements

  • Enhanced input handling capabilities in the Dynamics base class
  • Added new properties for better state management
  • Improved integration with brainstate framework
  • Refactored to use public methods instead of private counterparts for clarity

Documentation

  • Added comprehensive Examples sections to all neuron classes in _lif.py
  • Each example includes:
    • Import statements for required modules
    • Basic usage with parameter specifications
    • State initialization examples
    • Update and spike generation examples
    • Network integration with brainstate.nn.Sequential
    • Notes highlighting key features
  • All 13 neuron classes in _lif.py now have complete documentation
  • Simplified documentation paths by removing 'core-concepts' and 'quickstart' prefixes in index.rst

Bug Fixes

  • Fixed import paths in _base.py: changed references from brainstate to brainpy for consistency (057b872)
  • Fixed test suite issues (95ec203)
  • Fixed test suite for proper unit handling in synapse models

Code Quality

  • Refactored module assignments to brainpy.state for consistency across files (06b2bf4)
  • Refactored method calls in _base.py: replaced private methods with public counterparts (210426a)

Testing

  • Added comprehensive test suites for all new neuron models
  • Added AMPA and GABAa synapse tests
  • Added tests for Izhikevich neuron variants
  • Added tests for Hodgkin-Huxley model
  • All tests passing with proper unit handling

Files Modified

  • brainpy/__init__.py: Updated version to 2.7.1
  • brainpy/state/_base.py: Enhanced Dynamics class with improved input handling (447 lines added)
  • brainpy/state/_lif.py: Added extensive LIF neuron variants (1862 lines total)
  • brainpy/state/_izhikevich.py: New file with Izhikevich models (407 lines)
  • brainpy/state/_hh.py: New file with Hodgkin-Huxley model (666 lines)
  • brainpy/state/_synapse.py: Added BioNMDA model (158 lines)
  • brainpy/state/_projection.py: Updated for consistency (43 lines modified)
  • brainpy/state/__init__.py: Updated exports for new models
  • Test files added: _lif_test.py, _izhikevich_test.py, _hh_test.py, _synapse_test.py, _base_test.py
  • Documentation updates in docs_state/index.rst

Removed

  • Removed outdated documentation notebooks from docs_state/:
    • checkpointing-en.ipynb and checkpointing-zh.ipynb
    • snn_simulation-en.ipynb and snn_simulation-zh.ipynb
    • snn_training-en.ipynb and snn_training-zh.ipynb

Notes

  • This release significantly expands the brainpy.state module with biologically realistic neuron and synapse models
  • All new models are fully compatible with the brainstate ecosystem
  • Enhanced documentation provides clear usage examples for all models
  • The Dynamics class refactoring improves the foundation for future state-based model development

What's Changed

New Contributors

Full Changelog: V2.7.0...V2.7.1

Version 2.7.0

10 Oct 09:11
4a32348

Choose a tag to compare

Release Date: October 2025

This is a maintenance release focusing on documentation improvements and version management.

Major Changes

Version Management

  • Downgraded version numbering from 3.x series back to 2.7.0 to maintain consistency with the stable 2.x API
  • This release represents the continuation of the BrainPy 2.x series

Documentation

Documentation Structure

  • Streamlined table of contents in documentation
  • Added new sections for Core Concepts and Quickstart guides
  • Consolidated documentation sections for better clarity
  • Updated default build version to v2 in configuration
  • Improved documentation build process with better logging

Documentation Updates

  • Refactored index.rst for better organization
  • Updated documentation to reflect current module structure
  • Enhanced documentation build scripts

Testing

Test Cleanup

  • Removed redundant test for abstract Neuron class to avoid conflicts

Notes

  • This release maintains the stable BrainPy 2.x API
  • For users of BrainPy 2.x, no code changes are required
  • Documentation has been improved for better user experience

What's Changed

  • Rollback (#789)
  • Update documentation (#790, #791)
  • Update changelog for version 3.0.1 (#792)
  • Downgrade version to 2.7.0 in init.py (#792)
  • Documentation structure improvements

Full Changelog: V2.6.0...V2.7.0

Version 2.6.0

24 Mar 02:30
3e5dcbf

Choose a tag to compare

New Features

This release provides several new features, including:

  • MLIR registered operator customization interface in brainpy.math.XLACustomOp.
  • Operator customization with CuPy JIT interface.
  • Bug fixes.

What's Changed

New Contributors

Full Changelog: V2.5.0...V2.6.0

Version 2.5.0

01 Feb 07:18
6b6a62f

Choose a tag to compare

This release contains many new features and fixes. It is the first release with a mature solution for Brain Dynamics Operator Customization on both CPU and GPU platforms.

New Features

  1. Add synapse projection with Delta synapse models through brainpy.dyn.HalfProjDelta and brainpy.dyn.FullProjDelta.
  2. Add brainpy.math.exprel, and change the code in the corresponding HH neuron models to improve numerical computation accuracy. These changes can significantly improve the numerical integration accuracy of HH-like models under x32 computation.
  3. Add brainpy.reset_level() decorator so that the state resetting order can be customized by users.
  4. Add brainpy.math.ein_rearrange, brainpy.math.ein_reduce, and brainpy.math.ein_repeat functions
  5. Add brainpy.math.scan transformation.
  6. Rebase all customized operators using Taichi JIT compiler. On the CPU platform, the speed performance can be boosted ten to hundred times. On the GPU platforms, the flexibility can be greatly improved.
  7. Many bug fixes.
  8. A new version of brainpylib>=0.2.4 has been released, supporting operator customization through the Taichi compiler. The supported backends include Linux, Windows, MacOS Intel, and MacOS M1 platforms. Tutorials please see https://brainpy.readthedocs.io/en/latest/tutorial_advanced/operator_custom_with_taichi.html

What's Changed

New Contributors

Full Changelog: V2.4.6...V2.5.0

Version 2.4.6

11 Nov 02:43
92cdc40

Choose a tag to compare

This release contains more than 130 commit updates, and has provided several new features.

New Features

1. surrogate gradient functions are more transparent.

New instances can be used to compute the surrogate gradients. For example:

import brainpy.math as bm
fun = bm.surrogate.Sigmoid()

# forward function
spk = fun(membrane_potential)

# backward function
dV = fun.surrogate_grad(1., membrane_potential)

# surrogate forward function
surro_spk = fun.surrogate_fun(membrane_potential)

2. Add brainpy.math.eval_shape for evaluating the all dynamical variables used in the target function.

This function is similar to jax.eval_shape which has no FLOPs, while it can extract all variables used in the target function. For example:

net = ...  # any dynamical system
inputs = ...  # inputs to the dynamical system
variables, outputs= bm.eval_shape(net, inputs)  
# "variables" are all variables used in the target "net"

In future, this function will be used everywhere to transform all jax transformations into brainpy's oo transformations.

3. Generalize tools and interfaces for state managements.

For a single object:

  • The .reset_state() defines the state resetting of all local variables in this node.
  • The .load_state() defines the state loading from external disks (typically, a dict is passed into this .load_state() function).
  • The .save_state() defines the state saving to external disks (typically, the .save_state() function generates a dict containing all variable values).

Here is an example to define a full class of brainpy.DynamicalSystem.

import brainpy as bp

class YouDynSys(bp.DynamicalSystem):
   def __init__(self, ):  # define parameters
      self.par1 = ....
      self.num = ...

  def reset_state(self, batch_or_mode=None):  # define variables
     self.a = bp.init.variable_(bm.zeros, (self.num,), batch_or_mode)

  def load_state(self, state_dict):  # load states from an external dict
     self.a.value = bm.as_jax(state_dict['a'])

  def save_state(self):  # save states as an external dict
     return {'a': self.a.value}

For a complex network model, brainpy provide unified state managment interface for initializing, saving, and loading states.

  • The brainpy.reset_state() defines the state resetting of all variables in this node and its children nodes.
  • The brainpy.load_state() defines the state loading from external disks of all variables in the node and its children.
  • The brainpy.save_state() defines the state saving to external disks of all variables in the node and its children.
  • The brainpy.clear_input() defines the clearing of all input variables in the node and its children.

4. Unified brain simulation and brain-inspired computing interface through automatic membrane scaling.

The same model used in brain simulation can be easily transformed into the one used for brain-inspired computing for training. For example,

class EINet(bp.DynSysGroup):
  def __init__(self):
    super().__init__()
    self.N = bp.dyn.LifRefLTC(4000, V_rest=-60., V_th=-50., V_reset=-60., tau=20., tau_ref=5.,
                              V_initializer=bp.init.Normal(-55., 2.))
    self.delay = bp.VarDelay(self.N.spike, entries={'I': None})
    self.E = bp.dyn.ProjAlignPost1(
      comm=bp.dnn.EventCSRLinear(bp.conn.FixedProb(0.02, pre=3200, post=4000), weight=bp.init.Normal(0.6, 0.01)),
      syn=bp.dyn.Expon(size=4000, tau=5.),
      out=bp.dyn.COBA(E=0.),
      post=self.N
    )
    self.I = bp.dyn.ProjAlignPost1(
      comm=bp.dnn.EventCSRLinear(bp.conn.FixedProb(0.02, pre=800, post=4000), weight=bp.init.Normal(6.7, 0.01)),
      syn=bp.dyn.Expon(size=4000, tau=10.),
      out=bp.dyn.COBA(E=-80.),
      post=self.N
    )

  def update(self, input):
    spk = self.delay.at('I')
    self.E(spk[:3200])
    self.I(spk[3200:])
    self.delay(self.N(input))
    return self.N.spike.value


# used for brain simulation
with bm.environment(mode=bm.nonbatching_mode):
  net = EINet()


# used for brain-inspired computing
# define the `membrane_scaling` parameter
with bm.environment(mode=bm.TrainingMode(128), membrane_scaling=bm.Scaling.transform([-60., -50.])):
  net = EINet()

5. New apis for operator customization on CPU and GPU devices through brainpy.math.XLACustomOp.

Starting from this release, brainpy introduces Taichi for operator customization. Now, users can write CPU and GPU operators through numba and taichi syntax on CPU device, and taichi syntax on GPu device. Particularly, to define an operator, user can use:

import numba as nb
import taichi as ti
import numpy as np
import jax
import brainpy.math as bm


@nb.njit
def numba_cpu_fun(a, b, out_a, out_b):
  out_a[:] = a
  out_b[:] = b


@ti.kernel
def taichi_gpu_fun(a, b, out_a, out_b):
  for i in range(a.size):
    out_a[i] = a[i]
  for i in range(b.size):
    out_b[i] = b[i]


prim = bm.XLACustomOp(cpu_kernel=numba_cpu_fun, gpu_kernel=taichi_gpu_fun)
a2, b2 = prim(np.random.random(1000), np.random.random(1000),
              outs=[jax.ShapeDtypeStruct(1000, dtype=np.float32),
                    jax.ShapeDtypeStruct(1000, dtype=np.float32)])

6. Generalized STDP models which are compatible with diverse synapse models.

See https://github.com/brainpy/BrainPy/blob/master/brainpy/_src/dyn/projections/tests/test_STDP.py

What's Changed

New Contributors

Full Changelog: V2.4.5...V2.4.6

Version 2.4.5

18 Sep 07:21

Choose a tag to compare

New Features

  • A new version of brainpylib==0.1.10 has been released. In this release, we have fixed some bugs of brainpy dedicated GPU operators. Users can freely use them in any application.
  • Correspondingly, dedicated operators in brainpy.math have been refined.
  • .tracing_variable() has been created to support tracing Variables during computations and compilations. Example usage please see #472
  • Add a new random API for creating multiple random keys: brainpy.math.random.split_keys().
  • Fix bugs, including
    • brainpy.dnn.AllToAll module
    • RandomState.
    • brainpy.math.cond and brainpy.math.while_loop when variables are used in both branches

What's Changed

New Contributors

Full Changelog: V2.4.4...V2.4.5

Version 2.4.4

26 Aug 05:22

Choose a tag to compare

This release has fixed several bugs and updated the sustainable documentation.

What's Changed

New Contributors

Full Changelog: V2.4.3...V2.4.4

Version 2.4.3

23 Jul 02:33
53ed70b

Choose a tag to compare

This release has standardized the modeling of DNN and SNN models by two intercorrelated packages: brainpy.dnn and brainpy.dyn.

Overall, the modeling of brain dynamics in this release has the following advantages:

  • the automatic merging of the duplicate synapses, keeping the minimal device memory
  • easy model and data parallelization across multiple devices
  • easy integration with artificial neural networks
  • a new abstraction that decouples dynamics from communication
  • the unified DynamicalSystem interface

New Features

  1. Support to define ion channel models which rely on multiple ions. For example,
class HH(bp.dyn.CondNeuGroup):
   def __init__(self, size):
      super().__init__(size)
      self.k = bp.dyn.PotassiumFixed(size)
      self.ca = bp.dyn.CalciumFirstOrder(size)

      self.kca = bp.dyn.mix_ions(self.k, self.ca)  # Ion that mixing Potassium and Calcium
      self.kca.add_elem(ahp=bp.dyn.IAHP_De1994v2(size))  # channel that relies on both Potassium and Calcium
  1. New style .update() function in brainpy.DynamicalSystem which resolves all compatible issues. Starting from this version, all update() no longer needs to receive a global shared argument such as tdi.
class YourDynSys(bp.DynamicalSystem):
  def update(self, x):
    t = bp.share['t']
    dt = bp.share['dt']
    i = bp.share['i']
    ...
  1. Optimize the connection-building process when using brainpy.conn.ScaleFreeBA, brainpy.conn.ScaleFreeBADual, brainpy.conn.PowerLaw

  2. New dual exponential model brainpy.dyn.DualExponV2 can be aligned with post dimension.

  3. More synaptic projection abstractions, including

    • brainpy.dyn.VanillaProj
    • brainpy.dyn.ProjAlignPostMg1
    • brainpy.dyn.ProjAlignPostMg2
    • brainpy.dyn.ProjAlignPost1
    • brainpy.dyn.ProjAlignPost2
    • brainpy.dyn.ProjAlignPreMg1
    • brainpy.dyn.ProjAlignPreMg2
  4. Fix compatible issues, fix unexpected bugs, and improve the model tests.

What's Changed

New Contributors

Full Changelog: V2.4.2...V2.4.3

Version 2.4.2

27 Jun 09:00
9c43971

Choose a tag to compare

We are very excited to release this new version of BrainPy V2.4.2. In this new update, we cover several exciting features:

New Features

  • Reorganize the model to decouple dynamics and communication.
  • Add brainpy.dyn for dynamics models and brainpy.dnn for the ANN layer and connection structures.
  • Supplement many docs for dedicated operators and common bugs of BrainPy.
  • Fix many bugs.

What's Changed

New Contributors

Full Changelog: V2.4.1...V2.4.2

Version 2.4.1

24 May 10:03
fc6d657

Choose a tag to compare

New Features

  1. [math] Support the error report when modifying a brainpy.math.Array during compilation
  2. [math] add brainpy.math.event, brainpy.math.sparse and brainpy.math.jitconn module, needs brainpylib >= 0.1.9
  3. [interoperation] add apis and docs for brainpy.layers.FromFlax and brainpy.layer.ToFlaxRNNCell
  4. [fix] Bug fixes:
    • fix WilsonCowan bug
    • fix brainpy.connect.FixedProb bug
    • fix analysis jit bug

What's Changed

New Contributors

Full Changelog: V2.4.0...V2.4.1