Skip to content

Commit 9df4dad

Browse files
authored
[None][fix] Introduce inline namespace to avoid symbol collision (NVIDIA#9541)
Signed-off-by: Yihan Wang <[email protected]>
1 parent af315d8 commit 9df4dad

File tree

621 files changed

+4168
-9576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

621 files changed

+4168
-9576
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ tests/integration/test_input_files/*.jpg filter=lfs diff=lfs merge=lfs -text
1212
docs/source/blogs/media/tech_blog10_baseline_performance_detail.png filter=lfs diff=lfs merge=lfs -text
1313
docs/source/blogs/media/tech_blog10_full_strategy_performance.png filter=lfs diff=lfs merge=lfs -text
1414
docs/source/blogs/media/tech_blog10_context_wait_performance.png filter=lfs diff=lfs merge=lfs -text
15+
cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/kernelMetaInfo_cubin.cpp filter=lfs diff=lfs merge=lfs -text
16+
cpp/tensorrt_llm/kernels/decoderMaskedMultiheadAttention/cubin/xqa_kernel_cubin.cpp filter=lfs diff=lfs merge=lfs -text

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ llm-test-workspace/
7474
cpp/include/tensorrt_llm/executor/version.h
7575
cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fmha_v2_cu/
7676
cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/cubin/fmha_cubin.h
77+
cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/cubin/fmha_cubin.cpp
7778
.devcontainer/.env
7879
/examples/layer_wise_benchmarks/profiles/
7980

benchmarks/cpp/utils/utils.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
/*
3-
* SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
* SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION &
4+
*AFFILIATES. All rights reserved.
45
* SPDX-License-Identifier: Apache-2.0
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,13 +18,16 @@
1718
*/
1819

1920
#include "utils.h"
21+
#include "tensorrt_llm/common/config.h"
2022
#include "tensorrt_llm/common/logger.h"
2123
#include <random>
2224

2325
#include <filesystem>
2426
#include <fstream>
2527

26-
namespace tensorrt_llm::benchmark
28+
TRTLLM_NAMESPACE_BEGIN
29+
30+
namespace benchmark
2731
{
2832

2933
std::vector<std::vector<SizeType32>> parseVectorOfVectors(std::string const& input)
@@ -98,7 +102,8 @@ Samples parseWorkloadJson(
98102
if (samples.size() < maxNumSamples)
99103
{
100104
TLLM_LOG_WARNING(
101-
"Dataset size %zu is smaller than given max_num_samples %d, max_num_samples will be ignored.\n",
105+
"Dataset size %zu is smaller than given max_num_samples "
106+
"%d, max_num_samples will be ignored.\n",
102107
samples.size(), maxNumSamples);
103108
}
104109
return samples;
@@ -160,4 +165,6 @@ std::ostream& operator<<(std::ostream& os, RecordBwMetric const& metric)
160165
return os;
161166
}
162167

163-
} // namespace tensorrt_llm::benchmark
168+
} // namespace benchmark
169+
170+
TRTLLM_NAMESPACE_END

benchmarks/cpp/utils/utils.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19+
#include "tensorrt_llm/common/config.h"
1920
#include "tensorrt_llm/executor/executor.h"
2021

2122
#include <cstdint>
@@ -29,7 +30,9 @@
2930

3031
#pragma once
3132

32-
namespace tensorrt_llm::benchmark
33+
TRTLLM_NAMESPACE_BEGIN
34+
35+
namespace benchmark
3336
{
3437

3538
// using namespace tensorrt_llm::batch_manager;
@@ -237,4 +240,6 @@ std::vector<double> generateRandomExponentialValues(int count, float lambda, int
237240

238241
std::vector<double> computeTimeDelays(BenchmarkParams const& benchmarkParams, int numDelays);
239242

240-
} // namespace tensorrt_llm::benchmark
243+
} // namespace benchmark
244+
245+
TRTLLM_NAMESPACE_END

