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

Add GMLP #339

Merged
merged 5 commits into from
May 19, 2021
Merged

Add GMLP #339

merged 5 commits into from
May 19, 2021

Conversation

sdtblck
Copy link
Contributor

@sdtblck sdtblck commented May 19, 2021

You'll need to update to the latest version of deepspeed (specified in requirements.txt)

@sdtblck sdtblck requested a review from a team as a code owner May 19, 2021 19:38
@sdtblck sdtblck enabled auto-merge (squash) May 19, 2021 19:39
Copy link
Contributor

@lucidrains lucidrains left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 👏 👏

if self.causal:
mask = torch.ones(weight.shape[:2], device=gate.device).triu_(1).bool()
weight = weight.masked_fill(mask, 0.)
gate = F.linear(gate.transpose(2, 1), weight, self.proj.bias).transpose(2, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

res, gate = x.chunk(2, dim=-1) # split along dim
gate = self.norm(gate)
weight = self.proj.weight
if self.causal:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added a https://github.com/lucidrains/g-mlp-pytorch/blob/main/g_mlp_pytorch/g_mlp_pytorch.py#L89 so it wouldn't break if you give it a sequence length < max sequence length - not sure if you can use it or not

@sdtblck sdtblck merged commit c33a2cf into main May 19, 2021
@sdtblck sdtblck deleted the gmlp branch May 19, 2021 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants