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 useless pipeline buffer between cpu to stage 0 #8484

Merged
merged 3 commits into from
Jun 24, 2022
Merged

Conversation

chengtbf
Copy link
Contributor

移除掉一个过渡设计:

Pipeline 并行下, CPU stage 0 到 GPU stage 0 之间插入过一个 buffer,且这 buffer = stage num * 2。

当时的想法是, cpu copy 到 gpu 的数据,可能被后向消费,如果没有 buffer ,则会阻碍 stage 0 的流水。

但实际情况是,我们一定会给 GPU stage 0 自动插入一个 identity(module 层级已经做好了这个 insert),而后向只可能消费这个 identity ,而不是 copy 到 gpu 的 regst。 而这个 identity 连向 backward 的边,一定会被识别为需要插入 buffer 的边,导致我们反向消费前向 identity 一定可以经过 buffer。 因此 前向 cpu 0 到 gpu 0 不需要再额外插入 buffer。

同时这个还会解决一个 bug,即 : img gpu decoder ,会消费一个 cpu 上的 kTensorBuffer 数据(non POD 类型的,二级指针)。此时如果插入一个 identity buffer,则 buffer copy 这个就会出错。

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

Speed stats:
GPU Name: NVIDIA GeForce GTX 1080 

❌ OneFlow resnet50 time: 129.6ms (= 12956.6ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 145.5ms (= 14545.4ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.12 (= 145.5ms / 129.6ms)

OneFlow resnet50 time: 75.9ms (= 7593.4ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 85.6ms (= 8559.8ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.13 (= 85.6ms / 75.9ms)

OneFlow resnet50 time: 52.1ms (= 10426.9ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 56.3ms (= 11265.8ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.08 (= 56.3ms / 52.1ms)

OneFlow resnet50 time: 38.9ms (= 7781.9ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 43.5ms (= 8691.1ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.12 (= 43.5ms / 38.9ms)

OneFlow resnet50 time: 35.0ms (= 6993.3ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 40.5ms (= 8105.7ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.16 (= 40.5ms / 35.0ms)

OneFlow swin dataloader time: 0.272s (= 54.458s / 200, num_workers=1)
PyTorch swin dataloader time: 0.151s (= 30.121s / 200, num_workers=1)
Relative speed: 0.553 (= 0.151s / 0.272s)

OneFlow swin dataloader time: 0.076s (= 15.154s / 200, num_workers=4)
PyTorch swin dataloader time: 0.042s (= 8.436s / 200, num_workers=4)
Relative speed: 0.557 (= 0.042s / 0.076s)

OneFlow swin dataloader time: 0.040s (= 8.028s / 200, num_workers=8)
PyTorch swin dataloader time: 0.023s (= 4.611s / 200, num_workers=8)
Relative speed: 0.574 (= 0.023s / 0.040s)

❌ OneFlow resnet50 time: 144.9ms (= 14494.7ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 166.2ms (= 16622.6ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.15 (= 166.2ms / 144.9ms)

OneFlow resnet50 time: 95.8ms (= 9575.8ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 123.6ms (= 12364.2ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.29 (= 123.6ms / 95.8ms)

OneFlow resnet50 time: 69.6ms (= 13911.2ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 88.7ms (= 17734.8ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.27 (= 88.7ms / 69.6ms)

OneFlow resnet50 time: 56.2ms (= 11234.8ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 74.7ms (= 14932.0ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.33 (= 74.7ms / 56.2ms)

OneFlow resnet50 time: 51.2ms (= 10239.6ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 73.7ms (= 14743.1ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.44 (= 73.7ms / 51.2ms)

@leaves-zwx
Copy link
Contributor

@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot June 24, 2022 17:47
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot June 24, 2022 20:22
@github-actions
Copy link
Contributor

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

@mergify mergify bot merged commit ca9fd64 into master Jun 24, 2022
@mergify mergify bot deleted the dev_cc_pp branch June 24, 2022 21:43
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