cpp/include/tensorrt_llm/common/algorithm.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
#pragma once
1818

19-
namespace tensorrt_llm
20-
{
19+
#include "tensorrt_llm/common/config.h"
20+
21+
TRTLLM_NAMESPACE_BEGIN
2122

2223
// Base class for algorithms
2324
struct Algorithm
@@ -29,4 +30,4 @@ struct Algorithm
2930
Algorithm& operator=(Algorithm const&) = delete;
3031
};
3132

32-
} // namespace tensorrt_llm
33+
TRTLLM_NAMESPACE_END

cpp/include/tensorrt_llm/common/arrayView.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717
#pragma once
1818

1919
#include "tensorrt_llm/common/assert.h"
20+
#include "tensorrt_llm/common/config.h"
21+
2022
#include <cstdint>
2123

22-
namespace tensorrt_llm::common
24+
TRTLLM_NAMESPACE_BEGIN
25+
26+
namespace common
2327
{
2428

2529
//!
@@ -100,4 +104,6 @@ class ArrayView
100104
size_type mSize;
101105
};
102106

103-
} // namespace tensorrt_llm::common
107+
} // namespace common
108+
109+
TRTLLM_NAMESPACE_END

cpp/include/tensorrt_llm/common/assert.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@
1616

1717
#pragma once
1818

19+
#include "tensorrt_llm/common/config.h"
1920
#include "tensorrt_llm/common/tllmException.h"
2021

22+
TRTLLM_NAMESPACE_BEGIN
23+
2124
class DebugConfig
2225
{
2326
public:
2427
static bool isCheckDebugEnabled();
2528
};
2629

