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

Remove CUDA-only restriction for multi-tensor model updates in optimizer #10564

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ShawnXuan
Copy link
Contributor

This PR removes the CUDA-only restriction in the multi-tensor model update pass within both multi_tensor_model_update.cpp and adamw.py.

By commenting out the device type checks, we allow multi-tensor and fused updates to run on non-CUDA devices as well.

Copy link
Contributor

Copy link
Contributor

Speed stats:
GPU Name: NVIDIA GeForce RTX 3080 Ti 

❌ OneFlow resnet50 time: 43.7ms (= 4368.5ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 57.3ms (= 5731.6ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.31 (= 57.3ms / 43.7ms)

OneFlow resnet50 time: 26.1ms (= 2614.1ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 37.1ms (= 3714.5ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.42 (= 37.1ms / 26.1ms)

OneFlow resnet50 time: 19.0ms (= 3804.2ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 35.5ms (= 7103.5ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.87 (= 35.5ms / 19.0ms)

OneFlow resnet50 time: 17.5ms (= 3501.3ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 32.3ms (= 6456.6ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.84 (= 32.3ms / 17.5ms)

OneFlow resnet50 time: 17.4ms (= 3483.7ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 31.3ms (= 6253.9ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.80 (= 31.3ms / 17.4ms)

OneFlow swin dataloader time: 0.199s (= 39.839s / 200, num_workers=1)
PyTorch swin dataloader time: 0.129s (= 25.762s / 200, num_workers=1)
Relative speed: 0.647 (= 0.129s / 0.199s)

OneFlow swin dataloader time: 0.054s (= 10.725s / 200, num_workers=4)
PyTorch swin dataloader time: 0.033s (= 6.542s / 200, num_workers=4)
Relative speed: 0.610 (= 0.033s / 0.054s)

OneFlow swin dataloader time: 0.030s (= 6.077s / 200, num_workers=8)
PyTorch swin dataloader time: 0.017s (= 3.307s / 200, num_workers=8)
Relative speed: 0.544 (= 0.017s / 0.030s)

❌ OneFlow resnet50 time: 49.6ms (= 4961.7ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 64.0ms (= 6399.1ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.29 (= 64.0ms / 49.6ms)

OneFlow resnet50 time: 36.8ms (= 3680.8ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 45.6ms (= 4562.3ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.24 (= 45.6ms / 36.8ms)

OneFlow resnet50 time: 28.1ms (= 5615.2ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 40.5ms (= 8098.1ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.44 (= 40.5ms / 28.1ms)

OneFlow resnet50 time: 25.1ms (= 5027.7ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 38.4ms (= 7687.6ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.53 (= 38.4ms / 25.1ms)

OneFlow resnet50 time: 24.9ms (= 4981.2ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 37.4ms (= 7476.0ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.50 (= 37.4ms / 24.9ms)

@@ -163,10 +163,6 @@ def __init__(
warnings.warn("Fused Adamw is not supported when amsgrad=True.")
param_group["fused"] = False

if param_group["fused"] and not param.is_cuda:
Copy link
Contributor

Choose a reason for hiding this comment

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

这个去掉,是不是cpu device会有影响,是否需要用param.is_cpu判断一下?

Copy link
Contributor

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

Copy link
Contributor

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

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