Describe the bug
The layer norm folding is currently only implemented for the default TransformerBlock. If you use BertBlock (the layernorm is after the attention and mlp layers, not before), then the LayerNorm still gets folded into W_Q, W_K, and W_V, which is incorrect.
I believe the LayerNorm should instead be folded into W_O for attention and fc2 for the MLP but please check this.
Additional context
Discovered the bug when adapting the repo to CLIP. Many implementations of CLIP use BertBlock, not TransformerBlock.
Checklist
- [X ] I have checked that there is no similar issue in the repo (required)
Describe the bug
The layer norm folding is currently only implemented for the default TransformerBlock. If you use BertBlock (the layernorm is after the attention and mlp layers, not before), then the LayerNorm still gets folded into W_Q, W_K, and W_V, which is incorrect.
I believe the LayerNorm should instead be folded into W_O for attention and fc2 for the MLP but please check this.
Additional context
Discovered the bug when adapting the repo to CLIP. Many implementations of CLIP use BertBlock, not TransformerBlock.
Checklist