Spike-driven Transformer

Spiking Neural Networks (SNNs) provide an energy-efficient deep learning option due to their unique spike-based event-driven (i.e., spike-driven) paradigm. In this paper, we incorporate the spike-driven paradigm into Transformer by the proposed Spike-driven Transformer with four unique properties: 1) Event-driven, no calculation is triggered when the input of Transformer is zero; 2) Binary spike communication, all matrix multiplications associated with the spike matrix can be transformed into sparse additions; 3) Self-attention with linear complexity at both token and channel dimensions; 4) The operations between spike-form Query, Key, and Value are mask and addition. Together, there are only sparse addition operations in the Spike-driven Transformer. To this end, we design a novel Spike-Driven Self-Attention (SDSA), which exploits only mask and addition operations without any multiplication, and thus having up to $87.2\times$ lower computation energy than vanilla self-attention. Especially in SDSA, the matrix multiplication between Query, Key, and Value is designed as the mask operation. In addition, we rearrange all residual connections in the vanilla Transformer before the activation functions to ensure that all neurons transmit binary spike signals. It is shown that the Spike-driven Transformer can achieve 77.1\% top-1 accuracy on ImageNet-1K, which is the state-of-the-art result in the SNN field. The source code is available at https://github.com/BICLab/Spike-Driven-Transformer.

Paper

References (100)

Scroll for more · 38 remaining

Similar papers

Peer review

Reviewer qknk5/10 · confidence 4/52023-07-06

Summary

This paper proposes a Spike-driven Transformer that incorporates the spike-driven paradigm of SNNs into the Transformer and is hardware-friendly for neuromorphic chips. The authors use SDSA to transform the multiplication operation between Query, Key, and Value into a combination of mask and sparse addition operations and modify the self-attention structure to achieve linear complexity. As a result, this approach can achieve up to 87.2× lower energy consumption compared to the traditional self-attention method. Furthermore, membrane shortcut is introduced to ensure all spiking neurons communicate via binary spikes. The paper provides insights into implementing each module on neuromorphic chips and achieves competitive results on multiple datasets while reducing energy consumption compared to previous works.

Strengths

The authors introduce the Spike-Driven Self-Attention (SDSA) module as a replacement for the self-attention module in the current spiking Transformer. The proposed module exhibits superior performance while significantly reducing energy consumption, resulting in an architecture that is better suited for deployment on neuromorphic chips.

Weaknesses

This paper explores the feasibility of implementing Conv, MLP, and Self-attention models driven by spikes on neuromorphic chips. However, it does not delve into the implementation details of membrane shortcuts. This approach involves the direct transmission of membrane potential signals between spiking neurons and may contradict the spike-driven approach discussed in the original text. The effectiveness of a spikformer-based framework with only SDSA, without MS, remains unclear as most experiments in the literature combine both techniques. This weakens the argument for the performance of the spike-driven Transformer proposed in this paper. Although an ablation study was conducted on MS and SDSA in Table 5, it was limited to the CIFAR10/100 dataset and Spiking Transformer-2-512. The results suggest that the use of MS may be crucial to achieve state-of-the-art performance.

Questions

How is the membrane shortcut implemented on a neuromorphic chip? Is it necessary to use it instead of SEW shortcut? The article explains that membrane shortcuts are used to optimize the distribution of membrane potential, but for spiking neurons, wouldn't it be more appropriate to perform such an optimization in the time domain?

Rating

5: Borderline accept: Technically solid paper where reasons to accept outweigh reasons to reject, e.g., limited evaluation. Please use sparingly.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

2 fair

Presentation

3 good

Contribution

3 good

Limitations

No

Reviewer 8FkB7/10 · confidence 3/52023-07-06

Summary

This paper proposed a Spike-Driven Self-Attention (SDSA) module, which uses Hadamard product, column-wise summation, and spiking neuron layer to replace the matrix multiplication and softmax operation. Experiments on static and neuromorphic image classification demonstrate competitive performance and energy efficiency.

Strengths

1.. The authors proposed a novel form of linear self-attention module, SDSA, which leverages the features of the spikes and increases computational and memory efficiency. 2. The authors show extensive results from different models and different datasets. The performance of accuracy and energy efficiency is very strong. 3. SDSA reduces the computational complexity with a slight accuracy drop, and the authors show some attention maps to validate the effectiveness of the SDSA.

Weaknesses

1. There is still a noticeable drop between the spike-driven transformer and the original transformer. Can the authors show some results of the model with more time steps and report the limitations of the model? 2. Can the authors show the performance and energy consumption as the number of time steps decreases?

Questions

