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

Autograd.grad support allow_unused argument #10251

Merged
merged 2 commits into from
May 11, 2023

Conversation

pingzhuu
Copy link
Contributor

No description provided.

)
return tuple([Tensor(x) for x in in_grads])
return tuple([x for x in in_grads])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

allow_unused=True 时Tensor(None) 会返回 nan

@github-actions
Copy link
Contributor

View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/10251/

@github-actions
Copy link
Contributor

Speed stats:
GPU Name: NVIDIA GeForce RTX 3080 Ti 

❌ OneFlow resnet50 time: 43.5ms (= 4352.6ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 61.6ms (= 6164.6ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.42 (= 61.6ms / 43.5ms)

OneFlow resnet50 time: 26.4ms (= 2637.3ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 37.7ms (= 3774.7ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.43 (= 37.7ms / 26.4ms)

OneFlow resnet50 time: 19.5ms (= 3904.2ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 36.6ms (= 7324.5ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.88 (= 36.6ms / 19.5ms)

OneFlow resnet50 time: 16.8ms (= 3353.6ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 30.7ms (= 6146.6ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.83 (= 30.7ms / 16.8ms)

OneFlow resnet50 time: 17.2ms (= 3445.7ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 28.7ms (= 5743.3ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.67 (= 28.7ms / 17.2ms)

OneFlow swin dataloader time: 0.202s (= 40.340s / 200, num_workers=1)
PyTorch swin dataloader time: 0.129s (= 25.703s / 200, num_workers=1)
Relative speed: 0.637 (= 0.129s / 0.202s)

OneFlow swin dataloader time: 0.056s (= 11.126s / 200, num_workers=4)
PyTorch swin dataloader time: 0.032s (= 6.498s / 200, num_workers=4)
Relative speed: 0.584 (= 0.032s / 0.056s)

OneFlow swin dataloader time: 0.029s (= 5.874s / 200, num_workers=8)
PyTorch swin dataloader time: 0.016s (= 3.296s / 200, num_workers=8)
Relative speed: 0.561 (= 0.016s / 0.029s)

❌ OneFlow resnet50 time: 47.4ms (= 4743.0ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 64.5ms (= 6448.0ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.36 (= 64.5ms / 47.4ms)

OneFlow resnet50 time: 31.0ms (= 3101.3ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 44.1ms (= 4412.4ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.42 (= 44.1ms / 31.0ms)

OneFlow resnet50 time: 24.3ms (= 4853.7ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 41.7ms (= 8345.1ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.72 (= 41.7ms / 24.3ms)

OneFlow resnet50 time: 22.5ms (= 4494.9ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 38.4ms (= 7687.7ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.71 (= 38.4ms / 22.5ms)

OneFlow resnet50 time: 21.4ms (= 4279.2ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 34.3ms (= 6851.5ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.60 (= 34.3ms / 21.4ms)

Copy link
Contributor

@levi131 levi131 left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify mergify bot merged commit f6de3a1 into master May 11, 2023
@mergify mergify bot deleted the autograd_support_allow_unused branch May 11, 2023 07:17
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.

3 participants