Skip to content

[Bug Report] Layer norm folding not properly implemented for BertBlock #509

Description

@soniajoseph

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomplexity-moderateModerately complicated issues for people who have intermediate experience with the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions