[Paper Review] QKFormer: Hierarchical Spiking Transformer using Q-K Attention
QKFormer introduces a spike-form Q-K attention with linear complexity and a patch-embedding Deformed Shortcut, enabling hierarchical spiking transformers that directly train and outperform prior SNN models on ImageNet-1k and other datasets.
Spiking Transformers, which integrate Spiking Neural Networks (SNNs) with Transformer architectures, have attracted significant attention due to their potential for energy efficiency and high performance. However, existing models in this domain still suffer from suboptimal performance. We introduce several innovations to improve the performance: i) We propose a novel spike-form Q-K attention mechanism, tailored for SNNs, which efficiently models the importance of token or channel dimensions through binary vectors with linear complexity. ii) We incorporate the hierarchical structure, which significantly benefits the performance of both the brain and artificial neural networks, into spiking transformers to obtain multi-scale spiking representation. iii) We design a versatile and powerful patch embedding module with a deformed shortcut specifically for spiking transformers. Together, we develop QKFormer, a hierarchical spiking transformer based on Q-K attention with direct training. QKFormer shows significantly superior performance over existing state-of-the-art SNN models on various mainstream datasets. Notably, with comparable size to Spikformer (66.34 M, 74.81%), QKFormer (64.96 M) achieves a groundbreaking top-1 accuracy of 85.65% on ImageNet-1k, substantially outperforming Spikformer by 10.84%. To our best knowledge, this is the first time that directly training SNNs have exceeded 85% accuracy on ImageNet-1K. The code and models are publicly available at https://github.com/zhouchenlin2096/QKFormer
Motivation & Objective
- Motivate energy-efficient, high-performance spiking neural networks for vision tasks.
- Develop a hierarchical spiking transformer that can be trained directly (non-conversion).
- Propose a spike-form Q-K attention mechanism with linear complexity.
- Design a Patch Embedding module with a Deformed Shortcut to improve information flow.
- Demonstrate state-of-the-art results on ImageNet-1k and other datasets.
Proposed method
- Propose Q-K attention that uses spike-form Query (Q) and Key (K) to compute token and channel importances with linear complexity.
- Decompose Q-K attention into Q-K Token Attention (QKTA) and Q-K Channel Attention (QKCA) with spike-based masking and simple aggregations.
- Integrate a Patch Embedding module with Deformed Shortcut (PEDS) to enable residual learning in patch embedding.
- Build a Hierarchical Spiking Transformer (QKFormer) with three stages that progressively reduces token counts and increases channel dimensions.
- Train the model directly in the spiking domain and use a Spiking MLP (SMLP) and a final FC layer for classification.
- Provide extensive experiments across ImageNet-1k, CIFAR-10/100, CIFAR10-DVS, and DVS128 Gesture to validate performance and efficiency.
Experimental results
Research questions
- RQ1Can a spike-form Q-K attention achieve linear computational complexity while effectively modeling token and channel importance in Spiking Neural Networks?
- RQ2Does incorporating a hierarchical spiking structure with Q-K attention improve performance over existing SNN transformers on large-scale vision tasks?
- RQ3Does the Patch Embedding module with Deformed Shortcut (PEDS) enhance information transmission and accuracy in spiking transformers?
- RQ4Can directly trained SNNs reach or exceed 85% top-1 accuracy on ImageNet-1k with reasonable time steps?
Key findings
- QKFormer achieves 85.65% top-1 accuracy on ImageNet-1k with 4 time steps and 64.96M parameters (best reported in the paper).
- QKFormer outperforms Spikformer by 10.84 percentage points (85.65% vs 74.81%) at similar model sizes.
- Directly trained SNNs in QKFormer surpass 85% top-1 accuracy on ImageNet-1k for the first time in this work.
- Q-K attention has linear time/space characteristics, with QKTA and QKCA enabling efficient token- and channel-wise emphasis through spike-form operations.
- PEDS provides a measurable accuracy gain on CIFAR100 and CIFAR10-DVS compared to baseline Spikformer (CIFAR100: +2.05%; CIFAR10-DVS: +1.3%).
- QKFormer demonstrates strong performance on both static and neuromorphic datasets, with favorable memory and energy characteristics versus quadratic-attention counterparts.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.