forked from alibaba/rtp-llm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD
130 lines (119 loc) · 3.5 KB
/
BUILD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
load("//:def.bzl", "copts", "cuda_copts", "torch_deps")
load("//bazel:arch_select.bzl", "th_transformer_so")
load("//bazel:arch_select.bzl", "cutlass_kernels_interface")
cutlass_kernels_interface()
config_setting(
name = "using_cuda",
values = {"define": "using_cuda=true"},
)
config_setting(
name = "use_cuda12",
values = {"define": "use_cuda12=true"},
)
cc_library(
name = "gpt_init_params_hdr",
hdrs = [
"src/fastertransformer/th_op/GptInitParameter.h"
],
deps = [
"//src/fastertransformer/utils:utils",
] + torch_deps(),
visibility = ["//visibility:public"],
)
# NOTE: This target is defined here but not used here.
# for libth_transformer.so, GptInitParameter.cc must be compiled together with `th_op/multi_gpu_gpt/*.cc`
# in a single target, otherwise torch throws an error of
# `Type c10::intrusive_ptr<GptInitParameter> could not be converted to any of the known types.`
# This is due to GptInitParameter is referenced before it's registered,
# which might because the compiled symbols does not load in expected order according to dependency.
cc_library(
name = "gpt_init_params",
srcs = [
"src/fastertransformer/th_op/GptInitParameter.cc"
],
deps = [
":gpt_init_params_hdr",
],
copts = copts(),
alwayslink = True,
visibility = ["//visibility:public"],
)
cc_library(
name = "th_op_hdrs",
hdrs = glob([
"src/fastertransformer/th_op/**/*.h",
], exclude = [
"src/fastertransformer/th_op/GptInitParameter.h"
]),
)
cc_library(
name = "th_transformer_lib",
srcs = glob([
"src/fastertransformer/th_op/th_utils.cc",
"src/fastertransformer/th_op/common/*.cc",
"src/fastertransformer/th_op/multi_gpu_gpt/*.cc",
"src/fastertransformer/th_op/GptInitParameter.cc"
]),
deps = [
":gpt_init_params_hdr",
":th_op_hdrs",
"//src/fastertransformer/cuda:allocator_torch",
"//src/fastertransformer/layers:layers",
"//src/fastertransformer/models:models",
"//src/fastertransformer/utils:utils",
],
copts = copts(),
alwayslink = True,
visibility = ["//visibility:public"],
)
cc_binary(
name = "th_transformer",
deps = [
"cutlass_kernels_interface",
"//3rdparty/flash_attention2:flash_attention2_impl",
"//3rdparty/contextFusedMultiHeadAttention:trt_fmha_impl",
":th_transformer_lib",
":gpt_init_params_hdr",
],
copts = copts(),
linkshared = 1,
visibility = ["//visibility:public"],
)
cc_library(
name = "th_utils",
srcs = [
"src/fastertransformer/th_op/th_utils.cc",
],
hdrs = [
"src/fastertransformer/th_op/th_utils.h",
"src/fastertransformer/th_op/GptCommonInputs.h",
],
deps = [
"//src/fastertransformer/cuda:allocator_torch",
"//src/fastertransformer/cuda:cuda",
"//src/fastertransformer/utils:utils",
"//src/fastertransformer/kernels:kernels",
],
copts = copts(),
visibility = ["//visibility:public"],
)
py_runtime(
name = "python310",
interpreter_path = "/opt/conda310/bin/python",
python_version = "PY3",
stub_shebang = "#!/opt/conda310/bin/python"
)
cc_binary(
name = "kernel_unittest",
srcs = glob([
"tests/layernorm/*.cpp",
"tests/logn_attention/*.cpp",
"tests/rotary_embedding/*.cpp",
]),
deps = [
"//tests:test_ops",
],
copts = cuda_copts(),
linkshared = 1,
visibility = ["//visibility:public"],
)