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

Make Dropout a no-op when p=0.0 #259

Merged
merged 2 commits into from
Sep 12, 2023
Merged

Make Dropout a no-op when p=0.0 #259

merged 2 commits into from
Sep 12, 2023

Conversation

epwalsh
Copy link
Member

@epwalsh epwalsh commented Sep 6, 2023

This is low-hanging fruit that got overlooked until now. It turns out there is a little overhead with nn.Dropout even when p=0.0.
To avoid that overhead, this PR implements our own subclass of nn.Dropout that just overrides the .forward() method to return the input as-is when self.p == 0.0.

With a tiny model on A100 GPUs, this slightly increases throughput from ~50,622 tokens/sec to ~50,722 tokens/sec. I expect we'll see a greater gain for larger models.

@epwalsh epwalsh requested a review from dirkgr September 6, 2023 20:13
@epwalsh epwalsh merged commit a49f4ec into main Sep 12, 2023
10 checks passed
@epwalsh epwalsh deleted the petew/dropout-passthrough branch September 12, 2023 19:17
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.

None yet

2 participants