30+
TRTLLM_NAMESPACE_END
31+
2732
#if defined(_WIN32)
2833
#define TLLM_LIKELY(x) (__assume((x) == 1), (x))
2934
#define TLLM_UNLIKELY(x) (__assume((x) == 0), (x))
@@ -35,8 +40,8 @@ class DebugConfig
3540
#define TLLM_CHECK(val) \
3641
do \
3742
{ \
38-
TLLM_LIKELY(static_cast<bool>(val)) ? ((void) 0) \
39-
: tensorrt_llm::common::throwRuntimeError(__FILE__, __LINE__, #val); \
43+
TLLM_LIKELY(static_cast<bool>(val)) \
44+
? ((void) 0) : tensorrt_llm::common::throwRuntimeError(__FILE__, __LINE__, #val); \
4045
} while (0)
4146

4247
#define TLLM_CHECK_WITH_INFO(val, info, ...) \
@@ -51,17 +56,17 @@ class DebugConfig
5156
#define TLLM_CHECK_DEBUG(val) \
5257
do \
5358
{ \
54-
if (TLLM_UNLIKELY(DebugConfig::isCheckDebugEnabled())) \
59+
if (TLLM_UNLIKELY(tensorrt_llm::DebugConfig::isCheckDebugEnabled())) \
5560
{ \
56-
TLLM_LIKELY(static_cast<bool>(val)) ? ((void) 0) \
57-
: tensorrt_llm::common::throwRuntimeError(__FILE__, __LINE__, #val); \
61+
TLLM_LIKELY(static_cast<bool>(val)) \
62+
? ((void) 0) : tensorrt_llm::common::throwRuntimeError(__FILE__, __LINE__, #val); \
5863
} \
5964
} while (0)
6065

6166
#define TLLM_CHECK_DEBUG_WITH_INFO(val, info, ...) \
6267
do \
6368
{ \
64-
if (TLLM_UNLIKELY(DebugConfig::isCheckDebugEnabled())) \
69+
if (TLLM_UNLIKELY(tensorrt_llm::DebugConfig::isCheckDebugEnabled())) \
6570
{ \
6671
TLLM_LIKELY(static_cast<bool>(val)) \
6772
? ((void) 0) \

cpp/include/tensorrt_llm/common/bindingUtils.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717
#pragma once
1818

1919
#include "c10/util/intrusive_ptr.h"
20+
#include "tensorrt_llm/common/config.h"
21+
2022
#include <Python.h>
2123

22-
namespace tensorrt_llm::common
24+
TRTLLM_NAMESPACE_BEGIN
25+
26+
namespace common
2327
{
2428

2529
// Adapted from pybind11's example implementation:
@@ -69,4 +73,6 @@ c10::intrusive_ptr<T> get_intrusive_ptr(PyObject* py_obj, std::string pybind11_a
6973
return c10::intrusive_ptr<T>::reclaim_copy(p);
7074
}
7175

72-
} // namespace tensorrt_llm::common
76+
} // namespace common
77+
78+
TRTLLM_NAMESPACE_END
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2022-2025, 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+
17+
#pragma once
18+
#ifndef TRTLLM_CONFIG_H
19+
#define TRTLLM_CONFIG_H
20+
21+
/**
22+
* \def TRTLLM_ABI_NAMESPACE
23+
* This macro is used to open an implicitly inline namespace block for the ABI version.
24+
* This macro can be overridden to change the ABI version.
25+
* The default ABI version is _v1.
26+
*/
27+
#ifndef TRTLLM_ABI_NAMESPACE
28+
#define TRTLLM_ABI_NAMESPACE _v1
29+
#endif
30+
31+
#ifndef TRTLLM_ABI_NAMESPACE_BEGIN
32+
#define TRTLLM_ABI_NAMESPACE_BEGIN \
33+
inline namespace TRTLLM_ABI_NAMESPACE \
34+
{
35+
#endif
36+
37+
#ifndef TRTLLM_ABI_NAMESPACE_END
38+
#define TRTLLM_ABI_NAMESPACE_END }
39+
#endif
40+
41+
/**
42+
* \def TRTLLM_NAMESPACE_BEGIN
43+
* This macro is used to open a `tensorrt_llm::` namespace block, along with any
44+
* enclosing namespaces requested by TRTLLM_WRAPPED_NAMESPACE, etc.
45+
* This macro is defined by TensorRT-LLM and may not be overridden.
46+
*/
47+
#define TRTLLM_NAMESPACE_BEGIN \
48+
namespace tensorrt_llm \
49+
{ \
50+
TRTLLM_ABI_NAMESPACE_BEGIN
51+
52+
/**
53+
* \def TRTLLM_NAMESPACE_END
54+
* This macro is used to close a `tensorrt_llm::` namespace block, along with any
55+
* enclosing namespaces requested by TRTLLM_WRAPPED_NAMESPACE, etc.
56+
* This macro is defined by TensorRT-LLM and may not be overridden.
57+
*/
58+
#define TRTLLM_NAMESPACE_END \
59+
TRTLLM_ABI_NAMESPACE_END \
60+
} /* end namespace tensorrt_llm */
61+
62+
#endif // TRTLLM_CONFIG_H

cpp/include/tensorrt_llm/common/cudaFp8Utils.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#pragma once
1818

19+
#include "tensorrt_llm/common/config.h"
20+
1921
#ifdef ENABLE_FP8
2022
#include <cuda_fp8.h>
2123
#include <cuda_runtime.h>
@@ -29,8 +31,8 @@
2931
#define USE_QGMMA
3032
#endif
3133

32-
namespace tensorrt_llm
33-
{
34+
TRTLLM_NAMESPACE_BEGIN
35+
3436
namespace common
3537
{
3638

@@ -320,5 +322,6 @@ void invokeComputeScalesAndQuantizeMatrix(T_OUT* output, T_S* quant_ptr, const T
320322
const int64_t lda, QuantizeMode quantize_mode, cudaStream_t stream);
321323

322324
} // namespace common
323-
} // namespace tensorrt_llm
325+
326+
TRTLLM_NAMESPACE_END
324327
#endif // ENABLE_FP8

0 commit comments

Comments
 (0)