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

Split axis according to grouped axises #8919

Merged
merged 24 commits into from
Aug 20, 2022
Merged

Split axis according to grouped axises #8919

merged 24 commits into from
Aug 20, 2022

Conversation

Yipeng1994
Copy link
Contributor

@Yipeng1994 Yipeng1994 commented Aug 15, 2022

The current algorithm has a bug under such situation:
In shape: (49, 49, 24)
Out shape: (2401, 24)
The old algorithm would allow {in: S0, out: S0} on 2 GPUs since 24 is divisible by 2.
However, on GPU 0,
In physical shape: (25, 49, 24)
Out physical shape: (1201, 24)
It would cause a bug: Check failed: (out_shape->elem_cnt()) == (in_shape.elem_cnt()) (28824 vs 29400)
Similar case on GPU 1.

This algorithm fixes this bug.

With these reasonable SBP candidates, the throughput of auto parallel would increase by 50%.

@chengtbf
Copy link
Contributor

The current algorithm has a bug under such situation: In shape: (49, 49, 24) Out shape: (2401, 24) The old algorithm would allow {in: S0, out: S0} on 2 GPUs since 24 is divisible by 2. However, on GPU 0, In physical shape: (25, 49, 24) Out physical shape: (1201, 24) It would cause a bug: Check failed: (out_shape->elem_cnt()) == (in_shape.elem_cnt()) (28824 vs 29400) Similar case on GPU 1.

This algorithm fixes this bug.

With these reasonable SBP candidates, the throughput of auto parallel would increase by 50%.

这个 case 需要加到 单测里。

Copy link
Contributor

@wyg1997 wyg1997 left a comment

Choose a reason for hiding this comment

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

再补充一下单测就可以了,我没有问题了

@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

