brainx-skill 1.0.3 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +29 -64
  3. package/adapters/gemini.js +7 -0
  4. package/adapters/opencode.js +7 -0
  5. package/adapters/windsurf.js +7 -0
  6. package/{lib → installation/lib}/installer.js +8 -5
  7. package/manifest.json +7 -1
  8. package/package.json +25 -10
  9. package/skills/braincell/SKILL.md +182 -0
  10. package/skills/braincell/references/area-scaled-hh-pattern.md +54 -0
  11. package/skills/braincell/references/braincell-custom-ion-channel-authoring.md +210 -0
  12. package/skills/braincell/references/channel-library.md +170 -0
  13. package/skills/braincell/references/ion-library.md +154 -0
  14. package/skills/braincell/references/mixions-for-adaptation.md +81 -0
  15. package/skills/braincell/references/multicompartment/braincell-manual-morphology-construction.md +180 -0
  16. package/skills/braincell/references/multicompartment/cv-policy-reference.md +133 -0
  17. package/skills/braincell/references/multicompartment/filter-function-library.md +162 -0
  18. package/skills/braincell/references/multicompartment/morphology-io-loading-validation.md +135 -0
  19. package/skills/braincell/references/multicompartment/multicompartment-cell-workflow.md +391 -0
  20. package/skills/braincell/references/multicompartment/probe-reference.md +128 -0
  21. package/skills/braincell/references/multicompartment/topology-building-and-visualization.md +121 -0
  22. package/skills/braincell/references/scripts/calcium_channel_gating.py +66 -0
  23. package/skills/braincell/references/scripts/cell_multicompartment_reference.py +221 -0
  24. package/skills/braincell/references/scripts/channel_ablation.py +61 -0
  25. package/skills/braincell/references/scripts/fi_curve.py +68 -0
  26. package/skills/braincell/references/scripts/hh_neuron_basics.py +59 -0
  27. package/skills/braincell/references/scripts/spike_frequency_adaptation.py +75 -0
  28. package/skills/braincell/references/scripts/t_current_rebound.py +72 -0
  29. package/skills/braincell/references/scripts/thalamic_neurons.py +228 -0
  30. package/skills/braincell/references/solver-library-with-effects.md +188 -0
  31. package/skills/brainevent/SKILL.md +268 -0
  32. package/skills/brainevent/references/connectivity-variants.md +312 -0
  33. package/skills/brainevent/references/custom-operators-cpu.md +304 -0
  34. package/skills/brainevent/references/custom-operators-gpu.md +468 -0
  35. package/skills/brainevent/references/scripts/102_EI_net_1996.py +107 -0
  36. package/skills/brainevent/references/scripts/204_joglekar_2018_propagation.py +168 -0
  37. package/skills/brainevent/references/scripts/coba_ei_teaching.py +356 -0
  38. package/skills/brainevent/references/sparse-formats.md +182 -0
  39. package/skills/brainevent/references/synaptic-plasticity.md +285 -0
  40. package/skills/brainpy-state/SKILL.md +232 -0
  41. package/skills/brainpy-state/references/array-creation.md +158 -0
  42. package/skills/brainpy-state/references/brain-dynamics-delay-protocol.md +96 -0
  43. package/skills/brainpy-state/references/braintools/brainstate-control-flow-patterns.md +334 -0
  44. package/skills/brainpy-state/references/braintools/data-preprocessing.md +79 -0
  45. package/skills/brainpy-state/references/braintools/metric.md +152 -0
  46. package/skills/brainpy-state/references/braintools/optimizer.md +179 -0
  47. package/skills/brainpy-state/references/braintools/parameter-initializer.md +183 -0
  48. package/skills/brainpy-state/references/braintools/surrogate.md +147 -0
  49. package/skills/brainpy-state/references/component-selection.md +273 -0
  50. package/skills/brainpy-state/references/nest-compatible/devices.md +157 -0
  51. package/skills/brainpy-state/references/nest-compatible/divergence-and-parity.md +114 -0
  52. package/skills/brainpy-state/references/nest-compatible/integration-categories.md +41 -0
  53. package/skills/brainpy-state/references/nest-compatible/model-library.md +200 -0
  54. package/skills/brainpy-state/references/nest-compatible/nest-workflow.md +156 -0
  55. package/skills/brainpy-state/references/nest-compatible/network-building.md +264 -0
  56. package/skills/brainpy-state/references/nest-compatible/scripts/brette_et_al_2007.py +320 -0
  57. package/skills/brainpy-state/references/nest-compatible/scripts/brunel_alpha.py +108 -0
  58. package/skills/brainpy-state/references/nest-compatible/scripts/brunel_delta.py +93 -0
  59. package/skills/brainpy-state/references/nest-compatible/scripts/clopath_synapse_spike_pairing.py +171 -0
  60. package/skills/brainpy-state/references/nest-compatible/scripts/evaluate_tsodyks2_synapse.py +147 -0
  61. package/skills/brainpy-state/references/nest-compatible/scripts/spatial_gaussex.py +112 -0
  62. package/skills/brainpy-state/references/nest-compatible/scripts/synapsecollection.py +198 -0
  63. package/skills/brainpy-state/references/nest-compatible/synapse-and-connectivity.md +153 -0
  64. package/skills/brainpy-state/references/projection-patterns.md +125 -0
  65. package/skills/brainpy-state/references/scripts/103_COBA_2005.py +86 -0
  66. package/skills/brainpy-state/references/scripts/106_COBA_HH_2007.py +181 -0
  67. package/skills/brainpy-state/references/scripts/107_gamma_oscillation_1996.py +156 -0
  68. package/skills/brainpy-state/references/scripts/109_fast_global_oscillation.py +111 -0
  69. package/skills/brainpy-state/references/scripts/201_surrogate_grad_lif_fashion_mnist.py +221 -0
  70. package/skills/brainpy-state/references/scripts/training-snn.py +119 -0
  71. package/skills/brainstate/SKILL.md +399 -0
  72. package/skills/brainstate/agents/openai.yaml +4 -0
  73. package/skills/brainstate/references/brainstate/brainstate-control-flow-patterns.md +334 -0
  74. package/skills/brainstate/references/brainstate/brainstate-transformed-diagnostics.md +180 -0
  75. package/skills/brainstate/references/brainstate/parameter-constraints-regularization.md +213 -0
  76. package/skills/brainstate/references/brainstate/parameter-transforms-regularizers-catalog.md +171 -0
  77. package/skills/brainstate/references/brainstate/randomness-and-reproducibility.md +131 -0
  78. package/skills/brainstate/references/brainstate/transformation-grad-expansion.md +462 -0
  79. package/skills/brainstate/references/brainstate/transformation-jit-expansion.md +167 -0
  80. package/skills/brainstate/references/brainstate/transformation-vmap-expansion.md +314 -0
  81. package/skills/brainstate/references/collective_model_operations.md +195 -0
  82. package/skills/brainstate/references/extension_mechanisms.md +293 -0
  83. package/skills/brainstate/references/libraries/prebuilt-activation-library.md +115 -0
  84. package/skills/brainstate/references/libraries/prebuilt-layer-library.md +143 -0
  85. package/skills/brainstate/references/model-interop-and-migration.md +305 -0
  86. package/skills/brainstate/references/simulation-environment.md +117 -0
  87. package/skills/brainstate/references/size-inference-variations.md +279 -0
  88. package/skills/brainstate/references/state-graph-operations.md +216 -0
  89. package/skills/brainstate/references/state_collections_and_utilities.md +235 -0
  90. package/skills/brainstate/scripts/integrator_rnn.py +359 -0
  91. package/skills/brainstate/scripts/lif_neuron_model.py +52 -0
  92. package/skills/brainstate/scripts/modern_cnn.py +73 -0
  93. package/skills/brainstate/scripts/resnet.py +130 -0
  94. package/skills/brainunit/SKILL.md +287 -0
  95. package/skills/brainunit/references/array-creation.md +158 -0
  96. package/skills/brainunit/references/array-mechanics/functional-structural-api.md +90 -0
  97. package/skills/brainunit/references/array-mechanics.md +165 -0
  98. package/skills/brainunit/references/math-function-library.md +433 -0
  99. package/skills/brainunit/references/physical-constant-library.md +58 -0
  100. package/skills/brainunit/references/prefix-library.md +116 -0
  101. package/skills/brainunit/references/quantity-inspection-and-conversion.md +104 -0
  102. package/skills/brainunit/references/typing-and-runtime-validation.md +203 -0
  103. package/skills/brainunit/references/unit-structure-and-definition.md +140 -0
  104. package/skills/brainx-general-guard/SKILL.md +153 -0
  105. package/skills/brainx-general-guard/references/brainstate-randomness-reproducibility/advanced-randomness.md +303 -0
  106. package/skills/brainx-general-guard/references/brainstate-randomness-reproducibility/randomness-and-reproducibility.md +62 -0
  107. package/skills/brainx-install/SKILL.md +2 -2
  108. package/skills/brainx-install/references/compatibility-and-release-matching.md +3 -3
  109. /package/{bin → installation/bin}/brainx.js +0 -0
  110. /package/{lib → installation/lib}/adapter-transaction.js +0 -0
  111. /package/{lib → installation/lib}/bundle.js +0 -0
  112. /package/{lib → installation/lib}/cli.js +0 -0
  113. /package/{lib → installation/lib}/constants.js +0 -0
  114. /package/{lib → installation/lib}/hash.js +0 -0
  115. /package/{lib → installation/lib}/paths.js +0 -0
  116. /package/{lib → installation/lib}/prompts.js +0 -0
  117. /package/{lib → installation/lib}/receipt.js +0 -0
