forked from NVIDIA/FasterTransformer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
563 lines (506 loc) · 21 KB
/
CMakeLists.txt
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
# Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.8 FATAL_ERROR) # for PyTorch extensions, version should be greater than 3.13
project(FasterTransformer LANGUAGES CXX CUDA)
find_package(CUDA 10.2 REQUIRED)
if(${CUDA_VERSION_MAJOR} VERSION_GREATER_EQUAL "11")
add_definitions("-DENABLE_BF16")
message("CUDA_VERSION ${CUDA_VERSION_MAJOR} is greater or equal than 11, enable -DENABLE_BF16 flag")
endif()
option(BUILD_CUTLASS_MOE "Builds CUTLASS kernels supporting MoE GEMM" ON)
if(BUILD_CUTLASS_MOE)
message(STATUS "Add DBUILD_CUTLASS_MOE, requires CUTLASS. Increases compilation time")
add_definitions("-DBUILD_CUTLASS_MOE")
endif()
option(BUILD_CUTLASS_MIXED_GEMM "Builds CUTLASS kernels supporting mixed gemm" ON)
if(BUILD_CUTLASS_MIXED_GEMM)
message(STATUS "Add DBUILD_CUTLASS_MIXED_GEMM, requires CUTLASS. Increases compilation time")
add_definitions("-DBUILD_CUTLASS_MIXED_GEMM")
endif()
option(BUILD_TF "Build in TensorFlow mode" OFF)
option(BUILD_TF2 "Build in TensorFlow2 mode" OFF)
option(BUILD_PYT "Build in PyTorch TorchScript class mode" OFF)
option(BUILD_TRT "Build projects about TensorRT" OFF)
option(GIT_AUTOCLONE_CUTLASS "Check submodules during build" ON)
if(NOT BUILD_MULTI_GPU)
option(BUILD_MULTI_GPU "Build project about multi-GPU" OFF)
endif()
if(NOT USE_TRITONSERVER_DATATYPE)
option(USE_TRITONSERVER_DATATYPE "Build triton backend for triton server" OFF)
endif()
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
if(GIT_AUTOCLONE_CUTLASS)
message(STATUS "Running submodule update to fetch cutlass")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init 3rdparty/cutlass
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init 3rdparty/cutlass failed with ${GIT_SUBMOD_RESULT}, please checkout cutlass submodule")
endif()
endif()
endif()
set(CUTLASS_HEADER_DIR ${PROJECT_SOURCE_DIR}/3rdparty/cutlass/include)
set(CUTLASS_EXTENSIONS_DIR ${PROJECT_SOURCE_DIR}/src/fastertransformer/cutlass_extensions/include)
option(SPARSITY_SUPPORT "Build project with Ampere sparsity feature support" OFF)
option(BUILD_FAST_MATH "Build in fast math mode" ON)
if(BUILD_MULTI_GPU)
message(STATUS "Add DBUILD_MULTI_GPU, requires MPI and NCCL")
add_definitions("-DBUILD_MULTI_GPU")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
find_package(MPI REQUIRED)
find_package(NCCL REQUIRED)
#if(${NCCL_VERSION} LESS 2.7)
# message(FATAL_ERROR "NCCL_VERSION ${NCCL_VERSION} is less than 2.7")
#endif()
set(CMAKE_MODULE_PATH "") # prevent the bugs for pytorch building
endif()
if(BUILD_PYT)
if(DEFINED ENV{NVIDIA_PYTORCH_VERSION})
if($ENV{NVIDIA_PYTORCH_VERSION} VERSION_LESS "20.03")
message(FATAL_ERROR "NVIDIA PyTorch image is too old for TorchScript mode.")
endif()
if($ENV{NVIDIA_PYTORCH_VERSION} VERSION_EQUAL "20.03")
add_definitions(-DLEGACY_THS=1)
endif()
endif()
endif()
if(USE_TRITONSERVER_DATATYPE)
message("-- USE_TRITONSERVER_DATATYPE")
add_definitions("-DUSE_TRITONSERVER_DATATYPE")
endif()
set(CXX_STD "14" CACHE STRING "C++ standard")
set(CUDA_PATH ${CUDA_TOOLKIT_ROOT_DIR})
set(TF_PATH "" CACHE STRING "TensorFlow path")
set(CUSPARSELT_PATH "" CACHE STRING "cuSPARSELt path")
if((BUILD_TF OR BUILD_TF2) AND NOT TF_PATH)
message(FATAL_ERROR "TF_PATH must be set if BUILD_TF or BUILD_TF2 (=TensorFlow mode) is on.")
endif()
list(APPEND CMAKE_MODULE_PATH ${CUDA_PATH}/lib64)
# profiling
option(USE_NVTX "Whether or not to use nvtx" OFF)
if(USE_NVTX)
message(STATUS "NVTX is enabled.")
add_definitions("-DUSE_NVTX")
endif()
# setting compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -Wall -ldl") # -Xptxas -v
set(SM_SETS 52 60 61 70 75 80 86)
set(USING_WMMA False)
set(FIND_SM False)
foreach(SM_NUM IN LISTS SM_SETS)
string(FIND "${SM}" "${SM_NUM}" SM_POS)
if(SM_POS GREATER -1)
if(FIND_SM STREQUAL False)
set(ENV{TORCH_CUDA_ARCH_LIST} "")
endif()
set(FIND_SM True)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -gencode=arch=compute_${SM_NUM},code=\\\"sm_${SM_NUM},compute_${SM_NUM}\\\"")
if (SM_NUM STREQUAL 70 OR SM_NUM STREQUAL 75 OR SM_NUM STREQUAL 80 OR SM_NUM STREQUAL 86)
set(USING_WMMA True)
endif()
if(BUILD_PYT)
string(SUBSTRING ${SM_NUM} 0 1 SM_MAJOR)
string(SUBSTRING ${SM_NUM} 1 1 SM_MINOR)
set(ENV{TORCH_CUDA_ARCH_LIST} "$ENV{TORCH_CUDA_ARCH_LIST}\;${SM_MAJOR}.${SM_MINOR}")
endif()
list(APPEND CMAKE_CUDA_ARCHITECTURES ${SM_NUM})
message("-- Assign GPU architecture (sm=${SM_NUM})")
endif()
endforeach()
if(USING_WMMA STREQUAL True)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWMMA")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWMMA")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DWMMA")
message("-- Use WMMA")
endif()
if(NOT (FIND_SM STREQUAL True))
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} \
-gencode=arch=compute_70,code=\\\"sm_70,compute_70\\\" \
-gencode=arch=compute_75,code=\\\"sm_75,compute_75\\\" \
-gencode=arch=compute_80,code=\\\"sm_80,compute_80\\\" \
-gencode=arch=compute_86,code=\\\"sm_86,compute_86\\\" \
")
# -rdc=true")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWMMA")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWMMA")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DWMMA")
if(BUILD_PYT)
set(ENV{TORCH_CUDA_ARCH_LIST} "7.0;7.5;8.0;8.6")
endif()
set(CMAKE_CUDA_ARCHITECTURES 70 75 80 86)
message("-- Assign GPU architecture (sm=70,75,80,86)")
endif()
if(BUILD_PYT)
set(TORCH_CUDA_ARCH_LIST $ENV{TORCH_CUDA_ARCH_LIST})
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -O0")
# set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -O0 -G -Xcompiler -Wall --ptxas-options=-v --resource-usage")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -O0 -G -Xcompiler -Wall")
set(CMAKE_CXX_STANDARD "${CXX_STD}")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --std=c++${CXX_STD}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
# set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -Xcompiler -O3 --ptxas-options=--verbose")
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -Xcompiler -O3")
if(BUILD_FAST_MATH)
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} --use_fast_math")
message("CMAKE_CUDA_FLAGS_RELEASE: ${CMAKE_CUDA_FLAGS_RELEASE}")
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(COMMON_HEADER_DIRS
${PROJECT_SOURCE_DIR}
${CUDA_PATH}/include
${CUTLASS_HEADER_DIR}
${CUTLASS_EXTENSIONS_DIR}
)
message("-- COMMON_HEADER_DIRS: ${COMMON_HEADER_DIRS}")
set(COMMON_LIB_DIRS
${CUDA_PATH}/lib64
)
if (SPARSITY_SUPPORT)
list(APPEND COMMON_HEADER_DIRS ${CUSPARSELT_PATH}/include)
list(APPEND COMMON_LIB_DIRS ${CUSPARSELT_PATH}/lib64)
add_definitions(-DSPARSITY_ENABLED=1)
endif()
if(BUILD_TF)
list(APPEND COMMON_HEADER_DIRS ${TF_PATH}/include)
list(APPEND COMMON_LIB_DIRS ${TF_PATH})
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
endif()
if(BUILD_TF2)
list(APPEND COMMON_HEADER_DIRS ${TF_PATH}/include)
list(APPEND COMMON_LIB_DIRS ${TF_PATH})
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
endif()
set(PYTHON_PATH "python" CACHE STRING "Python path")
if(BUILD_PYT)
execute_process(COMMAND ${PYTHON_PATH} "-c" "from __future__ import print_function; import torch; print(torch.__version__,end='');"
RESULT_VARIABLE _PYTHON_SUCCESS
OUTPUT_VARIABLE TORCH_VERSION)
if (TORCH_VERSION VERSION_LESS "1.5.0")
message(FATAL_ERROR "PyTorch >= 1.5.0 is needed for TorchScript mode.")
endif()
execute_process(COMMAND ${PYTHON_PATH} "-c" "from __future__ import print_function; import os; import torch;
print(os.path.dirname(torch.__file__),end='');"
RESULT_VARIABLE _PYTHON_SUCCESS
OUTPUT_VARIABLE TORCH_DIR)
if (NOT _PYTHON_SUCCESS MATCHES 0)
message(FATAL_ERROR "Torch config Error.")
endif()
list(APPEND CMAKE_PREFIX_PATH ${TORCH_DIR})
find_package(Torch REQUIRED)
execute_process(COMMAND ${PYTHON_PATH} "-c" "from __future__ import print_function; from distutils import sysconfig;
print(sysconfig.get_python_inc());"
RESULT_VARIABLE _PYTHON_SUCCESS
OUTPUT_VARIABLE PY_INCLUDE_DIR)
if (NOT _PYTHON_SUCCESS MATCHES 0)
message(FATAL_ERROR "Python config Error.")
endif()
list(APPEND COMMON_HEADER_DIRS ${PY_INCLUDE_DIR})
execute_process(COMMAND ${PYTHON_PATH} "-c" "from __future__ import print_function; import torch;
print(torch._C._GLIBCXX_USE_CXX11_ABI,end='');"
RESULT_VARIABLE _PYTHON_SUCCESS
OUTPUT_VARIABLE USE_CXX11_ABI)
message("-- USE_CXX11_ABI=${USE_CXX11_ABI}")
if (USE_CXX11_ABI)
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -D_GLIBCXX_USE_CXX11_ABI=1")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_GLIBCXX_USE_CXX11_ABI=1")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -D_GLIBCXX_USE_CXX11_ABI=1")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_USE_CXX11_ABI=1")
else()
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -D_GLIBCXX_USE_CXX11_ABI=0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_GLIBCXX_USE_CXX11_ABI=0")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -D_GLIBCXX_USE_CXX11_ABI=0")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
endif()
if (BUILD_MULTI_GPU)
list(APPEND COMMON_HEADER_DIRS ${MPI_INCLUDE_PATH})
list(APPEND COMMON_LIB_DIRS /usr/local/mpi/lib)
endif()
if(USE_TRITONSERVER_DATATYPE)
list(APPEND COMMON_HEADER_DIRS ${PROJECT_SOURCE_DIR}/../repo-core-src/include)
endif()
include_directories(
${COMMON_HEADER_DIRS}
)
link_directories(
${COMMON_LIB_DIRS}
)
add_subdirectory(3rdparty)
add_subdirectory(src)
add_subdirectory(examples)
add_subdirectory(tests)
# # Mesaure the compile time
option(MEASURE_BUILD_TIME "Measure the build time of each module" OFF)
if (MEASURE_BUILD_TIME)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time")
set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "${CMAKE_COMMAND} -E time")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CMAKE_COMMAND} -E time")
endif()
########################################
# Following feature requires cmake 3.15
# TODO Remove this part or modify such that we can run it under cmake 3.10
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
add_library(transformer-static STATIC
$<TARGET_OBJECTS:BaseBeamSearchLayer>
$<TARGET_OBJECTS:BaseSamplingLayer>
$<TARGET_OBJECTS:BeamSearchLayer>
$<TARGET_OBJECTS:Bert>
$<TARGET_OBJECTS:BertTritonBackend>
$<TARGET_OBJECTS:DecoderCrossAttentionLayer>
$<TARGET_OBJECTS:DecoderSelfAttentionLayer>
$<TARGET_OBJECTS:DynamicDecodeLayer>
$<TARGET_OBJECTS:FfnLayer>
$<TARGET_OBJECTS:FusedAttentionLayer>
$<TARGET_OBJECTS:GptContextAttentionLayer>
$<TARGET_OBJECTS:GptJ>
$<TARGET_OBJECTS:GptJContextDecoder>
$<TARGET_OBJECTS:GptJDecoder>
$<TARGET_OBJECTS:GptJDecoderLayerWeight>
$<TARGET_OBJECTS:GptJTritonBackend>
$<TARGET_OBJECTS:GptJWeight>
$<TARGET_OBJECTS:GptNeoX>
$<TARGET_OBJECTS:GptNeoXContextDecoder>
$<TARGET_OBJECTS:GptNeoXDecoder>
$<TARGET_OBJECTS:GptNeoXDecoderLayerWeight>
$<TARGET_OBJECTS:GptNeoXTritonBackend>
$<TARGET_OBJECTS:GptNeoXWeight>
$<TARGET_OBJECTS:OnlineBeamSearchLayer>
$<TARGET_OBJECTS:ParallelGpt>
$<TARGET_OBJECTS:ParallelGptContextDecoder>
$<TARGET_OBJECTS:ParallelGptDecoder>
$<TARGET_OBJECTS:ParallelGptDecoderLayerWeight>
$<TARGET_OBJECTS:ParallelGptTritonBackend>
$<TARGET_OBJECTS:ParallelGptWeight>
$<TARGET_OBJECTS:T5Decoder>
$<TARGET_OBJECTS:T5Decoding>
$<TARGET_OBJECTS:T5Encoder>
$<TARGET_OBJECTS:T5TritonBackend>
$<TARGET_OBJECTS:T5EncoderTritonBackend>
$<TARGET_OBJECTS:TensorParallelDecoderCrossAttentionLayer>
$<TARGET_OBJECTS:TensorParallelDecoderSelfAttentionLayer>
$<TARGET_OBJECTS:TensorParallelGeluFfnLayer>
$<TARGET_OBJECTS:TensorParallelSiluFfnLayer>
$<TARGET_OBJECTS:TensorParallelGptContextAttentionLayer>
$<TARGET_OBJECTS:TensorParallelReluFfnLayer>
$<TARGET_OBJECTS:TensorParallelUnfusedAttentionLayer>
$<TARGET_OBJECTS:TopKSamplingLayer>
$<TARGET_OBJECTS:TopPSamplingLayer>
$<TARGET_OBJECTS:TransformerTritonBackend>
$<TARGET_OBJECTS:UnfusedAttentionLayer>
$<TARGET_OBJECTS:activation_int8_kernels>
$<TARGET_OBJECTS:activation_kernels>
$<TARGET_OBJECTS:add_bias_transpose_kernels>
$<TARGET_OBJECTS:add_residual_kernels>
$<TARGET_OBJECTS:ban_bad_words>
$<TARGET_OBJECTS:beam_search_penalty_kernels>
$<TARGET_OBJECTS:beam_search_topk_kernels>
$<TARGET_OBJECTS:bert_preprocess_kernels>
$<TARGET_OBJECTS:calibrate_quantize_weight_kernels>
$<TARGET_OBJECTS:cublasAlgoMap>
$<TARGET_OBJECTS:cublasMMWrapper>
$<TARGET_OBJECTS:cuda_utils>
$<TARGET_OBJECTS:custom_ar_comm>
$<TARGET_OBJECTS:custom_ar_kernels>
$<TARGET_OBJECTS:cutlass_heuristic>
$<TARGET_OBJECTS:cutlass_preprocessors>
$<TARGET_OBJECTS:decoder_masked_multihead_attention>
$<TARGET_OBJECTS:decoding_kernels>
$<TARGET_OBJECTS:fpA_intB_gemm>
$<TARGET_OBJECTS:gen_relative_pos_bias>
$<TARGET_OBJECTS:gpt_kernels>
$<TARGET_OBJECTS:layernorm_int8_kernels>
$<TARGET_OBJECTS:layernorm_kernels>
$<TARGET_OBJECTS:layout_transformer_int8_kernels>
$<TARGET_OBJECTS:logprob_kernels>
$<TARGET_OBJECTS:logger>
$<TARGET_OBJECTS:longformer_kernels>
$<TARGET_OBJECTS:matrix_transpose_kernels>
$<TARGET_OBJECTS:matrix_vector_multiplication>
$<TARGET_OBJECTS:memory_utils>
$<TARGET_OBJECTS:moe_gemm_kernels>
$<TARGET_OBJECTS:moe_kernels>
$<TARGET_OBJECTS:mpi_utils>
$<TARGET_OBJECTS:nccl_utils>
$<TARGET_OBJECTS:online_softmax_beamsearch_kernels>
$<TARGET_OBJECTS:quantization_int8_kernels>
$<TARGET_OBJECTS:sampling_penalty_kernels>
$<TARGET_OBJECTS:sampling_topk_kernels>
$<TARGET_OBJECTS:sampling_topp_kernels>
$<TARGET_OBJECTS:softmax_int8_kernels>
$<TARGET_OBJECTS:stop_criteria>
$<TARGET_OBJECTS:tensor>
$<TARGET_OBJECTS:transpose_int8_kernels>
$<TARGET_OBJECTS:trt_fused_multi_head_attention>
$<TARGET_OBJECTS:unfused_attention_kernels>
$<TARGET_OBJECTS:word_list>
)
set_property(TARGET transformer-static PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET transformer-static PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
target_link_libraries(transformer-static PUBLIC -lcudart -lcublas -lcublasLt -lcurand)
add_library(transformer-shared SHARED
$<TARGET_OBJECTS:BaseBeamSearchLayer>
$<TARGET_OBJECTS:BaseSamplingLayer>
$<TARGET_OBJECTS:BeamSearchLayer>
$<TARGET_OBJECTS:Bert>
$<TARGET_OBJECTS:BertTritonBackend>
$<TARGET_OBJECTS:DecoderCrossAttentionLayer>
$<TARGET_OBJECTS:DecoderSelfAttentionLayer>
$<TARGET_OBJECTS:DynamicDecodeLayer>
$<TARGET_OBJECTS:FfnLayer>
$<TARGET_OBJECTS:FusedAttentionLayer>
$<TARGET_OBJECTS:GptContextAttentionLayer>
$<TARGET_OBJECTS:GptJ>
$<TARGET_OBJECTS:GptJContextDecoder>
$<TARGET_OBJECTS:GptJDecoder>
$<TARGET_OBJECTS:GptJDecoderLayerWeight>
$<TARGET_OBJECTS:GptJTritonBackend>
$<TARGET_OBJECTS:GptJWeight>
$<TARGET_OBJECTS:GptNeoX>
$<TARGET_OBJECTS:GptNeoXContextDecoder>
$<TARGET_OBJECTS:GptNeoXDecoder>
$<TARGET_OBJECTS:GptNeoXDecoderLayerWeight>
$<TARGET_OBJECTS:GptNeoXTritonBackend>
$<TARGET_OBJECTS:GptNeoXWeight>
$<TARGET_OBJECTS:OnlineBeamSearchLayer>
$<TARGET_OBJECTS:ParallelGpt>
$<TARGET_OBJECTS:ParallelGptContextDecoder>
$<TARGET_OBJECTS:ParallelGptDecoder>
$<TARGET_OBJECTS:ParallelGptDecoderLayerWeight>
$<TARGET_OBJECTS:ParallelGptTritonBackend>
$<TARGET_OBJECTS:ParallelGptWeight>
$<TARGET_OBJECTS:T5Decoder>
$<TARGET_OBJECTS:T5Decoding>
$<TARGET_OBJECTS:T5Encoder>
$<TARGET_OBJECTS:T5TritonBackend>
$<TARGET_OBJECTS:T5EncoderTritonBackend>
$<TARGET_OBJECTS:TensorParallelDecoderCrossAttentionLayer>
$<TARGET_OBJECTS:TensorParallelDecoderSelfAttentionLayer>
$<TARGET_OBJECTS:TensorParallelGeluFfnLayer>
$<TARGET_OBJECTS:TensorParallelSiluFfnLayer>
$<TARGET_OBJECTS:TensorParallelGptContextAttentionLayer>
$<TARGET_OBJECTS:TensorParallelReluFfnLayer>
$<TARGET_OBJECTS:TensorParallelUnfusedAttentionLayer>
$<TARGET_OBJECTS:TopKSamplingLayer>
$<TARGET_OBJECTS:TopPSamplingLayer>
$<TARGET_OBJECTS:TransformerTritonBackend>
$<TARGET_OBJECTS:UnfusedAttentionLayer>
$<TARGET_OBJECTS:activation_int8_kernels>
$<TARGET_OBJECTS:activation_kernels>
$<TARGET_OBJECTS:add_bias_transpose_kernels>
$<TARGET_OBJECTS:add_residual_kernels>
$<TARGET_OBJECTS:ban_bad_words>
$<TARGET_OBJECTS:beam_search_penalty_kernels>
$<TARGET_OBJECTS:beam_search_topk_kernels>
$<TARGET_OBJECTS:bert_preprocess_kernels>
$<TARGET_OBJECTS:calibrate_quantize_weight_kernels>
$<TARGET_OBJECTS:cublasAlgoMap>
$<TARGET_OBJECTS:cublasMMWrapper>
$<TARGET_OBJECTS:cuda_utils>
$<TARGET_OBJECTS:custom_ar_comm>
$<TARGET_OBJECTS:custom_ar_kernels>
$<TARGET_OBJECTS:cutlass_heuristic>
$<TARGET_OBJECTS:cutlass_preprocessors>
$<TARGET_OBJECTS:decoder_masked_multihead_attention>
$<TARGET_OBJECTS:decoding_kernels>
$<TARGET_OBJECTS:fpA_intB_gemm>
$<TARGET_OBJECTS:gen_relative_pos_bias>
$<TARGET_OBJECTS:gpt_kernels>
$<TARGET_OBJECTS:layernorm_int8_kernels>
$<TARGET_OBJECTS:layernorm_kernels>
$<TARGET_OBJECTS:layout_transformer_int8_kernels>
$<TARGET_OBJECTS:logprob_kernels>
$<TARGET_OBJECTS:logger>
$<TARGET_OBJECTS:longformer_kernels>
$<TARGET_OBJECTS:matrix_transpose_kernels>
$<TARGET_OBJECTS:matrix_vector_multiplication>
$<TARGET_OBJECTS:memory_utils>
$<TARGET_OBJECTS:moe_gemm_kernels>
$<TARGET_OBJECTS:moe_kernels>
$<TARGET_OBJECTS:mpi_utils>
$<TARGET_OBJECTS:nccl_utils>
$<TARGET_OBJECTS:online_softmax_beamsearch_kernels>
$<TARGET_OBJECTS:quantization_int8_kernels>
$<TARGET_OBJECTS:sampling_penalty_kernels>
$<TARGET_OBJECTS:sampling_topk_kernels>
$<TARGET_OBJECTS:sampling_topp_kernels>
$<TARGET_OBJECTS:softmax_int8_kernels>
$<TARGET_OBJECTS:stop_criteria>
$<TARGET_OBJECTS:tensor>
$<TARGET_OBJECTS:transpose_int8_kernels>
$<TARGET_OBJECTS:trt_fused_multi_head_attention>
$<TARGET_OBJECTS:unfused_attention_kernels>
$<TARGET_OBJECTS:word_list>
)
set_target_properties(transformer-shared PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(transformer-shared PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
set_target_properties(transformer-shared PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(transformer-shared PUBLIC -lcudart -lcublas -lcublasLt -lcurand)
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/FasterTransformer)
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/FasterTransformerConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/FasterTransformerConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/FasterTransformerConfig.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
install(
TARGETS
transformer-shared
EXPORT
transformer-shared-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/fastertransformer
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/fastertransformer
)
install(
EXPORT
transformer-shared-targets
FILE
FasterTransformerTargets.cmake
DESTINATION
${INSTALL_CONFIGDIR}
)
file(GLOB_RECURSE HEADER_FILES "*.h" "*.hpp" "*.cuh")
foreach ( file ${HEADER_FILES} )
file( RELATIVE_PATH rfile ${CMAKE_CURRENT_SOURCE_DIR} ${file} )
get_filename_component( dir ${rfile} DIRECTORY )
install( FILES ${file} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${dir} )
endforeach()
################################################################################
# add_executable(gpt sample/cpp/gpt_sample.cc )
# target_link_libraries(gpt PUBLIC -lcublas -lcublasLt -lcudart -lcurand -lnccl -lmpi transformer-static)
# target_link_libraries(gpt PUBLIC -lcublas -lcublasLt -lcudart -lcurand -lnccl -lmpi decoder decoding)
export(
EXPORT
transformer-shared-targets
FILE
${CMAKE_CURRENT_BINARY_DIR}/FasterTransformerTargets.cmake
NAMESPACE
TritonCore::
)
export(PACKAGE FasterTransformer)