Skip to content

Commit 258ae9c

Browse files
authored
Revert "infra: move nvrtc_wrapper to conan (#3282)" (#3573)
This reverts commit c0dd6cb. Signed-off-by: Kaiyu Xie <26294424+kaiyux@users.noreply.github.com>
1 parent d35db25 commit 258ae9c

File tree

13 files changed

+165
-132
lines changed

13 files changed

+165
-132
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ config.json
3232
/*.svg
3333
cpp/cmake-build-*
3434
cpp/.ccache
35-
cpp/.conan
3635
tensorrt_llm/bin
3736
tensorrt_llm/include
3837
tensorrt_llm/libs

cpp/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,6 @@ if(ENABLE_MULTI_DEVICE)
358358
find_library(NCCL_LIB nccl HINTS ${NCCL_LIB_DIR})
359359
endif()
360360

361-
find_package(tensorrt_llm_nvrtc_wrapper REQUIRED)
362-
363361
get_filename_component(TRT_LLM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} PATH)
364362

365363
set(3RDPARTY_DIR ${TRT_LLM_ROOT_DIR}/3rdparty)
@@ -371,7 +369,6 @@ include_directories(
371369
${CUDAToolkit_INCLUDE_DIRS}
372370
${CUDNN_ROOT_DIR}/include
373371
${NCCL_INCLUDE_DIR}
374-
${tensorrt_llm_nvrtc_wrapper_INCLUDE_DIRS}
375372
${3RDPARTY_DIR}/cutlass/include
376373
${3RDPARTY_DIR}/cutlass/tools/util/include
377374
${3RDPARTY_DIR}/NVTX/include

cpp/conandata.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp/conanfile.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

cpp/tensorrt_llm/CMakeLists.txt

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,55 @@ find_package(Threads REQUIRED)
139139
target_link_libraries(${BATCH_MANAGER_TARGET} INTERFACE Threads::Threads)
140140
target_link_libraries(${EXECUTOR_TARGET} INTERFACE Threads::Threads)
141141

142-
# NVRTC_WRAPPER_LIB_SOURCE_REL_LOC is defined in cpp/conanfile.py
143-
set(NVRTC_WRAPPER_LIB_BINARY_REL_LOC
144-
"kernels/decoderMaskedMultiheadAttention/decoderXQAImplJIT/nvrtcWrapper/libtensorrt_llm_nvrtc_wrapper.so"
145-
)
146-
# Copy the .so to build directory, which is needed in build_wheel.py.
147-
configure_file(${NVRTC_WRAPPER_LIB_SOURCE_REL_LOC}
148-
${NVRTC_WRAPPER_LIB_BINARY_REL_LOC} COPYONLY)
142+
set(NVRTC_WRAPPER_TARGET tensorrt_llm_nvrtc_wrapper)
143+
set(NVRTC_WRAPPER_TARGET_ARCH ${TARGET_ARCH})
144+
145+
if(BUILD_NVRTC_WRAPPER)
146+
add_subdirectory(
147+
kernels/decoderMaskedMultiheadAttention/decoderXQAImplJIT/nvrtcWrapper)
148+
else()
149+
add_library(${NVRTC_WRAPPER_TARGET} SHARED IMPORTED)
150+
set(NVRTC_WRAPPER_LIB_TARBALL
151+
"${CMAKE_CURRENT_SOURCE_DIR}/kernels/decoderMaskedMultiheadAttention/decoderXQAImplJIT/nvrtcWrapper/${NVRTC_WRAPPER_TARGET_ARCH}/${NVRTC_WRAPPER_TARGET}.tar.xz"
152+
)
153+
set(NVRTC_WRAPPER_LIB_BINARY_DIR
154+
"${CMAKE_CURRENT_BINARY_DIR}/kernels/decoderMaskedMultiheadAttention/decoderXQAImplJIT/nvrtcWrapper"
155+
)
156+
if(NOT WIN32) # Linux
157+
set(NVRTC_WRAPPER_LIB_NAME "lib${NVRTC_WRAPPER_TARGET}.so")
158+
else() # Windows
159+
set(NVRTC_WRAPPER_LIB_NAME "${NVRTC_WRAPPER_TARGET}.lib")
160+
set(NVRTC_WRAPPER_DLL_NAME "${NVRTC_WRAPPER_TARGET}.dll")
161+
set(NVRTC_WRAPPER_DLL_PATH
162+
"${NVRTC_WRAPPER_LIB_BINARY_DIR}/${NVRTC_WRAPPER_DLL_NAME}")
163+
endif()
164+
set(NVRTC_WRAPPER_LIB_PATH
165+
"${NVRTC_WRAPPER_LIB_BINARY_DIR}/${NVRTC_WRAPPER_LIB_NAME}")
166+
add_custom_command(
167+
OUTPUT ${NVRTC_WRAPPER_LIB_PATH} ${NVRTC_WRAPPER_DLL_PATH}
168+
COMMAND ${CMAKE_COMMAND} -E make_directory ${NVRTC_WRAPPER_LIB_BINARY_DIR}
169+
COMMAND ${CMAKE_COMMAND} -E chdir ${NVRTC_WRAPPER_LIB_BINARY_DIR}
170+
${CMAKE_COMMAND} -E tar xf ${NVRTC_WRAPPER_LIB_TARBALL}
171+
DEPENDS ${NVRTC_WRAPPER_LIB_TARBALL}
172+
VERBATIM)
173+
add_custom_target(${NVRTC_WRAPPER_TARGET}_helper
174+
DEPENDS ${NVRTC_WRAPPER_LIB_PATH} ${NVRTC_WRAPPER_DLL_PATH})
175+
add_dependencies(${NVRTC_WRAPPER_TARGET} ${NVRTC_WRAPPER_TARGET}_helper)
176+
set_property(TARGET ${NVRTC_WRAPPER_TARGET}
177+
PROPERTY IMPORTED_LOCATION ${NVRTC_WRAPPER_LIB_PATH})
178+
if(WIN32)
179+
set_property(TARGET ${NVRTC_WRAPPER_TARGET}
180+
PROPERTY IMPORTED_IMPLIB ${NVRTC_WRAPPER_DLL_PATH})
181+
endif()
182+
183+
file(SIZE ${INTERNAL_CUTLASS_KERNELS_LIB_TARBALL} NVRTC_WRAPPER_LIB_SIZE)
184+
if(NVRTC_WRAPPER_LIB_SIZE LESS 1024)
185+
message(
186+
FATAL_ERROR
187+
"The nvrtc wrapper library is truncated or incomplete. This is usually caused by using Git LFS (Large File Storage) incorrectly. Please try running command `git lfs install && git lfs pull`."
188+
)
189+
endif()
190+
endif()
149191

150192
set(TRTLLM_LINK_LIBS
151193
${CUDA_DRV_LIB}
@@ -231,9 +273,7 @@ if(NOT WIN32)
231273
"-Wl,-rpath='$ORIGIN'")
232274
endif()
233275

234-
target_link_libraries(
235-
${SHARED_TARGET}
236-
PUBLIC tensorrt_llm_nvrtc_wrapper::tensorrt_llm_nvrtc_wrapper)
276+
target_link_libraries(${SHARED_TARGET} PUBLIC ${NVRTC_WRAPPER_TARGET})
237277

238278
if(BUILD_PYT)
239279
add_subdirectory(thop)

cpp/tensorrt_llm/kernels/decoderMaskedMultiheadAttention/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ file(GLOB_RECURSE SRC_CPP *.cpp)
2020
set(SRC_CU)
2121
set(SRC_CU_EXTRA)
2222

23+
# Exclude files in nvrtcWrapper folder.
24+
list(FILTER SRC_CPP EXCLUDE REGEX ".*nvrtcWrapper/src.*")
25+
2326
filter_cuda_archs("80" SRC_CPP)
2427
filter_cuda_archs("86" SRC_CPP)
2528
filter_cuda_archs("89" SRC_CPP)

cpp/tensorrt_llm/kernels/decoderMaskedMultiheadAttention/decoderXQAImplJIT/compileEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
#include "compileEngine.h"
1717

1818
#include "cubinObj.h"
19+
#include "nvrtcWrapper/include/nvrtcWrapper.h"
1920
#include "tensorrt_llm/common/assert.h"
2021
#include "tensorrt_llm/common/stringUtils.h"
2122
#include "tensorrt_llm/common/tllmException.h"
2223
#include "tensorrt_llm/common/utils.h"
2324
#include "tensorrt_llm/kernels/decoderMaskedMultiheadAttention/decoderXQAImplJIT/kernelUtils.h"
24-
#include <nvrtcWrapper.h>
2525
#include <string>
2626
#include <vector>
2727

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
5ad6be58302fad71488246c4dea6f96d710143988a195d67b304ea251bd0aa89 libtensorrt_llm_nvrtc_wrapper.so
2+
commit 9c24486cb2cd9dd9582b311b84e1b428d29a735a
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* This file is NOT thread safe.
17+
*/
18+
#pragma once
19+
#include <stddef.h>
20+
21+
#ifdef _WIN32
22+
23+
#if COMPILING_DLL
24+
#define DLLEXPORT __declspec(dllexport)
25+
#else
26+
#define DLLEXPORT __declspec(dllimport)
27+
#endif
28+
29+
#else // _WIN32
30+
#define DLLEXPORT // Nothing.
31+
#endif
32+
33+
#if __cplusplus
34+
extern "C"
35+
{
36+
#endif
37+
38+
typedef enum
39+
{
40+
// sm >= 80
41+
TLLM_XQA_JIT_HMMA = 0,
42+
// sm == 90
43+
TLLM_XQA_JIT_QGMMA = 1
44+
} tllmXqaJitKernelType;
45+
46+
typedef enum
47+
{
48+
TLLM_XQA_JIT_ROPE_NONE = 0,
49+
TLLM_XQA_JIT_ROPE_NEOX = 1,
50+
TLLM_XQA_JIT_ROPE_GPTJ = 2
51+
} tllmXqaJitRopeStyle;
52+
53+
typedef struct
54+
{
55+
// Compute capability, e.g. 89.
56+
int sm;
57+
58+
unsigned int head_size;
59+
unsigned int num_q_heads;
60+
unsigned int num_kv_heads;
61+
unsigned int beam_width;
62+
unsigned int tokens_per_block;
63+
bool multi_query_tokens;
64+
unsigned int q_seq_len;
65+
bool paged_kv_cache;
66+
67+
// Actual type: tensorrt_llm::kernels::Data_type
68+
int data_type;
69+
int kv_cache_data_type;
70+
71+
tllmXqaJitKernelType kernel_type;
72+
73+
bool fp8_output;
74+
bool use_input_kv;
75+
tllmXqaJitRopeStyle rope_style; // useful only when use_input_kv is true.
76+
} tllmXqaJitContext;
77+
78+
// tllmXqaJitProgram is an opaque handle for a program.
79+
typedef struct _tllmXqaJitProgram* tllmXqaJitProgram;
80+
81+
typedef enum
82+
{
83+
TLLM_XQA_JIT_SUCCESS = 0,
84+
TLLM_XQA_JIT_INVALID_INPUT = 1,
85+
TLLM_XQA_JIT_INTERNAL_ERROR = 2,
86+
} tllmXqaJitStatus;
87+
88+
// context must outlive prog.
89+
DLLEXPORT tllmXqaJitStatus tllmXqaJitCreateAndCompileProgram(
90+
tllmXqaJitProgram* prog, tllmXqaJitContext const* context);
91+
DLLEXPORT tllmXqaJitStatus tllmXqaJitGetCUBINSize(tllmXqaJitProgram prog, size_t* cubinSizeRet);
92+
DLLEXPORT tllmXqaJitStatus tllmXqaJitGetCUBIN(tllmXqaJitProgram prog, char* cubin);
93+
DLLEXPORT tllmXqaJitStatus tllmXqaJitDestroyProgram(tllmXqaJitProgram* prog);
94+
95+
// Returns the size of the error string associated with the last non-success tllmXqaJit function call (including the
96+
// trailing \0). Returns 0 if there is no such non-success function call.
97+
DLLEXPORT size_t tllmXqaJitGetLastErrorStringSize();
98+
// Returns the error string.
99+
// Output can be nullptr if the returned value of tllmGetLastErrorStringSize() is 0.
100+
DLLEXPORT void tllmXqaJitGetLastErrorString(char* output);
101+
102+
#if __cplusplus
103+
} // extern "C"
104+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
9d1104bbe6b4f258482549ec71c9d1aed0de912b5824dced5cf7829bff66ba0d libtensorrt_llm_nvrtc_wrapper.so
2+
commit 9c24486cb2cd9dd9582b311b84e1b428d29a735a

docker/Dockerfile.user

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@ RUN apt-get update && \
1818
apt-get clean && \
1919
rm -rf /var/lib/apt/lists/*
2020

21-
ENV PATH="/home/${USER_NAME}/.local/bin:${PATH}"
22-
2321
USER ${USER_NAME}

docker/Makefile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,13 @@ DOCKER_RUN_OPTS ?= --rm -it --ipc=host --ulimit memlock=-1 --ulimit stack=6710
107107
DOCKER_RUN_ARGS ?=
108108
GPU_OPTS ?= --gpus=all
109109
SOURCE_DIR ?= $(shell readlink -f ..)
110-
NVRTC_WRAPPER_DIR ?=
111110
CODE_DIR ?= /code/tensorrt_llm
112111
CCACHE_DIR ?= ${CODE_DIR}/cpp/.ccache
113-
CONAN_DIR ?= ${CODE_DIR}/cpp/.conan
114112
RUN_CMD ?=
115113
CONTAINER_NAME ?= tensorrt_llm
116114
WORK_DIR ?= $(CODE_DIR)
117115
DOCKER_PULL ?= 0
118116

119-
ifneq ($(NVRTC_WRAPPER_DIR), )
120-
NVRTC_WRAPPER_MOUNT := --volume $(NVRTC_WRAPPER_DIR):/mnt/src/tensorrt_llm_nvrtc_wrapper
121-
else
122-
NVRTC_WRAPPER_MOUNT :=
123-
endif
124-
125117
%_run:
126118
ifeq ($(DOCKER_PULL),1)
127119
@$(MAKE) --no-print-directory $*_pull
@@ -132,10 +124,8 @@ endif
132124
docker run $(DOCKER_RUN_OPTS) $(DOCKER_RUN_ARGS) \
133125
$(GPU_OPTS) \
134126
--volume $(SOURCE_DIR):$(CODE_DIR) \
135-
$(NVRTC_WRAPPER_MOUNT) \
136127
--env "CCACHE_DIR=${CCACHE_DIR}" \
137128
--env "CCACHE_BASEDIR=${CODE_DIR}" \
138-
--env "CONAN_HOME=${CONAN_DIR}" \
139129
--workdir $(WORK_DIR) \
140130
--hostname $(shell hostname)-$* \
141131
--name $(CONTAINER_NAME)-$*-$(USER_NAME) \

0 commit comments

Comments
 (0)