Skip to content

Neural Execution API

Raul Montoya Cardenas edited this page Jul 29, 2026 · 2 revisions

Neural Execution API

Wiki hero

Generated with Grok Build: Grok 4.5 · xAI Imagine (/imagine)

Detailed call surface for production SparseBrain / EnsembleBrain paths.

Constructors

SparseBrain

SparseBrain(tau_m::Float32; n_in::Int=14, n_out::Int=16, name::String="default") -> SparseBrain
Arg Type Default Notes
tau_m Float32 required Membrane τ_m (ms)
n_in Int 14 Input dimension; must be > 0
n_out Int 16 Output dimension; must be > 0
name String "default" Logging label

Requires CUDA. Throws ArgumentError on non-positive dims. Allocates sparse W, dense I/O weights, state, and history on GPU.

EnsembleBrain

EnsembleBrain(; n_in::Int=14, n_out::Int=16) -> EnsembleBrain

Creates 4 lobes with τ_m ∈ {10, 25, 50, 100} ms and aggregation weights {0.4, 0.3, 0.2, 0.1}. Prints VRAM summary after sync.

Stepping

SparseBrain

step!(brain::SparseBrain, u::CuVector{Float32};
      inhibition::Real=0.0f0,
      reflex_eta::Real=ETA) -> nothing
Arg Requirement
u length(u) == brain.n_in or DimensionMismatch
inhibition Converted to Float32; clamped to [0, MAX_INHIBITION] internally
reflex_eta Learning rate for the 10-tick W_out Hebb update

On exception: best-effort Sentry capture, then rethrow.

EnsembleBrain

ensemble_step!(eb::EnsembleBrain, u::CuVector{Float32};
               inhibition::Real=0.0f0,
               reflex_eta::Real=ETA,
               reflex_signal::Real=0.0f0) -> nothing

step!(eb::EnsembleBrain, u::CuVector{Float32};
      inhibition=0.0f0, reflex_eta=ETA, reflex_signal=0.0f0) -> nothing

step! on an ensemble forwards to ensemble_step!. When |reflex_signal| > 0.1, Fast lobe uses 5 * reflex_eta.

Readouts

get_output(brain::SparseBrain) -> Vector{Float32}         # length n_out
get_ensemble_output(eb::EnsembleBrain) -> Vector{Float32} # length n_out

Both copy from GPU to host via Array(...).

Covariance

compute_reservoir_covariance!(brain::SparseBrain)
# -> nothing  if !hist_full
# -> (C::CuMatrix, indices::Vector{Int}) otherwise

See STDP and Covariance.

Diagnostics

diagnostics(brain::SparseBrain) -> String
# [brain] tick=… spikes=… rate=…% V_thresh=… W_out_norm=…

ensemble_diagnostics(eb::EnsembleBrain) -> String
# [Fast:τ=10] tick=… rate=…% W=… | [Medium:…] | …

Minimal Example

using LiquidCortex, CUDA

brain = SparseBrain(20.0f0; n_in=8, n_out=4, name="api")
u = CUDA.randn(Float32, 8)
for _ in 1:100
    step!(brain, u; inhibition=0.2f0)
end
y = get_output(brain)
@assert length(y) == 4

eb = EnsembleBrain(n_in=8, n_out=4)
ensemble_step!(eb, u; inhibition=0.1f0, reflex_signal=0.2f0)
ye = get_ensemble_output(eb)

Related


Last updated: July 28, 2026 Updated by: Grok Build: Grok 4.5 Package tip reference: 4e2698c (main)

Clone this wiki locally