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

skip rms norm #10036

Merged
merged 7 commits into from
Mar 28, 2023
Merged

skip rms norm #10036

merged 7 commits into from
Mar 28, 2023

Conversation

zobinHuang
Copy link
Contributor

No description provided.


@unittest.skipIf(os.getenv("ONEFLOW_TEST_CPU_ONLY"), "only test cpu cases")
@flow.unittest.skip_unless_1n1d()
class TestSkipLayerNorm(flow.unittest.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

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

RMS?

@@ -6959,6 +6959,28 @@ def OneFlow_RmsNormGradOp : OneFlow_BaseOp<"rms_norm_grad", [NoSideEffect, Decla
let has_data_type_infer_fn = 1;
}

def OneFlow_SkipRmsNormOp : OneFlow_BaseOp<"skip_rms_norm", [NoSideEffect, DeclareOpInterfaceMethods<UserOpCompatibleInterface>]> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

AttrSizedOperandSegments

let attrs = (ins
ShapeAttr:$normalized_shape,
DefaultValuedAttr<F32Attr, "0.00001">:$epsilon,
DefaultValuedAttr<F32Attr, "0.00001">:$alpha
Copy link
Collaborator

Choose a reason for hiding this comment

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

默认值不合理,同时把skip_layer_norm的默认值也处理一下

@liujuncheng liujuncheng changed the title finish dev and test skip rms norm Mar 27, 2023
@liujuncheng liujuncheng enabled auto-merge (squash) March 28, 2023 03:55
@github-actions
Copy link
Contributor

Speed stats:

@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

❌ OneFlow resnet50 time: 141.0ms (= 14100.7ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 143.2ms (= 14321.1ms / 100, input_shape=[16, 3, 224, 224])
❌ Relative speed: 1.02 (= 143.2ms / 141.0ms)

OneFlow resnet50 time: 81.6ms (= 8162.9ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 88.6ms (= 8864.7ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.09 (= 88.6ms / 81.6ms)

OneFlow resnet50 time: 50.9ms (= 10172.5ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 56.1ms (= 11221.9ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.10 (= 56.1ms / 50.9ms)

OneFlow resnet50 time: 34.5ms (= 6892.5ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 41.0ms (= 8204.7ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.19 (= 41.0ms / 34.5ms)

OneFlow resnet50 time: 25.9ms (= 5170.5ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 39.9ms (= 7975.0ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.54 (= 39.9ms / 25.9ms)

OneFlow swin dataloader time: 0.235s (= 47.056s / 200, num_workers=1)
PyTorch swin dataloader time: 0.152s (= 30.359s / 200, num_workers=1)
Relative speed: 0.645 (= 0.152s / 0.235s)

OneFlow swin dataloader time: 0.067s (= 13.425s / 200, num_workers=4)
PyTorch swin dataloader time: 0.041s (= 8.162s / 200, num_workers=4)
Relative speed: 0.608 (= 0.041s / 0.067s)

OneFlow swin dataloader time: 0.048s (= 9.652s / 200, num_workers=8)
PyTorch swin dataloader time: 0.023s (= 4.615s / 200, num_workers=8)
Relative speed: 0.478 (= 0.023s / 0.048s)

❌ OneFlow resnet50 time: 153.3ms (= 15325.8ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 166.8ms (= 16677.0ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
❌ Relative speed: 1.09 (= 166.8ms / 153.3ms)

OneFlow resnet50 time: 92.7ms (= 9270.6ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 104.2ms (= 10420.4ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.12 (= 104.2ms / 92.7ms)

OneFlow resnet50 time: 60.4ms (= 12078.3ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 81.8ms (= 16352.5ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.35 (= 81.8ms / 60.4ms)

OneFlow resnet50 time: 43.4ms (= 8686.2ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 70.1ms (= 14020.5ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.61 (= 70.1ms / 43.4ms)

OneFlow resnet50 time: 36.9ms (= 7372.7ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 68.6ms (= 13720.3ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.86 (= 68.6ms / 36.9ms)

@github-actions
Copy link
Contributor

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

@liujuncheng liujuncheng merged commit 47db142 into master Mar 28, 2023
@liujuncheng liujuncheng deleted the skip_rms_norm branch March 28, 2023 15:45
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