@@ -0,0 +1,303 @@
1
+ # Advanced BrainState RNG reference
2
+
3
+ This is a nested child with exactly one selector: `skills/brainx-general-guard/references/brainstate-randomness-reproducibility/randomness-and-reproducibility.md`. Do not route here directly from a skill, workspace router, index, transform reference, or dynamics reference. Keep the default path compact: seed once, call `brainstate.random`, and let BrainState manage keys automatically.
4
+
5
+ Official anchor phrase: `brainstate.random` provides "a comprehensive set of random number generation functions and utilities for neural network simulations and scientific computing." It includes standard random distributions, random state management with automatic key splitting, seed management utilities, and a NumPy-compatible API.
6
+
7
+ ## 1. Manual key management
8
+
9
+ Official boundary: "For advanced use cases, you can directly access and manipulate keys."
10
+
11
+ Use manual keys only when the task explicitly needs current-key inspection, exact RNG restoration, or parallel key splitting.
12
+
13
+ ```python
14
+ # Get current key
15
+ current_key = brainstate.random.get_key()
16
+ print(f"Current key: {current_key}")
17
+
18
+ # Split key for parallel operations
19
+ keys = brainstate.random.split_key(n=4)
20
+ print(f"\n Split into {len(keys)} keys:")
21
+ for i, key in enumerate(keys):
22
+ print(f" Key {i}: {key}")
23
+ ```
24
+
25
+ ```python
26
+ # Save and restore state
27
+ saved_key = brainstate.random.get_key()
28
+ v1 = brainstate.random.randn(3)
29
+ # Generate more numbers
30
+ v2 = brainstate.random.randn(3)
31
+
32
+ # Restore state
33
+ brainstate.random.set_key(saved_key)
34
+ v3 = brainstate.random.randn(3)
35
+
36
+ print(f"v1: {v1}")
37
+ print(f"v2: {v2}")
38
+ print(f"v3 (restored): {v3}")
39
+ print(f"\n v1 == v3? {jnp.allclose(v1, v3)}")
40
+ ```
41
+
42
+ Related API utilities:
43
+
44
+ - `get_key`: get the current global random key.
45
+ - `set_key`: set a new random key for the global random state.
46
+ - `get_key_data`: get the current global random key as raw `uint32[2]` data.
47
+ - `restore_key`: restore the default random key to its previous state.
48
+ - `split_key`: create new random key(s) from the current seed.
49
+ - `split_keys`: create multiple independent random keys from the current seed.
50
+ - `self_assign_multi_keys`: assign multiple keys to the global random state for parallel access.
51
+
52
+ ## 2. Custom `RandomState` instances / independent streams
53
+
54
+ Official boundary: "For advanced use cases, you can create custom `RandomState` instances with independent random streams."
55
+
56
+ ```python
57
+ # Create custom random generators
58
+ rng1 = brainstate.random.RandomState(42)
59
+ rng2 = brainstate.random.RandomState(123)
60
+
61
+ print("RNG 1:")
62
+ print(rng1)
63
+
64
+ # Generate independent random sequences
65
+ samples1 = rng1.randn(5)
66
+ samples2 = rng2.randn(5)
67
+ print(f"Samples from RNG1: {samples1}")
68
+ print(f"Samples from RNG2: {samples2}")
69
+ print(f"\n Are they different? {not jnp.allclose(samples1, samples2)}")
70
+
71
+ # Re-seed custom RNG
72
+ rng1.seed(999)
73
+ samples3 = rng1.randn(5)
74
+ print(f"\n After re-seeding RNG1 to 999: {samples3}")
75
+ ```
76
+
77
+ Best-practice examples from the RNG tutorial:
78
+
79
+ ```python
80
+ # For data augmentation
81
+ aug_rng = brainstate.random.RandomState(seed=123)
82
+
83
+ # For model initialization
84
+ init_rng = brainstate.random.RandomState(seed=456)
85
+ ```
86
+
87
+ ## 3. Checkpoint RNG save/restore
88
+
89
+ Use this only when exact continuation of a run matters.
90
+
91
+ ```python
92
+ # Save state
93
+ checkpoint = {
94
+ 'model': model.state_dict(),
95
+ 'rng_key': brainstate.random.get_key()
96
+ }
97
+
98
+ # Restore state
99
+ brainstate.random.set_key(checkpoint['rng_key'])
100
+ ```
101
+
102
+ ## 4. Temporary seed contexts and RNG cloning
103
+
104
+ Official API phrases:
105
+
106
+ - `seed_context`: "Context manager for temporary random seed changes with automatic restoration."
107
+ - `default_rng`: "Get the default random state or create a new one with specified seed."
108
+ - `clone_rng`: "Create a clone of the random state or a new random state."
109
+
110
+ The API page’s seed-management example shows a temporary seed context as:
111
+
112
+ ```python
113
+ >>> import brainstate.random as bsr
114
+ >>>
115
+ >>> # Set a global seed
116
+ >>> bsr.seed(42)
117
+ >>>
118
+ >>> # Get current seed/key
119
+ >>> key = bsr.get_key()
120
+ >>>
121
+ >>> # Split the key for parallel operations
122
+ >>> keys = bsr.split_key(n=4)
123
+ >>>
124
+ >>> # Use context manager for temporary seed
125
+ >>> with bsr.local_seed(123):
126
+ ... x = bsr.normal(0, 1, (5,)) # Uses seed 123
127
+ >>> y = bsr.normal(0, 1, (5,)) # Uses original seed
128
+ ```
129
+
130
+ ## 5. Full probability distribution catalog
131
+
132
+ The compact skill lists only everyday functions. Use this catalog when the user asks for specific distributions or API coverage.
133
+
134
+ ### Basic random sampling
135
+
136
+ - `rand`: random values in a given shape.
137
+ - `randn`: sample(s) from the standard normal distribution.
138
+ - `random`, `random_sample`, `ranf`, `sample`: random floats in `[0.0, 1.0)`.
139
+ - `randint`: random integers from low inclusive to high exclusive.
140
+ - `random_integers`: random integers between low and high inclusive.
141
+
142
+ ### Array-like generation: PyTorch compatibility
143
+
144
+ - `rand_like`: similar to `rand_like` in torch.
145
+ - `randint_like`: similar to `randint_like` in torch.
146
+ - `randn_like`: similar to `randn_like` in torch.
147
+
148
+ ### Array manipulation
149
+
150
+ - `choice`: generates a random sample from a given 1-D array.
151
+ - `permutation`: randomly permute a sequence, or return a permuted range.
152
+ - `shuffle`: return a randomly shuffled copy of an array along an axis.
153
+
154
+ ### Continuous distributions
155
+
156
+ - `beta`: draw samples from a Beta distribution.
157
+ - `exponential`, `standard_exponential`: draw samples from an exponential distribution.
158
+ - `gamma`, `standard_gamma`: draw samples from a Gamma distribution.
159
+ - `gumbel`: draw samples from a Gumbel distribution.
160
+ - `laplace`: draw samples from the Laplace or double exponential distribution.
161
+ - `logistic`: draw samples from a logistic distribution.
162
+ - `normal`: draw random samples from a normal/Gaussian distribution.
163
+ - `pareto`: draw samples from a Pareto II or Lomax distribution.
164
+ - `standard_cauchy`: draw samples from a standard Cauchy distribution.
165
+ - `standard_normal`: draw samples from a standard Normal distribution.
166
+ - `standard_t`: draw samples from a standard Student’s t distribution.
167
+ - `uniform`: draw samples from a uniform distribution.
168
+ - `truncated_normal`: sample truncated standard normal random values.
169
+ - `lognormal`, `power`, `rayleigh`, `triangular`, `vonmises`, `wald`, `weibull`, `weibull_min`, `maxwell`, `t`, `loggamma`.
170
+
171
+ ### Discrete distributions
172
+
173
+ - `bernoulli`: sample Bernoulli random values with given shape and mean.
174
+ - `binomial`: draw samples from a binomial distribution.
175
+ - `categorical`: sample random values from categorical distributions.
176
+ - `geometric`, `hypergeometric`, `logseries`, `multinomial`, `negative_binomial`, `poisson`, `zipf`.
177
+
178
+ ### Special distributions
179
+
180
+ - `chisquare`: draw samples from a chi-square distribution.
181
+ - `dirichlet`: draw samples from the Dirichlet distribution.
182
+ - `f`: draw samples from an F distribution.
183
+ - `multivariate_normal`: draw random samples from a multivariate normal distribution.
184
+ - `noncentral_chisquare`, `noncentral_f`, `orthogonal`.
185
+
186
+ ## 6. Distribution visualization
187
+
188
+ Official boundary: visualization belongs in reference/tutorial material. The RNG tutorial introduces it with: "Let’s visualize several distributions."
189
+
190
+ Use the official tutorial section for histogram examples rather than placing plotting code in the compact skill.
191
+
192
+ ## 7. Full practical examples from the RNG tutorial
193
+
194
+ ### Mini-batch sampling
195
+
196
+ ```python
197
+ def create_mini_batches(X, y, batch_size=32, shuffle=True):
198
+ """Create mini-batches for training."""
199
+ n_samples = len(X)
200
+
201
+ # Shuffle indices
202
+ if shuffle:
203
+ indices = brainstate.random.permutation(n_samples)
204
+ else:
205
+ indices = jnp.arange(n_samples)
206
+
207
+ # Create batches
208
+ batches = []
209
+ for start_idx in range(0, n_samples, batch_size):
210
+ end_idx = min(start_idx + batch_size, n_samples)
211
+ batch_indices = indices[start_idx:end_idx]
212
+ batches.append((X[batch_indices], y[batch_indices]))
213
+
214
+ return batches
215
+
216
+ # Generate dummy dataset
217
+ brainstate.random.seed(0)
218
+ X = brainstate.random.randn(100, 10) # 100 samples, 10 features
219
+ y = brainstate.random.randint(0, 2, 100) # Binary labels
220
+ # Create mini-batches
221
+ batches = create_mini_batches(X, y, batch_size=32)
222
+ print(f"Created {len(batches)} mini-batches")
223
+ print(f"First batch shape: X={batches[0][0].shape}, y={batches[0][1].shape}")
224
+ ```
225
+
226
+ ### Dropout layer
227
+
228
+ ```python
229
+ class Dropout(brainstate.nn.Module):
230
+ """Dropout layer with random masking."""
231
+
232
+ def __init__(self, drop_rate=0.5):
233
+ super().__init__()
234
+ self.drop_rate = drop_rate
235
+
236
+ def __call__(self, x):
237
+ fit = brainstate.environ.get('fit', False)
238
+ if not fit:
239
+ return x
240
+ # Generate random mask
241
+ keep_prob = 1.0 - self.drop_rate
242
+ mask = brainstate.random.bernoulli(keep_prob, x.shape)
243
+
244
+ # Apply dropout and scale
245
+ return x * mask / keep_prob
246
+
247
+ # Test dropout
248
+ brainstate.random.seed(42)
249
+ dropout = Dropout(drop_rate=0.3)
250
+
251
+ x = jnp.ones(10)
252
+ y = dropout(x)
253
+
254
+ print(f"Input: {x}")
255
+ print(f"Output: {y}")
256
+ print(f"Zeros: {jnp.sum(y == 0)}/10")
257
+ ```
258
+
259
+ ### Noisy neural network layer
260
+
261
+ ```python
262
+ class NoisyLayer(brainstate.nn.Module):
263
+ """Linear layer with Gaussian noise."""
264
+
265
+ def __init__(self, d_in, d_out, noise_std=0.1):
266
+ super().__init__()
267
+ self.noise_std = noise_std
268
+
269
+ # Parameters with noise
270
+ self.w = brainstate.ParamState(brainstate.random.randn(d_in, d_out) * 0.1)
271
+ self.b = brainstate.ParamState(jnp.zeros(d_out))
272
+ def __call__(self, x):
273
+ # Add weight noise
274
+ w_noisy = self.w.value + brainstate.random.normal(0, self.noise_std, self.w.value.shape)
275
+
276
+ # Forward pass
277
+ return x @ w_noisy + self.b.value
278
+
279
+ # Create and test
280
+ brainstate.random.seed(0)
281
+ layer = NoisyLayer(5, 3, noise_std=0.01)
282
+
283
+ x = jnp.ones(5)
284
+ y1 = layer(x)
285
+ y2 = layer(x) # Different due to noise
286
+ print(f"Output 1: {y1}")
287
+ print(f"Output 2: {y2}")
288
+ print(f"Difference: {y2 - y1}")
289
+ ```
290
+
291
+ ## 8. Reference routing for broader BrainState workflows
292
+
293
+ - Core tutorials: "define states, compose modules and layers, apply the essential transformations, and train a model."
294
+ - Transformations tutorials: "state-aware program transformations, from the essential `jit` / `grad` / `vmap` through advanced batching, error handling, debugging, and intermediate-representation tooling."
295
+ - Brain Dynamics tutorials: "neuron dynamics and numerical integration, synaptic delays, event-driven operators, and spiking neural networks."
296
+
297
+ ## Official BrainX sources
298
+
299
+ - https://brainx.chaobrain.com/brainstate/tutorials/core/08_randomness.html
300
+ - https://brainx.chaobrain.com/brainstate/apis/random.html
301
+ - https://brainx.chaobrain.com/brainstate/tutorials/transformations/index.html
302
+ - https://brainx.chaobrain.com/brainstate/tutorials/core/index.html
303
+ - https://brainx.chaobrain.com/brainstate/tutorials/brain_dynamics/index.html
@@ -0,0 +1,62 @@
1
+ # BrainState Randomness and Reproducibility Parent Reference
2
+
3
+ Use this reference when BrainState code needs random numbers, reproducible examples/tests, stochastic masks/noise, seed control, random trials, stochastic state, dropout/noise, RNG under transforms, or a decision between the default BrainState RNG path and advanced key/stream APIs.
4
+
5
+ Usually reached from primary skills only when the task actually involves randomness. Do not load this for ordinary deterministic state, module, training, or BrainCell modeling tasks.
6
+
7
+ ## Parent-reference boundary
8
+
9
+ This is this skill's only first-layer randomness reference. `skills/brainx-general-guard/SKILL.md` routes here. `skills/brainx-general-guard/references/brainstate-randomness-reproducibility/advanced-randomness.md` is its nested child and has no other selection route.
10
+
11
+ Use `brainstate.random` for BrainState RNG. Official anchor phrase: it "wraps JAX’s random number generation capabilities with a stateful interface that simplifies usage while maintaining reproducibility and performance."
12
+
13
+ ## Core rules
14
+
15
+ - Default path: use `brainstate.random`; BrainState uses automatic key management, so do not manually create/split `jax.random.PRNGKey` unless explicit key control is requested.
16
+ - Reproducibility: call `brainstate.random.seed(seed)` once at the beginning of scripts, notebooks, examples, tests, or reproducible experiments.
17
+ - Global state: all random functions in `brainstate.random` use a global `DEFAULT` instance of `RandomState`.
18
+ - Common functions only: `random`, `rand`, `randn`, `normal`, `uniform`, `randint`, `bernoulli`, `choice`, `permutation`, `shuffle`.
19
+ - Stochastic modules: generate masks/noise inside the stochastic call using `brainstate.random`.
20
+ - Train-only randomness: gate stochastic behavior with training/fit mode; for dropout-style code, use `brainstate.environ.get('fit', False)` and return the input unchanged when not fitting.
21
+
22
+ ## Canonical official workflow
23
+
24
+ ```python
25
+ import brainstate
26
+
27
+ brainstate.random.seed(0)
28
+ x = brainstate.random.normal(0, 1, (100,)) # Keys handled automatically
29
+ ```
30
+
31
+ ## Stochastic-module pattern
32
+
33
+ ```python
34
+ fit = brainstate.environ.get('fit', False)
35
+ if not fit:
36
+ return x
37
+
38
+ keep_prob = 1.0 - drop_rate
39
+ mask = brainstate.random.bernoulli(keep_prob, x.shape)
40
+ return x * mask / keep_prob
41
+ ```
42
+
43
+ For noisy stochastic behavior, generate noise at call time with `brainstate.random.normal(..., shape)`.
44
+
45
+ ## Open the nested child `skills/brainx-general-guard/references/brainstate-randomness-reproducibility/advanced-randomness.md` for
46
+
47
+ - manual keys: `get_key`, `set_key`, `get_key_data`, `restore_key`, `split_key`, `split_keys`, `self_assign_multi_keys`
48
+ - custom `RandomState` instances or independent streams
49
+ - checkpoint RNG save/restore
50
+ - temporary seed contexts, `default_rng`, or `clone_rng`
51
+ - full probability distribution catalog
52
+ - PyTorch-compatible `rand_like`, `randint_like`, `randn_like`
53
+ - distribution visualization, mini-batch sampling, full dropout/noisy-layer examples
54
+ - RNG combined with transformations, parallelism, or brain-dynamics workflows
55
+
56
+ ## Mirror Source URLs
57
+
58
+ - https://brainx.chaobrain.com/brainstate/tutorials/core/08_randomness.html
59
+ - https://brainx.chaobrain.com/brainstate/apis/random.html
60
+ - https://brainx.chaobrain.com/brainstate/tutorials/transformations/index.html
61
+ - https://brainx.chaobrain.com/brainstate/tutorials/core/index.html
62
+ - https://brainx.chaobrain.com/brainstate/tutorials/brain_dynamics/index.html
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: brainx-install
3
- description: Install, uninstall, or configure BrainX, change its package version or device target, and resolve BrainX ecosystem compatibility. Use whenever a user asks to install, set up, upgrade, downgrade, pin, migrate, remove, uninstall, clean up, or reconcile BrainX packages; switch or select CPU, CUDA 12, CUDA 13, or TPU support. Do not use for general BrainX modeling.
3
+ description: "Manage BrainX Python package installation and package state: install, set up, upgrade, downgrade, pin, migrate, uninstall, or clean up BrainX; select CPU, CUDA 12, CUDA 13, or TPU package extras; and reconcile BrainX release, dependency, and virtual-environment compatibility. Use only for requests about installing or removing packages, package versions, dependency constraints, pip or virtual-environment setup, or device-specific package builds. Do not use for BrainX modeling, simulation, APIs, coding, application debugging, performance, or other general BrainX questions."
4
4
  ---