1. The ablation study shows the membrane shortcut brings significant accuracy improvement. I slightly doubt the importance of the SDSA. Can the authors try the combination of the membrane shortcut and some attention-free transformers like [1][2] to check if they can also achieve similar performance? [1] J Lee-Thorp et al., “FNet: Mixing Tokens with Fourier Transforms”, NAACL 2022 [2] W Yu et al, “MetaFormer Is Actually What You Need for Vision”, CVPR 2022

Rating

7: Accept: Technically solid paper, with high impact on at least one sub-area, or moderate-to-high impact on more than one areas, with good-to-excellent evaluation, resources, reproducibility, and no unaddressed ethical considerations.

Confidence

3: You are fairly confident in your assessment. It is possible that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

3 good

Presentation

3 good

Contribution

3 good

Limitations

The paper has few limitations.

Reviewer Lu4B7/10 · confidence 4/52023-07-07

Summary

This paper proposes an improved spike transformer by replacing Spike-Element-Wise shortcut in an existing spike transformer (ref [20]) with Membrane Shortcut from spike ResNet (ref [26]) .

Strengths

Match SOTA ImageNet top-1 precision achieved by ResNet [26] with slightly lower estimated energy consumption.

Weaknesses

Combining known techniques from two papers without modification is considered an incremental improvement. It is not clear why Transformer is a better choice than ConvNet in the context of Spike Neural Network. In ViT papers, the motivation for the Transformer is its model capacity can scale easily to handle large datasets and it has much better parallelism on TPU/GPU than ConvNet. None of these has been indicated as the goal for SNN. As shown in table-2, the ResNet SNN model in ref[27] is equally competitive as the proposed model. The notation is a bit confusing in a few equations. The s in Eq (5) is binary. This should be distinguished from floating-point numbers in Eq (4). But the same symbol R is used for both. The same observation holds for Eq (8)(10)(11).

Questions

The outputs of LIF spiking neurons at all timesteps are used as the inputs to the Transformer. This may be the tested method in [20], but why is this a better idea than using the output at the last timestep? As shown in table-2, the power is directly proportional to the timestep count. So this seems a critical parameter to optimize over. In Eq (12), S_L has the shape TxNxD. So outputs at all timesteps are used in classification head? In Eq (6), the input s has no 2d spatial dimensions. What are the 2d dimensions in Conv2d()?

Rating

7: Accept: Technically solid paper, with high impact on at least one sub-area, or moderate-to-high impact on more than one areas, with good-to-excellent evaluation, resources, reproducibility, and no unaddressed ethical considerations.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

3 good

Presentation

2 fair

Contribution

4 excellent

Limitations

None

Reviewer Lu4B2023-08-20

Thanks for the clarification. I have increased my ratings.

Authorsrebuttal2023-08-21

I sincerely appreciate your constructive comments. But I noticed that you don't seem to be improving the rating of this paper as you said in official comment. I wonder if there was some misunderstanding here, could you please check it again?

Reviewer GiWX7/10 · confidence 2/52023-07-07

Summary

The authors propose a variant of transformer networks with spiking neurons based on the LIF neuron. The submission reformulates the self-attention to use sparse addition and masking, and modifies the residual connections to transmit information in the domain of membrane potentials. They achieve a state of the art result on Imagenet. They present an energy analysis.

Strengths

It increases the amount of binary spike-based computations in the transformer. The experimental results are strong. A small ablation study is performed.

Weaknesses

The explanation for equations 15 and 16 can be improved The explanation of power estimates can be improved.

Questions

Can the authors provide an additional explanation for equations 15 and 16?

Rating

7: Accept: Technically solid paper, with high impact on at least one sub-area, or moderate-to-high impact on more than one areas, with good-to-excellent evaluation, resources, reproducibility, and no unaddressed ethical considerations.

Confidence

2: You are willing to defend your assessment, but it is quite likely that you did not understand the central parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

3 good

Presentation

3 good

Contribution

3 good

Limitations

not much discussed

Reviewer qknk2023-08-13

Thank you for providing detailed responses and conducting additional experiments in your rebuttal. It is evident that SDSA can significantly reduce computational complexity without using MS, while maintaining competitive performance. Moreover, this approach facilitates easy deployment on neuromorphic chips. However, I still hold reservations regarding the use of voltage as output for membrane shortcut, as it does not align with the mechanisms of SNNs. In summary, I am willing to revise my score from 4 to 5.

Authorsrebuttal2023-08-17

Thank you very much for your endorsement, the discussion with you made us rethink this work carefully. We believe this is very helpful for our future work.

Reviewer GiWX2023-08-16

why is the right hand side in eq (16) equal to the right hand side in eq (14) ?

