Repository navigation
release: v0.6.0 - #247
release: v0.6.0#247
Conversation
Reviewer's GuideThis release-only PR publishes brainstate 0.6.0 by updating version and packaging metadata, raising the supported Python floor to 3.12, aligning the PyPI workflow and type-checking configuration, and finalizing comprehensive release notes for the representation redesign, correctness fixes, JAX compatibility, upgrade impacts, and validation results. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pyproject.toml" line_range="28" />
<code_context>
description = "A State-based Transformation System for Brain Modeling."
readme = 'README.md'
-requires-python = '>=3.11'
+requires-python = '>=3.12'
authors = [{ name = 'BrainState Developers', email = 'chao.brain@qq.com' }]
classifiers = [
</code_context>
<issue_to_address>
**Documented Python installs fail**
When a user follows the installation guide on Python 3.10 or 3.11, `pip` enforces `requires-python = '>=3.12'` and rejects installation, so users following the installation guide on Python 3.10 or 3.11 cannot install this release.
Update the installation guide to state that Python 3.12 or newer is required.
</issue_to_address>| description = "A State-based Transformation System for Brain Modeling." | ||
| readme = 'README.md' | ||
| requires-python = '>=3.11' | ||
| requires-python = '>=3.12' |
There was a problem hiding this comment.
🟡 Medium · Documented Python installs fail
When a user follows the installation guide on Python 3.10 or 3.11, pip enforces requires-python = '>=3.12' and rejects installation, so users following the installation guide on Python 3.10 or 3.11 cannot install this release.
Update the installation guide to state that Python 3.12 or newer is required.
Prompt for AI agents
In `pyproject.toml` at line 28:
**Documented Python installs fail**
When a user follows the installation guide on Python 3.10 or 3.11, `pip` enforces `requires-python = '>=3.12'` and rejects installation, so users following the installation guide on Python 3.10 or 3.11 cannot install this release.
Update the installation guide to state that Python 3.12 or newer is required.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Release brainstate 0.6.0.
Changes in this PR: the version goes to
0.6.0, the minimum Python version goes to 3.12, the Python 3.15 classifier is added, and the 0.6.0 changelog is finalized.After merging, create the
v0.6.0GitHub release. That triggersPublish.yml, which uploads to PyPI.brainstate 0.6.0 replaces the pretty representation of modules and states, fixes about thirty correctness bugs found in an audit of the codebase, and supports JAX 0.9 through 0.12. The minimum supported versions are now Python 3.12 and JAX 0.9.0. A few of the fixes change results that existing code may depend on; read Upgrade notes before upgrading.
Highlights
reprforModule,Node,Stateand thebrainstate.utilcontainers. It summarises arrays by shape and dtype and adds a parameter-count footer, and can be configured with the newbrainstate.util.repr_options()(feat: redesign pretty repr for Node, Module, State and friends #246).Statehooks,environ,random,nnandtransform(fix: High/Medium audit bugs across state, environ, random, nn, transform #244).import brainstaterespectsjax_enable_x64: importing the package no longer turns float64 off (Respect jax_enable_x64 when brainstate is imported #242).Upgrade notes
Most code needs no changes. Check the following if they apply to you:
jax>=0.9.0(was0.8.0).brainstate.random.pareto()[0, inf), the same asnumpy.random.pareto. Earlier samples were 1 too large.nn.MaxPool*(return_indices=True)x.ravel()[indices]). Pass them toMaxUnpool*.brainstate.environcontext()overrides are still per thread.environ.context(...)inside each thread.jax_enable_x64=Falsewhen imported.mixin.ModeequalityBatchinginstances are equal only ifbatch_sizeandbatch_axismatch.JointModeinstances compare their component modes.Modeis a staticjitargument, a different batch size now triggers a retrace.repr()/print()outputreproutput.New Features
Pretty representation redesign (#246)
Node,nn.Module,State,TreefyStateand thebrainstate.utilcontainers now share one width-aware layout engine. A group goes on a single line when it fits within the line width. If it doesn't, each item goes on its own line and is followed by a comma. Arrays are shown as dtype and shape. Trailing comments give per-child and total parameter counts:Formatting:
f32[3,4], scalars likef32(0.5), andbrainunitquantities likef32[3] mV.(3,) -> (4,).ParamState{...}.[i]index labels.<shared: path>, and a reference back to an enclosing object as<cycle: path>.Summary: the parameter and state-value counts and byte sizes are computed from unique states. Computing them does not trigger state read hooks.
New options API in
brainstate.util:ReprOptionshas the fieldswidth,max_depth,max_items,summary,colorandshort_dtypes.set_repr_options()andget_repr_options()set and read the process-wide defaults.repr_options()context manager applies a nestable override for the current thread only.brainstate.util.pretty_format(value)formats any value with the same engine, including lists, dicts, dataclasses and arrays.Optional ANSI color, applied only by
str()andprint(), never byrepr(). Turn it on withset_repr_options(color=True)orBRAINSTATE_REPR_COLOR=1. TheNO_COLORenvironment variable turns it off.The custom
__pretty_repr__protocol is backward compatible.The redesign also fixes these representations:
TreefyStateprinted full arrays and its internal hook manager.nn.Mapandnn.Paramprinted attributes that wereNone.mixin.Batchinglabelledbatch_sizeasin_size.interop.PermuteAxesprinted asTranspose.HiDatasubclasses printed asHiData.Bug Fixes
brainstate.Stateand hooks (#244)State.update_from_ref()used to replace the target's hook manager with the source's. It now keeps the target's own.State.replace()andTreefyState.to_state()now get a fresh hook manager.copy(),replace(),copy_from()andto_state()now copy thetagset instead of sharing it.HookCancellationErrorin a hook cancels the write. It used to be wrapped inHookExecutionError, so the write went ahead anyway. Logged hook errors now report the original exception.StateTraceStackno longer hides exceptions. If an exception was raised inside the block, leaving the block now lets it propagate instead of replacing it with an "out of order"RuntimeError.brainstate.mixin(#244)Mode.__eq__andMode.__hash__take parameters into account, soBatching(2) != Batching(5). Before,jitcould reuse code compiled for a different batch size. Comparing a mode with a non-Modeobject returnsNotImplemented.brainstate.environ(#242, #244)import brainstateno longer disables float64. The global precision now starts from JAX's setting: 64 if x64 is on, otherwise 32. Importing the package doesn't change the JAX config. Explicitset(precision=...),set_precision()andcontext(precision=...)still controljax_enable_x64.get_dt()raisedKeyError) whilejax_enable_x64was set for the whole process. Ifcontext(precision=...)blocks overlap in different threads, one thread no longer turns x64 off while another still needs it.brainstate.random(#244)pareto()samples Pareto II (Lomax), matching its documentation and NumPy (see Upgrade notes).multinomial()no longer drops draws whenpvalsdoes not sum to 1. As in NumPy, the last probability is taken to be1 - sum(pvals[:-1]), so the counts in every row sum ton.zipf()acceptssizeas a list.brainstate.nn(#244)BatchNorm*withtrack_running_stats=Falsenow normalizes using batch statistics. Before, it returned its input unchanged.BatchNorm*running statistics are no longer corrupted whenfeature_axisis not the last axis.MaxUnpool*restores odd-sized and padded inputs correctly withoutoutput_size. Before, values were misplaced, sometimes into other batch elements.output_sizeis still honored (see Upgrade notes for the change to the index format).MaxPool*(return_indices=True, in_size=...)no longer fails in the constructor.Delaycomputes the correct number of steps for float delays. Ifdelay / dtis within 1e-6 of an integer, it is now rounded instead of rounded up, so0.3 / 0.1gives 3 steps instead of 4.update_everygets the same fix.init_maybe_prefetch()acceptsPrefetchDelaytargets instead of raisingTypeError.brainstate.transform(#244)jax.debug.print, host callbacks andjit_error_if.jit, while the optimization pass is running.x - x → 0and0 * x → 0simplifications only apply to 0-d integer outputs. They used to produce outputs of the wrong shape and to turninf - infinto 0 instead of NaN.vmap_new_states,vmap2_new_statesandpmap2_new_statesdetect mapped tracers leaking into existing states. When the function writes a mapped value into a state that existed before the call, that state is rolled back and a clear error is raised. States excluded withstate_to_excludeare now cleaned up properly instead of keeping invalid tracers.jitworks outstatic_argnumsfromstatic_argnames(and the reverse) using the function signature, likejax.jit. The same applies todonate_argnumsanddonate_argnames. A static argument passed by position is now treated as static.StatefulFunctionandmake_jaxpraccept negativestatic_argnums.scanwith constants runs correctly (fn_to_python_code(),jaxpr_to_python_code()). This also covers bodies containing operations that only use constants, and nested jaxprs with unused inputs.DebugInfoattached. JAX has deprecated jaxprs without one and plans to make them an error (jax-ml/jax#26480). This affectseqns_to_jaxpr(),eqns_to_closed_jaxpr(),optimize_jaxpr(),fn_to_python_code()andjaxpr_to_python_code()(fix: jax 0.11.2 compatibility, raise floor to jax>=0.9.0 #240).Build & CI
requires-python = '>=3.12'). The Python 3.11 classifier is removed and a Python 3.15 classifier is added.jax>=0.9.0inpyproject.tomlandrequirements.txt, and the code paths for older JAX versions are removed (fix: jax 0.11.2 compatibility, raise floor to jax>=0.9.0 #240).jax==0.8.0entry is dropped (fix: jax 0.11.2 compatibility, raise floor to jax>=0.9.0 #240, ci: pin jax 0.12.0 in test matrix; add jax 0.12 compatibility audit #243).DebugInfo(fix: jax 0.11.2 compatibility, raise floor to jax>=0.9.0 #240).Quality
jax>=0.11.1, and visualization tests that needpydot.mypyreports no issues in the 108 checked source files.Summary by Sourcery
Release brainstate 0.6.0 with redesigned representations, broad correctness fixes, and support for current Python and JAX versions.
New Features:
Bug Fixes:
Enhancements:
Build:
CI:
Deployment:
Documentation:
Tests:
Chores: