bmtk.simulator.dpointnet.cell_models package#
Submodules#
bmtk.simulator.dpointnet.cell_models.glif3_cell module#
- class bmtk.simulator.dpointnet.cell_models.glif3_cell.GLIF3Cell(*args: Any, **kwargs: Any)[source]#
Bases:
Layer- calculate_input_current_from_firing_probabilities(x_t, input_net)[source]#
Input current when the input is firing PROBABILITIES (rate/’current’ input) rather than discrete spikes. Computes I[:, post, r] = sum_pre w[post,pre]*basis[type,r]*prob[pre] via a per-receptor sparse-dense matmul. Ported from the reference V1_GLIF_model; uses the per-input dict (input_net) like calculate_input_current_from_spikes.
- property output_size#
- refresh_recurrent_weight_shadow()[source]#
Sync the compute-dtype shadow of the recurrent weights with the trained master.
Under mixed precision the forward uses
recurrent_weight_values_compute(a non-trainable float16 copy) while the optimizer updates the float32 masterrecurrent_weight_values. This must be called after each optimizer step, else the forward keeps using stale weights and recurrent-weight training has no effect. Matches the reference V1_GLIF_model.
- property state_size#
- class bmtk.simulator.dpointnet.cell_models.glif3_cell.SignedConstraint(*args: Any, **kwargs: Any)[source]#
Bases:
Constraint
- bmtk.simulator.dpointnet.cell_models.glif3_cell.calculate_input_currents(x_t, input_indices, input_weight_values, input_weight_values_compute, input_dense_shape, synaptic_basis_weights, input_syn_ids, pre_input_ind_table)#
Memory-efficient input (LGN/background) synaptic current, mirroring
calculate_synaptic_currentsbut for an external spike inputx_t.Forward: I[b,post,r] = sum_pre( x_t[b,pre] * W_in[post,pre] * basis[type,r] ), where
x_t[b,pre]may be a multi-spike count (not just 0/1). Forward reads the compute-dtype shadowinput_weight_values_compute; the custom backward returns the gradient w.r.t. the trainable masterinput_weight_valuesand recomputes the cheap basis gather instead of retaining per-timestep activations. The plain-autodiff version stacked those activations across the whole sequence, which dominated background-input memory at high firing rates. No gradient flows tox_t(external input).
- bmtk.simulator.dpointnet.cell_models.glif3_cell.calculate_synaptic_currents(rec_z_buf, synapse_indices, weight_values, weight_values_compute, dense_shape, synaptic_basis_weights, syn_ids, pre_ind_table)#
Optimized synaptic current calculation with memory-efficient gradients for RSNN timestep iteration.
Mathematical formulation: - Forward: I[b,post,r] = sum_pre(spike[b,pre] * W[post,pre] * basis[type[post,pre], r]) - Grad w.r.t spike: dL/dspike[b,pre] = sum_post sum_r(dL/dI[b,post,r] * W[post,pre] * basis[type,r]) - Grad w.r.t W: dL/dW[post,pre] = sum_b sum_r(dL/dI[b,post,r] * spike[b,pre] * basis[type,r])
Key optimizations: 1. Use int32 for GPU-bound operations (segment_ids, arithmetic, unsorted_segment_sum) 2. Use int64 for CPU-bound operations (RaggedTensor gather) and SparseTensor indices (required) 3. Recompute cheap operations in backward pass to minimize saved activations (VRAM) 4. Use einsum for fused multiply-sum operations on weight gradients
- bmtk.simulator.dpointnet.cell_models.glif3_cell.get_new_inds_table(indices, weights, syn_ids, non_zero_cols, pre_ind_table)[source]#
Optimized function that prepares new sparse indices tensor.
- bmtk.simulator.dpointnet.cell_models.glif3_cell.make_pre_ind_table(indices, n_source_neurons)[source]#
- bmtk.simulator.dpointnet.cell_models.glif3_cell.pseudo_derivative(v_scaled, dampening_factor)[source]#
- bmtk.simulator.dpointnet.cell_models.glif3_cell.spike_function(v_scaled, dampening_factor)#
- bmtk.simulator.dpointnet.cell_models.glif3_cell.spike_gauss(v_scaled, sigma, amplitude)#