Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiGLU naming of projection matrices #170

Closed
le1nux opened this issue Jul 2, 2024 · 2 comments
Closed

SwiGLU naming of projection matrices #170

le1nux opened this issue Jul 2, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@le1nux
Copy link
Member

le1nux commented Jul 2, 2024

The current SwiGLU implementation defines the projection matrice names, different from the original paper (https://arxiv.org/pdf/2002.05202).
We should stick to the W, V, W_2 names. The projection name c_proj in SwiGLU has the same name as a projection in GeLU already having lead to side-effects for weight initialisation (see comments in PR #168 )

https://github.com/Modalities/modalities/blob/f810fcce978e2f4fc577edf337835b6f4afa8aa9/src/modalities/models/model.py#L30C6-L45C10

class SwiGLU(nn.Module):
    def __init__(self, n_embd: int, bias: bool):
        super().__init__()

        hidden_dim = SwiGLU._get_hidden_dim(n_embd)

        self.c_fc = nn.Linear(
            in_features=n_embd,
            out_features=hidden_dim,
            bias=bias,
        )
        self.silu = nn.SiLU()
        self.c_proj = nn.Linear(
            in_features=n_embd,
            out_features=hidden_dim,
            bias=bias,
        )
        self.out_proj = nn.Linear(
            in_features=hidden_dim,
            out_features=n_embd,
            bias=bias,
        )
@le1nux le1nux added the enhancement New feature or request label Jul 2, 2024
@le1nux le1nux self-assigned this Jul 2, 2024
@le1nux
Copy link
Member Author

le1nux commented Jul 10, 2024

We also need to add the SwiGLU layers to the parameters filters for weight initialization,

@le1nux
Copy link
Member Author

le1nux commented Jul 10, 2024

fixed in 2de5ab4 of PR #141

@le1nux le1nux closed this as completed Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant