Theoretical framework unifying Spiking Neural Networks (SNNs) and Transformers through shared computational primitives. Based on arXiv:2605.00662 (Bose, 2026). Use when analyzing SNN-Transformer relationships, positional encoding design, sequence learning theory, spike-timing computation, or sparse distributed memory. Activation: spiking transformer, spike-timing attention, phase-latency isomorphism, sparse distributed memory SNN, positional encoding theory, sequence learning theory, SNN tran...
Scanned 9/11/2026
Install to Claude Code
npx -y skills add hiyenwong/ai_collection --skill spiking-transformer-unification --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Spiking Transformer Unification?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/hiyenwong-spiking-transformer-unification-d8df2bbf)More formats (shields.io, HTML) on the badges page.
---
name: spiking-transformer-unification
description: "Theoretical framework unifying Spiking Neural Networks (SNNs) and Transformers through shared computational primitives. Based on arXiv:2605.00662 (Bose, 2026). Use when analyzing SNN-Transformer relationships, positional encoding design, sequence learning theory, spike-timing computation, or sparse distributed memory. Activation: spiking transformer, spike-timing attention, phase-latency isomorphism, sparse distributed memory SNN, positional encoding theory, sequence learning theory, SNN transformer unification, cosine similarity retrieval."
---
# Spiking-Transformer Unification
Theoretical framework showing Spiking Sparse Distributed Memory (SDM, 2007) and Transformer (2017) instantiate the same five functional operations, with formal Phase-Latency Isomorphism linking spike timing to sinusoidal positional encoding.
## Core Theory
### Five Shared Functional Operations
Both architectures implement:
1. **Encoding**: Input → representation space mapping
2. **Context Maintenance**: Temporal/sequential state tracking
3. **Associative Retrieval**: Similarity-based content-addressable memory access
4. **Storage**: Writing to memory with interference management
5. **Decoding**: Representation → output mapping
### Phase-Latency Isomorphism (Theorem 1)
Sinusoidal positional phase φ and spike timing t are linearly related:
```
φ(ω, t) = ωt + φ₀ ↔ t ∝ φ/ω
```
Dot product attention is invariant to this mapping up to a global scale factor on the positional component.
**Key insight**: Time (spike latency), phase (sinusoidal PE), and rank (positional index) are three instantiations of the same computational primitive — an ordered index surviving similarity-based retrieval.
### Cosine Similarity as Shared Retrieval Primitive
Both Spiking SDM and Transformer attention use cosine similarity for retrieval:
```
Spiking SDM: retrieve(key) = argmax_j cos(h, m_j)
Transformer: attention(Q,K) = softmax(QK^T / √d) ≈ cosine similarity
```
## Positional Encoding Analysis
### Three Equivalent Positional Representations
| Type | Mechanism | Property |
|------|-----------|----------|
| Time | Spike latency | Physical delay |
| Phase | sin(ωt + φ₀) | Cyclical encoding |
| Rank | Learned embedding | Distance discriminability |
### Critical Finding
The essential property for positional encoding is **distance discriminability under dot-product similarity**, not the sinusoidal form. Learned rank-based embeddings match or exceed sinusoidal encoding.
Frequency-compressed positional encoding fails on positionally demanding tasks, confirming that sufficient frequency bandwidth matters more than functional form.
## Implementation Patterns
### Rank-Based Positional Encoding
```python
import torch
import torch.nn as nn
class RankBasedPositionalEncoding(nn.Module):
"""Learned rank-based positional encoding.
More flexible than sinusoidal PE, matches/exceeds performance."""
def __init__(self, max_len: int, d_model: int):
super().__init__()
self.positional_embeddings = nn.Embedding(max_len, d_model)
nn.init.normal_(self.positional_embeddings.weight, std=0.02)
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""x: (batch, seq_len, d_model)"""
positions = torch.arange(x.size(1), device=x.device)
return x + self.positional_embeddings(positions)
```
### Spiking Attention Approximation
```python
def spiking_cosine_attention(Q_spikes, M_patterns):
"""Spiking approximation of cosine-similarity attention.
Q_spikes: binary spike trains representing query
M_patterns: stored memory patterns
Uses coincidence detection to approximate cosine similarity."""
# Coincidence count ≈ dot product for binary spikes
coincidences = torch.matmul(Q_spikes.float(), M_patterns.T)
# Normalize by spike counts for cosine
q_norm = Q_spikes.sum(dim=-1, keepdim=True).sqrt()
m_norm = M_patterns.sum(dim=-1).sqrt()
return coincidences / (q_norm * m_norm + 1e-8)
```
## Key Implications
1. **SNNs as efficient Transformers**: Spiking networks can implement attention-like operations through coincidence detection and temporal coding
2. **Transformer insights for SNN design**: Attention theory informs better SNN architectures
3. **Positional encoding flexibility**: Rank-based alternatives to sinusoidal PE are viable
4. **Unified sequence learning theory**: Multiple architectures converge on same computational principles
## References
- Bose, J. (2026). Spiking Sequence Machines and Transformers. arXiv:2605.00662
- Kanerva, P. (2007). Sparse Distributed Memory (SDM framework)
- Vaswani, A. et al. (2017). Attention Is All You Need
## Pitfalls
- Phase-latency isomorphism holds only for sinusoidal PE with proper frequency selection
- Rank-based PE requires training data; not suitable for zero-shot extrapolation beyond max_len
- Spiking attention approximation loses precision compared to full dot-product attention
- SDM capacity scales as O(N) with pattern count N, unlike Transformer's O(N²)Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!