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 lamb optimizer #7389

Merged
merged 14 commits into from
Jan 28, 2022
Merged

add lamb optimizer #7389

merged 14 commits into from
Jan 28, 2022

Conversation

L1aoXingyu
Copy link
Contributor

为 eager 和 graph 增加 lamb optimizer interface

原始公式如下

image

第一步 normalize gradients 可以在 clip grad 中实现。

@L1aoXingyu
Copy link
Contributor Author

image

image

@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#include <memory>
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

python/oneflow/nn/optimizer/lamb.py Show resolved Hide resolved
@L1aoXingyu L1aoXingyu requested a review from wyg1997 January 27, 2022 06:58
stream, n, scale, l1, l2, beta1, beta2, epsilon, weight_decay, learning_rate, scale_by_ptr,
skip_if, reinterpret_cast<const half*>(model_diff), adam_diff, model, m, v, norm_buffer,
beta1_t, beta2_t);
stream, n, scale, l1, l2, beta1, beta2, epsilon, weight_decay, learning_rate_val, do_bias_correction, bias_correction1_val, bias_correction2_val, learning_rate_ptr, bias_correction1_ptr, bias_correction2_ptr, scale_by_ptr,
Copy link
Contributor

Choose a reason for hiding this comment

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

这个 of_format 不会做分行吗?

@github-actions
Copy link
Contributor

Code got formatted by CI. Please request CI again if you still want to have this PR merged. If the PR is from a forked repo, please download the patch files from the GitHub Actions web page and apply them locally.

@L1aoXingyu L1aoXingyu requested review from oneflow-ci-bot and removed request for oneflow-ci-bot January 28, 2022 01:24
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot January 28, 2022 02:15
@github-actions
Copy link
Contributor

CI failed when running job: cuda-misc. PR label automerge has been removed

@oneflow-ci-bot oneflow-ci-bot removed their request for review January 28, 2022 05:00
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot January 28, 2022 08:49
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

✔️ OneFlow resnet50 time: 136.7ms (= 13672.1ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 138.5ms (= 13847.1ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.01 (= 138.5ms / 136.7ms)

✔️ OneFlow resnet50 time: 78.4ms (= 7840.1ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 83.6ms (= 8355.2ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.07 (= 83.6ms / 78.4ms)

OneFlow resnet50 time: 52.4ms (= 10479.3ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 59.1ms (= 11821.5ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.13 (= 59.1ms / 52.4ms)

OneFlow resnet50 time: 39.4ms (= 7883.8ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 43.6ms (= 8728.0ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.11 (= 43.6ms / 39.4ms)

OneFlow resnet50 time: 37.6ms (= 7521.6ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 38.6ms (= 7725.2ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.03 (= 38.6ms / 37.6ms)

✔️ OneFlow resnet50 time: 148.0ms (= 14799.4ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 158.5ms (= 15849.5ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.07 (= 158.5ms / 148.0ms)

OneFlow resnet50 time: 88.9ms (= 8885.5ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 104.8ms (= 10482.0ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.18 (= 104.8ms / 88.9ms)

OneFlow resnet50 time: 67.0ms (= 13390.7ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 76.6ms (= 15320.3ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.14 (= 76.6ms / 67.0ms)

OneFlow resnet50 time: 57.3ms (= 11459.8ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 62.8ms (= 12554.7ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.10 (= 62.8ms / 57.3ms)

OneFlow resnet50 time: 57.3ms (= 11456.9ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 59.6ms (= 11919.6ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.04 (= 59.6ms / 57.3ms)

@jackalcooper jackalcooper merged commit 9f658f0 into master Jan 28, 2022
@jackalcooper jackalcooper deleted the dev_lxy_lambOptim branch January 28, 2022 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants