Make learning rate tensor (Backend) - reland#3332
Closed
spcyppt wants to merge 1 commit into
Closed
Conversation
Summary: X-link: facebookresearch/FBGEMM#428 Context problem from Microve: pt2 adds a guard on the float inputs, and if it is changed, it will be recompiled. Because compilation itself is expensive, each recompilation could take several minutes to >20 mins. In e2e training, there is a warm up stage where the learning rate is gradually increased to a pre-defined value e.g., say the final learning rate is 0.02 and the warm step is 10k, learning rate will increase from 0 to 0.02 with a step 0.00002 (each iteration, it increases by 0.00002). So, if we let pt2 recompile, it will recompile 10k times. For a tensor, the guard is only on its shape; if its shape remains the same, it will not trigger recompilation. ---- To prevent recompilation, we change learning rate from float to tensor. This, however, affects existing TBE frontend and backend. We will enable learning rate being tensor through the new unified interface (D50481991). For backward compatibility, the old interface (V1), i.e., `split_embedding_codegen_lookup_{{ optimizer }}_function` and `split_embedding_codegen_lookup_{{ optimizer }}_function_cpu` will continue to take learning rate as `float`. This diff - make learning rate tensor in codegen - keep learning rate as float for kernel arguments - create optional argument to OptimizerArgs for v1 signature - make old interface takes tensor as float and converts to tensor before passing to autograd - converts learning rate back to float before passing to kernels Old interface: ``` python -> C++ lookup -> autograd -> backend -> kernel lr type: (float) (float) (tensor) (tensor) (float) ``` PT2 unified interface (D50481991): ``` python -> C++ lookup -> autograd -> backend -> kernel lr type: (tensor) (tensor) (tensor) (tensor) (float) ``` Differential Revision: D65511904
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D65511904 |
❌ Deploy Preview for pytorch-fbgemm-docs failed.
|
Contributor
|
This pull request has been merged in 54f9a9b. |
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.
Summary:
X-link: https://github.com/facebookresearch/FBGEMM/pull/428
Context problem from Microve:
pt2 adds a guard on the float inputs, and if it is changed, it will be recompiled. Because compilation itself is expensive, each recompilation could take several minutes to >20 mins.
In e2e training, there is a warm up stage where the learning rate is gradually increased to a pre-defined value
e.g., say the final learning rate is 0.02 and the warm step is 10k, learning rate will increase from 0 to 0.02 with a step 0.00002 (each iteration, it increases by 0.00002). So, if we let pt2 recompile, it will recompile 10k times.
For a tensor, the guard is only on its shape; if its shape remains the same, it will not trigger recompilation.
To prevent recompilation, we change learning rate from float to tensor.
This, however, affects existing TBE frontend and backend.
We will enable learning rate being tensor through the new unified interface (D50481991).
For backward compatibility, the old interface (V1), i.e.,
split_embedding_codegen_lookup_{{ optimizer }}_functionandsplit_embedding_codegen_lookup_{{ optimizer }}_function_cpuwill continue to take learning rate asfloat.This diff
Old interface:
PT2 unified interface (D50481991):
Differential Revision: D65511904