✔️ OneFlow resnet50 time: 128.4ms (= 12836.2ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 141.3ms (= 14132.7ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.10 (= 141.3ms / 128.4ms)

OneFlow resnet50 time: 75.2ms (= 7521.5ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 84.7ms (= 8472.1ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.13 (= 84.7ms / 75.2ms)

OneFlow resnet50 time: 48.2ms (= 9645.8ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 64.8ms (= 12952.6ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.34 (= 64.8ms / 48.2ms)

OneFlow resnet50 time: 35.7ms (= 7146.0ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 44.0ms (= 8795.5ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.23 (= 44.0ms / 35.7ms)

OneFlow resnet50 time: 28.1ms (= 5622.6ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 37.0ms (= 7404.1ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.32 (= 37.0ms / 28.1ms)

OneFlow swin dataloader time: 0.266s (= 53.106s / 200, num_workers=1)
PyTorch swin dataloader time: 0.149s (= 29.867s / 200, num_workers=1)
Relative speed: 0.562 (= 0.149s / 0.266s)

OneFlow swin dataloader time: 0.071s (= 14.150s / 200, num_workers=4)
PyTorch swin dataloader time: 0.041s (= 8.192s / 200, num_workers=4)
Relative speed: 0.579 (= 0.041s / 0.071s)

OneFlow swin dataloader time: 0.040s (= 7.942s / 200, num_workers=8)
PyTorch swin dataloader time: 0.022s (= 4.449s / 200, num_workers=8)
Relative speed: 0.560 (= 0.022s / 0.040s)

❌ OneFlow resnet50 time: 136.4ms (= 13637.3ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 161.4ms (= 16135.1ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.18 (= 161.4ms / 136.4ms)

OneFlow resnet50 time: 84.5ms (= 8446.2ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 102.2ms (= 10222.0ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.21 (= 102.2ms / 84.5ms)

OneFlow resnet50 time: 57.7ms (= 11534.5ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 78.3ms (= 15652.4ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.36 (= 78.3ms / 57.7ms)

OneFlow resnet50 time: 44.9ms (= 8988.9ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 70.4ms (= 14078.9ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.57 (= 70.4ms / 44.9ms)

OneFlow resnet50 time: 38.8ms (= 7766.5ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 68.7ms (= 13741.2ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.77 (= 68.7ms / 38.8ms)

@Yipeng1994 Yipeng1994 requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 16, 2022 16:17
@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

Speed stats:

@Yipeng1994 Yipeng1994 requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 18, 2022 09:22
@github-actions
Copy link
Contributor

Speed stats:

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

✔️ OneFlow resnet50 time: 128.3ms (= 12831.8ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 141.3ms (= 14129.6ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.10 (= 141.3ms / 128.3ms)

OneFlow resnet50 time: 75.2ms (= 7522.1ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 83.6ms (= 8364.6ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.11 (= 83.6ms / 75.2ms)

OneFlow resnet50 time: 48.4ms (= 9675.8ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 57.1ms (= 11415.7ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.18 (= 57.1ms / 48.4ms)

OneFlow resnet50 time: 36.2ms (= 7241.5ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 41.0ms (= 8194.9ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.13 (= 41.0ms / 36.2ms)

OneFlow resnet50 time: 28.2ms (= 5646.2ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 38.3ms (= 7655.5ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.36 (= 38.3ms / 28.2ms)

OneFlow swin dataloader time: 0.263s (= 52.501s / 200, num_workers=1)
PyTorch swin dataloader time: 0.150s (= 29.911s / 200, num_workers=1)
Relative speed: 0.570 (= 0.150s / 0.263s)

OneFlow swin dataloader time: 0.070s (= 14.019s / 200, num_workers=4)
PyTorch swin dataloader time: 0.042s (= 8.433s / 200, num_workers=4)
Relative speed: 0.602 (= 0.042s / 0.070s)

OneFlow swin dataloader time: 0.040s (= 7.910s / 200, num_workers=8)
PyTorch swin dataloader time: 0.022s (= 4.363s / 200, num_workers=8)
Relative speed: 0.552 (= 0.022s / 0.040s)

❌ OneFlow resnet50 time: 136.6ms (= 13659.1ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 162.4ms (= 16237.2ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.19 (= 162.4ms / 136.6ms)

OneFlow resnet50 time: 84.9ms (= 8491.8ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 109.9ms (= 10990.9ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.29 (= 109.9ms / 84.9ms)

OneFlow resnet50 time: 57.8ms (= 11569.9ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 79.3ms (= 15863.2ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.37 (= 79.3ms / 57.8ms)

OneFlow resnet50 time: 45.5ms (= 9093.7ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 69.8ms (= 13966.0ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.54 (= 69.8ms / 45.5ms)

OneFlow resnet50 time: 39.1ms (= 7817.0ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 69.8ms (= 13962.1ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.79 (= 69.8ms / 39.1ms)

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

Speed stats:

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

✔️ OneFlow resnet50 time: 128.5ms (= 12847.8ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 142.5ms (= 14253.3ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.11 (= 142.5ms / 128.5ms)

OneFlow resnet50 time: 75.5ms (= 7547.8ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 84.9ms (= 8493.3ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.13 (= 84.9ms / 75.5ms)

OneFlow resnet50 time: 49.2ms (= 9848.3ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 54.5ms (= 10890.1ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.11 (= 54.5ms / 49.2ms)

OneFlow resnet50 time: 36.5ms (= 7303.3ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 46.4ms (= 9281.5ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.27 (= 46.4ms / 36.5ms)

OneFlow resnet50 time: 28.7ms (= 5746.1ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 45.4ms (= 9079.4ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.58 (= 45.4ms / 28.7ms)

OneFlow swin dataloader time: 0.269s (= 53.811s / 200, num_workers=1)
PyTorch swin dataloader time: 0.151s (= 30.181s / 200, num_workers=1)
Relative speed: 0.561 (= 0.151s / 0.269s)

OneFlow swin dataloader time: 0.074s (= 14.713s / 200, num_workers=4)
PyTorch swin dataloader time: 0.041s (= 8.248s / 200, num_workers=4)
Relative speed: 0.561 (= 0.041s / 0.074s)

OneFlow swin dataloader time: 0.060s (= 12.078s / 200, num_workers=8)
PyTorch swin dataloader time: 0.023s (= 4.507s / 200, num_workers=8)
Relative speed: 0.373 (= 0.023s / 0.060s)

❌ OneFlow resnet50 time: 136.9ms (= 13686.5ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 162.3ms (= 16228.2ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.19 (= 162.3ms / 136.9ms)

OneFlow resnet50 time: 86.1ms (= 8612.0ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 102.7ms (= 10272.5ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.19 (= 102.7ms / 86.1ms)

OneFlow resnet50 time: 58.3ms (= 11663.1ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 78.4ms (= 15684.7ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.34 (= 78.4ms / 58.3ms)

OneFlow resnet50 time: 46.1ms (= 9210.8ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 70.5ms (= 14107.4ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.53 (= 70.5ms / 46.1ms)

OneFlow resnet50 time: 39.2ms (= 7835.6ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 68.8ms (= 13759.0ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.76 (= 68.8ms / 39.2ms)

@mergify mergify bot merged commit 4956899 into master Aug 20, 2022
@mergify mergify bot deleted the fix-reshape_sbp-bug branch August 20, 2022 12:14
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