Rewrite scan-based GRU based on nn.GRU#8914
Merged
tengyifei merged 2 commits intopytorch:masterfrom Apr 4, 2025
Merged
Conversation
Collaborator
Author
Collaborator
Author
|
@tengyifei please run the test workflows and take a look. thanks! |
Collaborator
|
Hi yes, just did. Thank you for the great work. I'll try to review it later today. |
Collaborator
Author
|
it seems that the failed test is not related to this change. should i pull the latest commits and run the tests again? |
tengyifei
approved these changes
Apr 4, 2025
Collaborator
Sorry about that. Our GPU checks are just being turned back on and they have a lot of flakes. You may ignore unrelated errors. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a preparation step for #8860. specifically, this PR modified scan-based GRU implementation to derive from standard pytorch GRU implementation. It reuses all the components of the standard pytorch GRU implementation except the
forwardfunction. Reusing the standard GRU implementation makes the scan-based GRU weight key-compatible, enabling it to load checkpoints of the standard GRU.The standard pytorch GRU implementation is similar to the scan-based GRU implementation except that it directly add parameters to module instead of using a
ParameterList. It also uses the common performance optimization that concatenates the gate matrices into one matrix. For details on how it arranges and initialize the parameters, see: https://github.com/pytorch/pytorch/blob/340beb7f7cfe9c3c248819d2aae4170b8def3a8c/torch/nn/modules/rnn.py#L158-L201Currently, setting
batch_first,bidirectional, andproj_sizeare disabled. i will either make them work or allow them to fallback to the standard implementation in the following PRs.