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

Invoke hipify from op builder for JIT extension builds #1807

Merged

Conversation

jithunnair-amd
Copy link
Contributor

@jithunnair-amd jithunnair-amd commented Mar 3, 2022

cc @jeffra

@jithunnair-amd
Copy link
Contributor Author

jithunnair-amd commented Mar 3, 2022

Here's all the hipified files that get copied to the DeepSpeed install directory with the updated manifest:

root@ff499528957c:/data/DeepSpeed# find /opt/conda/lib/python3.8/site-packages/deepspeed -name \*hip\*
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/adagrad/cpu_adagrad_hip.cpp
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/common/custom_hip_kernel.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/quantization/quantizer.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/quantization/pt_binding_hip.cpp
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/lamb/fused_lamb_hip_kernel.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/softmax_kernels.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/gelu_kernels.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/general_kernels.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/transform_kernels.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/ds_transformer_hip.cpp
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/normalize_kernels.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/cublas_wrappers.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/inference/csrc/normalize.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/inference/csrc/apply_rotary_pos_emb.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/inference/csrc/dequantize.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/inference/csrc/pt_binding_hip.cpp
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/inference/csrc/gelu.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/inference/csrc/softmax.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/inference/includes/cublas_wrappers_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/inference/includes/custom_hip_layers.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/inference/includes/context_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/transformer/dropout_kernels.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/cublas_wrappers_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/patch/hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/patch/hip/hcc_detail/hip_cooperative_groups_helper.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/patch/hip/hcc_detail/hip_cooperative_groups.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/general_kernels_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/custom_hip_layers.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/dropout_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/Timer_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/softmax_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/context_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/cpu_adam_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/normalize_layer_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/gelu_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/feed_forward_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/type_shim_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/strided_batch_gemm_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/gemm_test_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/cpu_adagrad_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/ds_transformer_hip.h
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/adam/multi_tensor_adam.hip
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/adam/multi_tensor_apply_hip.cuh
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/adam/cpu_adam_hip.cpp

@jithunnair-amd
Copy link
Contributor Author

This is the testcase I used:

import deepspeed
deepspeed.ops.op_builder.FusedAdamBuilder().load()
deepspeed.ops.op_builder.CPUAdamBuilder().load()
deepspeed.ops.op_builder.FusedLambBuilder().load()
deepspeed.ops.op_builder.TransformerBuilder().load()
deepspeed.ops.op_builder.StochasticTransformerBuilder().load()
deepspeed.ops.op_builder.UtilsBuilder().load()

Log file: DeepSpeed_JIT_build.log

The only files that seem to get hipified afresh are:

fpadmin@rocm-framework-12:~$ grep '\[ok]' ~/tmp/DeepSpeed_JIT_build.log
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/quantizer.h -> /opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/quantizer_hip.h [ok]
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/patch/hip/hcc_detail/hip_cooperative_groups_helper.h -> /opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/patch/hip/hcc_detail/hip_cooperative_groups_helper_hip.h [ok]
/opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/patch/hip/hcc_detail/hip_cooperative_groups.h -> /opt/conda/lib/python3.8/site-packages/deepspeed/ops/csrc/includes/patch/hip/hcc_detail/hip_cooperative_groups_hip.h [ok]

The quantizer.h seems to be not included by any of the DeepSpeed source files, that's why it didn't get hipified originally.
As for the patched cooperative groups headers, they are never meant to be used from the patch dir anyway, instead being copied to the ROCm install path during DeepSpeed build.
In other words, even if these files run into a Permission Denied error, it shouldn't affect the user.

@jeffra jeffra changed the base branch from staging-amd-v4 to master March 4, 2022 00:08
@jeffra jeffra changed the base branch from master to staging-amd-v4 March 4, 2022 00:08
@jithunnair-amd jithunnair-amd force-pushed the invoke_hipify_from_op_builder branch from 086e270 to 242fce1 Compare March 6, 2022 04:16
@jithunnair-amd jithunnair-amd changed the base branch from staging-amd-v4 to master March 6, 2022 04:17
@jithunnair-amd
Copy link
Contributor Author

@jeffra Rebased on master

Copy link
Collaborator

@jeffra jeffra left a comment

Choose a reason for hiding this comment

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

Thank you @jithunnair-amd!

@jeffra jeffra enabled auto-merge (squash) March 7, 2022 18:50
@jeffra jeffra merged commit 350d74c into microsoft:master Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants