forked from pytorch/xla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build with BladeDISC (#8) * [to #53687860] feat: DISC client header, implement DISCComputation and DISCData POC implement in : https://code.alibaba-inc.com/torchx/xla/codereview/14984824 Link: https://code.alibaba-inc.com/torchx/xla/codereview/14987956 * Disc computation (#2) Support Disc as backend Co-authored-by: yancey.yx <[email protected]> Co-authored-by: wangang.wa <[email protected]> * add bazel flag to disable disc backend (#23) * add flag to disable disc backend in bazel workspace * support disc debug mode to dump mhlo and logs (#25) support disc backend debug mode to dump DISC compilation logs * support flash attention in disc (pytorch#34) * fix disc flag when complie python (pytorch#39) * fix bazel flag when complie python * fix lint. * support bf16 on disc backend (pytorch#40) add float-norm pass to support bf16 amp training * Support Flash Attention 2.5.6 for disc backend (#4) * fix build failed with NCCL (#5) * fix build failed on nccl * using nccl hdrs * Use the value of DISC_DEVICE as the device type of disc backend (#8) * change the device type of disc to cuda to make amp work properly * Use the value of DISC_DEVICE as the device type of disc backend * disable compilation of DISC by default (#15) --------- Co-authored-by: Yan Xu <[email protected]> Co-authored-by: wenting.swt <[email protected]> Co-authored-by: Dalong <[email protected]> Co-authored-by: Baole Ai <[email protected]> Co-authored-by: Yan Xu <[email protected]>
- Loading branch information
1 parent
063384c
commit fab18e0
Showing
32 changed files
with
2,419 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
package( | ||
default_visibility = [ | ||
"//visibility:public", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "headers", | ||
hdrs = glob( | ||
[ | ||
"mlir/ral/*.h", | ||
"mlir/ral/context/base/cuda/*.h", | ||
"mlir/ral/context/base/cuda/cuda_context_impl.h", | ||
"mlir/ral/device/cpu/*.h", | ||
"mlir/ral/device/gpu/*.h", | ||
], | ||
), | ||
includes = [ | ||
"tao_compiler", | ||
"tao_compiler/mlir", | ||
], | ||
strip_include_prefix = "external/disc_compiler/tao_compiler/mlir", | ||
) | ||
|
||
cc_import( | ||
name="disc_ral_cuda", | ||
shared_library = ":libral_base_context.so", | ||
) | ||
|
||
cc_import( | ||
name="disc_custom_op", | ||
shared_library = ":libdisc_custom_ops.so", | ||
) | ||
|
||
genrule( | ||
name = "build_disc", | ||
outs = ["libral_base_context.so", "libdisc_custom_ops.so", "disc_compiler_main", "torch-mlir-opt"], | ||
local = True, | ||
cmd = ';'.join(['export PATH=/root/bin:/usr/local/cuda/bin:$${PATH}', | ||
'pushd external/disc_compiler/pytorch_blade/', | ||
'python ../scripts/python/common_setup.py', | ||
'TF_CUDA_COMPUTE_CAPABILITIES="7.0,8.0,8.6,9.0" TORCH_CUDA_ARCH_LIST="7.0 8.0 8.6 9.0" python setup.py bdist_wheel', | ||
'popd', | ||
'cp third_party/BladeDISC/pytorch_blade/bazel-bin/external/org_disc_compiler/mlir/ral/libral_base_context.so $(location libral_base_context.so)', | ||
'cp third_party/BladeDISC/pytorch_blade/bazel-bin/external/org_disc_compiler/mlir/custom_ops/libdisc_custom_ops.so $(location libdisc_custom_ops.so)', | ||
'cp third_party/BladeDISC/pytorch_blade/bazel-bin/external/org_disc_compiler/mlir/disc/disc_compiler_main $(location disc_compiler_main)', | ||
'cp third_party/BladeDISC/pytorch_blade/bazel-bin/tests/mhlo/torch-mlir-opt/torch-mlir-opt $(location torch-mlir-opt)']), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
load( | ||
"//bazel:rules_def.bzl", | ||
"ptxla_cc_library", | ||
"ptxla_cc_test", | ||
) | ||
|
||
genrule( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
load( | ||
"@tsl//tsl/platform/default:cuda_build_defs.bzl", | ||
"if_cuda_is_configured", | ||
) | ||
|
||
load( | ||
"//bazel:rules_def.bzl", | ||
"ptxla_cc_library", | ||
"ptxla_cc_test", | ||
) | ||
|
||
|
||
ptxla_cc_library( | ||
name = "disc_ral", | ||
srcs = [ | ||
"disc_ral.cc", | ||
"custom_call_flash_attention_forward.cc", | ||
"custom_call_flash_attention_backward.cc" | ||
], | ||
hdrs = [ | ||
"disc_ral.h", | ||
], | ||
deps = [ | ||
":disc_utils", | ||
"@disc_compiler//:disc_ral_cuda", | ||
"@disc_compiler//:disc_custom_op", | ||
"@disc_compiler//:headers", | ||
"@local_config_cuda//cuda:cuda_headers", | ||
"@nccl_archive//:nccl_headers", | ||
"@torch//:libc10", | ||
"@torch//:libc10_cuda", | ||
"@torch//:libtorch_cuda", | ||
"@flash_attn//:headers", | ||
"@flash_attn//:flash_attn_cuda", | ||
], | ||
copts = [ | ||
"-DGOOGLE_CUDA", | ||
] | ||
) | ||
|
||
ptxla_cc_library( | ||
name = "disc_utils", | ||
srcs = ["disc_utils.cc"], | ||
hdrs = [ | ||
"disc_utils.h", | ||
], | ||
deps = [ | ||
"//torch_xla/csrc/runtime:tf_logging", | ||
] | ||
) | ||
|
||
ptxla_cc_library( | ||
name = "disc_compile", | ||
srcs = ["disc_compile.cc"], | ||
hdrs = [ | ||
"disc_compile.h", | ||
], | ||
deps = [ | ||
":disc_ral", | ||
":disc_utils", | ||
"//torch_xla/csrc/runtime:tf_logging", | ||
"//torch_xla/csrc/runtime:sys_util", | ||
"//torch_xla/csrc/runtime:env_vars", | ||
"@llvm-project//mlir:FuncDialect", | ||
"@llvm-project//mlir:IR", | ||
"@llvm-project//mlir:Parser", | ||
], | ||
copts = [ | ||
"-DGOOGLE_CUDA", | ||
] | ||
) | ||
|
||
ptxla_cc_test( | ||
name = "disc_ral_test", | ||
srcs = ["disc_ral_test.cc"], | ||
deps = [ | ||
":disc_ral", | ||
"@tsl//tsl/platform:test", | ||
"@tsl//tsl/platform:test_main", | ||
] | ||
) |
Oops, something went wrong.