SpikeSkip
Bypass the Von Neumann Memory Wall for Spiking Neural Networks & Sparse Activations.
SpikeSkip is a standalone, production-grade PyTorch CUDA plugin that skips weight DRAM memory fetches for silent (zero-valued) neurons using fused Compressed Sparse Row (CSR) kernels on standard NVIDIA GPUs.
Scope & Philosophy
SpikeSkip is a standalone, zero-dependency model plugin, not a monolithic SNN framework. It seamlessly integrates into any existing PyTorch codebase as a drop-in replacement for standard dense layers (torch.nn.Linear, torch.nn.Conv2d).
- Target Sparsity: >98-99% activation sparsity (typical for SNNs & deep ReLU networks).
- DRAM Reduction: Up to 546x less memory bandwidth traffic (120 KB vs 64 MB per pass on 4096×4096 layers).
- Zero Overhead: Fused GPU-only prefix-sum (~1μs) and cached weight transposes eliminate Python-CUDA runtime latency.
Installation
git clone https://github.com/Griffith-7/spikeskip.git
cd spikeskip
pip install -e .
Requirements
- PyTorch $\ge$ 2.0
- NVIDIA GPU with Compute Capability $\ge$ 7.0
- CUDA Toolkit 11.0+
- C++ Compiler (GCC 7+ on Linux, Visual Studio 2019+ on Windows)
Quick Start
1. High-Level Drop-In Module
import torch
from spikeskip import SparseLinear, SparseConv2d
# Drop-in replacement for nn.Linear
layer = SparseLinear(4096, 4096, bias=True, device="cuda")
# Input tensor with high sparsity (>99% zero elements)
x = torch.randn(256, 4096, device="cuda")
x[x < 2.0] = 0.0
# Forward pass
output = layer(x)
2. Multi-Timestep SNN Temporal Loop
# Input shape: (T=10 timesteps, Batch=256, In_Features=4096)
spikes_t = torch.randn(10, 256, 4096, device="cuda")
spikes_t[spikes_t < 2.0] = 0.0
# Executes CSR conversion and GEMM in a tight C++ loop (zero Python overhead between timesteps)
output = layer.forward_multistep(spikes_t, T=10)
3. Low-Level Functional API
from spikeskip import alloc_csr_buffers, sparse_linear_forward
# Pre-allocate reusable scratch buffers
bufs = alloc_csr_buffers(batch_size=256, in_features=4096, device="cuda")
weightT = layer.linear.weight.t().contiguous()
output = sparse_linear_forward(x, weightT, *bufs)
Benchmark Summary
1. Spiking Language Model Benchmark (pretraining_code.jsonl)
Trained and evaluated on real code pretraining text (pretraining_code.jsonl):
| Metric / Feature | Model A (Astrocyte Baseline) | Model B (SpikeSkip LM) | Key Takeaway |
|---|---|---|---|
| Activation Sparsity (%) | 70.0% (unconstrained) | 99.9% (target >99%) | SpikeSkip (+29.9% Sparsity) |
| Model Perplexity (PPL) | 25.6 (Loss 3.24) | 17.6 (Loss 2.87) | SpikeSkip (Better Accuracy & PPL) |
| DRAM Memory Traffic | 1.0x (Baseline Reads All) | 992.8x DRAM Reduction | SpikeSkip (Fetches <0.1% Weights from DRAM) |
| Inference Decoding Speed | 236.0 tokens/sec | 235.6 tokens/sec | Matching token generation speed |
| Training Speed | 60.10 ms/step | 62.95 ms/step | Parity (~2.8ms difference) |
2. Multi-Step Layer Benchmarks ($4096 \to 4096$, $B=256$)
| Layer Config | Sparsity | cuBLAS Dense | SpikeSkip CSR | Speedup |
|---|---|---|---|---|
| 4096→4096 (Single Pass) | 99.9% | 1.97 ms | 1.30 ms | 1.52x |
| 2-layer SNN (T=10 Timesteps) | 99.9% | 20.19 ms | 12.79 ms | 3.24x |
| Raw Coalesced Kernel | 99.0% | 0.54 ms | 0.25 ms | 2.13x |
Testing
Run the automated Pytest suite:
pip install -e ".[dev]"
pytest tests/ -v
Tests verify exact float32 numerical equivalence against dense PyTorch layers, automatic scratch buffer expansion for large batch sizes ($B > 1024$), and parameter version invalidation during optimizer steps.
Documentation
License
MIT License. See LICENSE for details.
Metadata
Release files for spikeskip 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| spikeskip-0.2.0.tar.gz | 28.7 kB | Without provenance | Details |
Release files / spikeskip-0.2.0.tar.gz
| Download URL | spikeskip-0.2.0.tar.gz |
|---|---|
| Size | 28.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1e4a832d5d806c07c25be4ffa1c70947b8a8852b1e7bc7c83825f91b75503ec
|
|
BLAKE2b-256 checksum How to use checksums |
47667649c0938f43653021a56bfe28e9727510b19924e543f0fc8e1fc5ea8d4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for spikeskip 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.