5
5
 
6
6
  # BrainX Install
@@ -77,7 +77,7 @@ Replace the example values with the user's actual target. If evidence is uncerta
77
77
 
78
78
  ## 3. Select One Release
79
79
 
80
- First case, When no BrainX meta-package or ecosystem component is installed and the user has not requested a specific version, do not open the compatibility reference. Use read-only official package-index metadata with the proposed interpreter to identify the exact latest Python-compatible BrainX release, then report it in the form `latest (vYYYY.M.D)`. For example, report `latest (v2026.7.9)` when `2026.7.9` is the verified current release.
80
+ First case, When no BrainX meta-package or ecosystem component is installed and the user has not requested a specific version, do not open the compatibility reference. Use read-only official package-index metadata with the proposed interpreter to identify the exact latest Python-compatible BrainX release, then report it in the form `latest (vYYYY.M.D)`. For example, report `latest (v2026.7.9)` when `2026.7.9` is the verified current release.
81
81
 
82
82
  Critically, for the second case, when BrainX packages are already installed or the user requests a specific pinned version, you must open [compatibility-and-release-matching.md](references/compatibility-and-release-matching.md) before selecting a release, then apply the matching procedure below.
83
83
 
@@ -19,9 +19,9 @@ Use this matrix for the second release-selection case: the target environment al
19
19
  | `v2026.7.9` | `>=0.8.0, <=0.10.2` | `0.5.1` | `0.5.2` | `0.1.2` | `0.3.0` | BrainTrace `0.2.4` | `0.1.0` | `2.8.1` | `0.1.0` | `0.1.1` | **Not bundled** | `>=0.2.8` |