Thank you for writing the explanation, however this still raises doubts: eq 16, rhs is: $SN(Q^i) \cdot SN ( SN(K^i)^\top \odot SN(V^i) ) $ eq 14 rhs is: $ SN ( SN(K^i)^\top \odot SN(Q^i) ) \cdot SN(V^i) $ the hadamard product can be exchanged: $Q_s \otimes K_s \otimes V_s = (Q_s \otimes K_s ) \otimes V_s = Q_s \otimes (K_s \otimes V_s) $, but not when there are thresholding non-linearities applied in between. As far as the reviewer understands, SN is a thresholding operation resulting in 1 or 0. So something needs to be proven to show that $SN ( SUM_c Q_s \otimes K_s ) \otimes SN( V_s) = SN(Q_s) \otimes SN ( SUM_c K_s \otimes V_s) $ This could be due to the fact that the summings are all non-negative, but even then the threshold should be at 1 or below. if the threshold is above 1, then this equality might not hold anymore. Can you please clarify ?

Authorsrebuttal2023-08-16

Eq.(14) and Eq.(15) are functionally equivalent. Eq.(15) and Eq.(16) are mathematically equivalent

Thank you very much for your insightful comments. The expression associated with Eq.(15) is not rigorous. **Eq.(14) and Eq.(15) are indeed not equivalent mathematically, but they are equivalent functionally.** **SDSA-V1.** Given a spike input feature sequence $S \in \mathbb{R}^{T\times N\times D}$, float-point $Q$, $K$, and $V$ in $\mathbb{R}^{T\times N\times D}$ are calculated by three learnable linear matrices, respectively. A spike neuron layer $SN(\cdot)$ follows, converting $Q$, $K$, $V$ into spike tensor $Q_{S}$, $K_{S}$, and $V_{S}$. SDSA-V1 is presented as: $SDSA(Q, K, V)=g(Q_{S}, K_{S})\otimes V_{S}= SN(SUM_{c}(Q_{S} \otimes K_{S})) \otimes V_{S},$ (14) **Since $Q_{S}, K_{S}, V_{S}$ are generated by the same type of function (a linear transformation) from the same input $X$ and there is no softmax in Eq.(14), $Q_{S}, K_{S}, V_{S}$ are no longer Query, Key, Value with clear meaning. Therefore, we can let $K_{S}$ be the Query matrix and $V_{S}$ be the Key matrix.** This is Eq.(15) below: $SDSA(Q, K, V)=Q_{S} \otimes g(K_{S}, V_{S}) = Q_{S} \otimes SN(SUM_{c}(K_{S} \otimes V_{S}))$, (15) **In summary, Eq.(14) and Eq.(15) are functionally equivalent. Eq.(15) and Eq.(16) are mathematically equivalent (please see previous reply).** For rigor, we will revise Lines 177-178 in the main text. Original Lines 177-178: ``Since the Hadamard product among $Q_{S}$, $K_{S}$, and $V_{S}$ in $\mathbb{R}^{N\times D}$ can be exchanged, Eq.(14) can also be written as: $SDSA(Q, K, V)=Q_{S} \otimes g(K_{S}, V_{S}) = Q_{S} \otimes SN(SUM_{c}(K_{S} \otimes V_{S}))$ " Revised Lines 177-178: ``***Since we exploit the Hadamard product and the sum function to calculate the similarity, and $Q_{S}$, $K_{S}$, and $V_{S}$ are generated in exactly the same way, Eq.(14) is functionally equivalent to the following formula***: $SDSA(Q, K, V)=Q_{S} \otimes g(K_{S}, V_{S}) = Q_{S} \otimes SN(SUM_{c}(K_{S} \otimes V_{S}))$ " We would also like to explain to you why we have given Eq.(15) and Eq.(16). A hallmark of linear Transformer[1,2] is that Key matrix and Value matrix are computed first, followed by Query matrix. We want to give readers such a formal intuition that the proposed SDSA is a kind of linear attention. In the code implementation, there is no difference in performance between Eq.(14) and Eq.(15). Thank you again for your careful review and we will make changes accordingly. --- [1] Transformers are RNNs: fast autoregressive transformers with linear attention. In: ICML (2020) [2] Hydra attention: Efficient attention with many heads. In: ECCV (2022)

Reviewer GiWX2023-08-16

thank you for taking the time to explain it. The proposed clarification for the paper that it is functionally equivalent but not mathematically equivalent is a good idea for the paper. The reviewer is happy about it (not only because the reviewer wants to sink into sleep now).

Reviewer 8FkB2023-08-21

Thank you for addressing our questions

Spike Transformer: The authors have addressed our questions with more experimental results. We have raised our score to 7.

Program Chairsdecision2023-09-21

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC