You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
brainpy: fix clear_buffer/pmap runtime bugs; drive package-wide mypy to zero
Runtime fixes (surfaced while re-executing the docs notebooks):
- math/environment.py: clear_buffer_memory() now resets JAX's runtime
effect-token registry after deleting live device buffers, so a later
ordered io_callback no longer crashes with "deleted or donated buffer".
- running/jax_multiprocessing.py: jax_parallelize_map now routes through
brainstate.transform.pmap2 (state-aware) instead of raw jax.pmap, and
pulls each chunk's outputs to host before concatenation. This fixes a
TraceContextError when the mapped function builds a stateful model
(random init writes to a State) and a device-placement failure on the
trailing partial chunk sharded on a subset of devices.
Added co-located regression tests for both modules.
Typing:
- Drove `mypy brainpy/` from 1568 errors to 0 across 123 files. These are
annotation-only changes with no runtime behavior change: implicit-Optional
defaults promoted to Optional[T], missing var-annotations added,
Optional values narrowed with asserts/guards, TypeVar-as-attribute
annotations widened, and a small number of targeted `# type: ignore[code]`
where the offending annotation lives in a third-party package. The
curated CI mypy subset remains green.
0 commit comments