Spike Codec & Loss Pack

Implement AMP-safe batch-first spike encoding and decoding with differentiable loss composition.

Updated Feb 28, 2026
One-click install
npx skills add https://github.com/sovr610/refffiy --skill spike-codec-loss-pack
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Spike Codec & Loss Pack
Source: https://github.com/sovr610/refffiy/tree/main/brain-ai-dev/skills/spike-codec-losses
Command: npx skills add https://github.com/sovr610/refffiy --skill spike-codec-loss-pack

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

Provides a modular, batched spike-encoding/decoding framework and a configurable spike-loss pack for training spike-based neural networks with strict AMP safety and diagnostics.

Core Features & Use Cases

  • Batch-first spike codec: encode inputs into SpikeBatch (B, T, N) and decode with AMP-hardening loss terms.
  • Loss composition: combine ProbSpikes, SpikeRateRegularization, TemporalConsistency, ISIRegularization, MembraneRegularization via SNNLossComposer with per-term diagnostics.
  • Deterministic/evaluation paths and generator control for reproducible experiments.
  • Reference templates and reference implementations to accelerate development, testing, and CI.

Quick Start

Run the AMP-stress tests to validate spike-codec losses across configurations and ensure end-to-end gradient flow.

Frequently Asked Questions about Spike Codec & Loss Pack

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement batch-first spike encoding and decoding for spiking neural networks?

Batch-first spike encoding and decoding transforms inputs into a SpikeBatch of shape (B, T, N) while applying AMP-hardening to ensure stable gradient flow during spiking neural network training.

How do I compose differentiable spike-rate and membrane regularization losses in PyTorch?

Spike-loss composition combines ProbSpikes, SpikeRateRegularization, TemporalConsistency, and MembraneRegularization via an SNNLossComposer to provide configurable differentiable losses with per-term diagnostics.

Does this spiking neural network codec support Automatic Mixed Precision training?

The spike codec and loss pack framework is explicitly AMP-safe, ensuring end-to-end gradient flow and differentiable loss composition remain stable under Automatic Mixed Precision configurations.

What is the best way to combine temporal consistency and ISI regularization for SNN training?

Combining temporal consistency and ISI regularization is best achieved through a modular loss composer that aggregates multiple spike-loss terms and provides per-term diagnostics for evaluation.

How do I ensure reproducible spike encoding across different training runs?

Reproducible spike encoding is managed through deterministic evaluation paths and explicit generator control, ensuring that SpikeBatch generation remains consistent across multiple experiments.

Why does my spike-loss calculation break gradient flow during AMP stress testing?

Gradient flow breaks during AMP stress testing when spike-loss terms lack AMP-hardening; using a dedicated codec with AMP-safe loss terms ensures end-to-end differentiability across configurations.