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

Rename straighten algo interface #8495

Merged
merged 10 commits into from
Jun 28, 2022
Merged

Conversation

wyg1997
Copy link
Contributor

@wyg1997 wyg1997 commented Jun 27, 2022

根据讨论: https://github.com/Oneflow-Inc/OneTeam/issues/1509#issuecomment-1166820859 拉直算法默认并闭,并重命名接口: disable_straighten_algorithm -> enable_straighten_algorithm

Co-authored-by: Yipeng Li <jamesonli1313@gmail.com>
Copy link
Contributor

@Yipeng1994 Yipeng1994 left a comment

Choose a reason for hiding this comment

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

Very good

@@ -278,15 +278,14 @@ def build(self, x):
"""
self.proto.cudnn_conv_heuristic_search_algo = mode

def disable_straighten_algorithm(self, mode: bool = False):
r""" Whether we disable the straighten algorithm.
def enable_straighten_algorithm(self, mode: bool = True):
Copy link
Contributor

@strint strint Jun 27, 2022

Choose a reason for hiding this comment

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

这个名字最好再精确一点,“拉直算法“作为代号ok,enable_dfs_op_schedule 是不是会更好一点?

Copy link
Contributor

Choose a reason for hiding this comment

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

严格来说拉直不是dfs,

拉直算法不是纯dps,每有一次传输拉直就会从现有计算里面找节点来执行,这时候跑的是已经出现的节点,也就是深度小的。
可以说拉直在传输节点上是bfs,在传输节点间是dfs。
而且5_3_5只是拉直的其中一种模式,也可以选择纯粹的先进先出模式排序比如2_0_1,这时候也是bfs

@wyg1997 wyg1997 requested review from oneflow-ci-bot and removed request for oneflow-ci-bot June 28, 2022 09:41
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: NVIDIA GeForce GTX 1080 

❌ OneFlow resnet50 time: 129.2ms (= 12916.8ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 144.2ms (= 14417.8ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.12 (= 144.2ms / 129.2ms)

OneFlow resnet50 time: 75.7ms (= 7574.4ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 85.1ms (= 8514.7ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.12 (= 85.1ms / 75.7ms)

OneFlow resnet50 time: 49.9ms (= 9984.9ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 62.2ms (= 12433.8ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.25 (= 62.2ms / 49.9ms)

OneFlow resnet50 time: 38.1ms (= 7614.0ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 41.6ms (= 8311.2ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.09 (= 41.6ms / 38.1ms)

OneFlow resnet50 time: 37.2ms (= 7437.1ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 38.2ms (= 7639.6ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.03 (= 38.2ms / 37.2ms)

OneFlow swin dataloader time: 0.260s (= 52.070s / 200, num_workers=1)
PyTorch swin dataloader time: 0.147s (= 29.495s / 200, num_workers=1)
Relative speed: 0.566 (= 0.147s / 0.260s)

OneFlow swin dataloader time: 0.074s (= 14.720s / 200, num_workers=4)
PyTorch swin dataloader time: 0.041s (= 8.203s / 200, num_workers=4)
Relative speed: 0.557 (= 0.041s / 0.074s)

OneFlow swin dataloader time: 0.039s (= 7.814s / 200, num_workers=8)
PyTorch swin dataloader time: 0.022s (= 4.446s / 200, num_workers=8)
Relative speed: 0.569 (= 0.022s / 0.039s)

❌ OneFlow resnet50 time: 144.9ms (= 14486.9ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 168.5ms (= 16850.2ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.16 (= 168.5ms / 144.9ms)

OneFlow resnet50 time: 93.9ms (= 9387.2ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 119.3ms (= 11932.8ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.27 (= 119.3ms / 93.9ms)

OneFlow resnet50 time: 68.9ms (= 13775.2ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 89.4ms (= 17885.1ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.30 (= 89.4ms / 68.9ms)

OneFlow resnet50 time: 56.3ms (= 11265.5ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 77.4ms (= 15486.6ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.37 (= 77.4ms / 56.3ms)

OneFlow resnet50 time: 51.5ms (= 10309.8ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 79.3ms (= 15857.2ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.54 (= 79.3ms / 51.5ms)

@mergify mergify bot merged commit 2aaa2a9 into master Jun 28, 2022
@mergify mergify bot deleted the rename-straighten_algo_interface branch June 28, 2022 12:53
@Flowingsun007
Copy link
Contributor

这个pr合并了,libai那边应该也需要同步更改一下相应的参数:disable_straighten_algorithm -> enable_straighten_algorithm @wyg1997 @CPFLAME

@wyg1997
Copy link
Contributor Author

wyg1997 commented Jun 29, 2022

disable_straighten_algorithm

libai main分支有用这个接口吗?我好像没搜到?

@CPFLAME
Copy link

CPFLAME commented Jun 29, 2022

这个在 libai_bench_merge_main 和 libai_bench 分支下有

应该把

self.config.disable_straighten_algorithm(True)

修改为

self.config.enable_straighten_algorithm(False)

是么?
@Flowingsun007

@wyg1997
Copy link
Contributor Author

wyg1997 commented Jun 29, 2022

这个在 libai_bench_merge_main 和 libai_bench 分支下有

应该把

self.config.disable_straighten_algorithm(True)

修改为

self.config.enable_straighten_algorithm(False)

self.config.disable_straighten_algorithm(True) 这行可以直接删掉,因为现在默认这个算法是不开启的,在想开启的地方加上 self.config.enable_straighten_algorithm(True) 就可以

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.

6 participants