20
20
  | `v2026.6.29` | `>=0.8.0, <=0.10.2` | `0.5.1` | `0.5.2` | `0.1.1` | `0.3.0` | BrainTrace `0.2.2` | `0.1.0` | `2.8.0` | `0.1.0` | `0.1.1` | **Removed** | — |
21
21
  | `v2026.6.19` | `>=0.8.0, <=0.10.2` | `0.5.1` | `0.5.1` | `0.1.1` | `0.3.0` | BrainTrace `0.2.1` | `0.1.0` | `2.8.0` | `0.1.0` | `0.1.1` | `0.0.3` | — |
22
- | `v2026.6.18` | — | `0.4.0` | `0.5.0` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.1.0` | `0.0.5` | `0.0.3` | — |
23
- | `v2026.6.14` | — | `0.4.0` | `0.5.0` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | `0.0.5` | `0.0.3` | — |
24
- | `v2026.6.11` | — | `0.4.0` | `0.4.2` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | `0.0.5` | `0.0.3` | — |
22
+ | `v2026.6.18` | `>=0.7.1, <=0.10.1` | `0.4.0` | `0.5.0` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.1.0` | `0.0.5` | `0.0.3` | — |
23
+ | `v2026.6.14` | `>=0.7.1, <=0.10.1` | `0.4.0` | `0.5.0` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | `0.0.5` | `0.0.3` | — |
24
+ | `v2026.6.11` | `>=0.7.1, <=0.10.1` | `0.4.0` | `0.4.2` | `0.1.0` | `0.1.10` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | `0.0.5` | `0.0.3` | — |
25
25
  | `v2026.6.8` | `>=0.6.0, <=0.10.1` | `0.3.2` | `0.4.0` | `0.1.0` | `0.1.9` | BrainTrace `0.2.0` | `0.0.8` | `2.7.8` | `0.0.4` | `0.0.5` | `0.0.3` | — |
26
26
  | `v2026.3.12` | `>=0.6.0, <=0.9.1` | `0.2.0` | `0.3.0` | `0.0.7` | `0.1.8` | BrainTrace `0.1.2` | `0.0.8` | `2.7.7` | `0.0.4` | `0.0.5` | `0.0.3` | — |
27
27
  | `v2026.1.31` | `>=0.6.0, <0.9.0` | `0.1.4` | `0.2.10` | `0.0.5` | `0.1.8` | BrainTrace `0.1.2` | `0.0.7` | `2.7.6` | `0.0.3` | `0.0.5` | `0.0.3` | — |
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes