Skip to content

Commit 530ab91

Browse files
committed
rebase
Signed-off-by: junq <[email protected]>
2 parents 43b18bd + 1388e84 commit 530ab91

File tree

128 files changed

+3336
-2052
lines changed

Some content is hidden

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

128 files changed

+3336
-2052
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
triton_backend/tools/gpt/input_data.json filter=lfs diff=lfs merge=lfs -text
88
*cubin.cpp filter=lfs diff=lfs merge=lfs -text
99
docs/source/blogs/media/tech_blog3_mla_absorb.png filter=lfs diff=lfs merge=lfs -text
10+
tests/integration/test_input_files/*.png filter=lfs diff=lfs merge=lfs -text
11+
tests/integration/test_input_files/*.jpg filter=lfs diff=lfs merge=lfs -text

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,5 +253,5 @@ Deprecation is used to inform developers that some APIs and tools are no longer
253253
## Useful Links
254254
- [Quantized models on Hugging Face](https://huggingface.co/collections/nvidia/model-optimizer-66aa84f7966b3150262481a4): A growing collection of quantized (e.g., FP8, FP4) and optimized LLMs, including [DeepSeek FP4](https://huggingface.co/nvidia/DeepSeek-R1-FP4), ready for fast inference with TensorRT-LLM.
255255
- [NVIDIA Dynamo](https://github.com/ai-dynamo/dynamo): A datacenter scale distributed inference serving framework that works seamlessly with TensorRT-LLM.
256-
- [AutoDeploy](./examples/auto_deploy/README.md): A prototype backend for TensorRT-LLM to simplify and accelerate the deployment of PyTorch models.
256+
- [AutoDeploy](https://nvidia.github.io/TensorRT-LLM/torch/auto_deploy/auto-deploy.html): A prototype backend for TensorRT-LLM to simplify and accelerate the deployment of PyTorch models.
257257
- [WeChat Discussion Group](https://github.com/NVIDIA/TensorRT-LLM/issues/5359): A real-time channel for TensorRT-LLM Q&A and news.

cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ add_compile_definitions("TLLM_GEN_EXPORT_INTERFACE")
6969
add_compile_definitions("TLLM_ENABLE_CUDA")
7070

7171
set(BINDING_TYPE
72-
"pybind"
72+
"nanobind"
7373
CACHE STRING
7474
"Binding type of Python bindings for C++ runtime and batch manager")
7575

cpp/include/tensorrt_llm/executor/dataTransceiverState.h

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,30 @@ class CacheState final
5252
AttentionType attentionType = AttentionType::kDEFAULT, int kvFactor = 2)
5353
: mModelConfig(std::move(modelConfig))
5454
, mParallelConfig{worldConfig.getTensorParallelism(), worldConfig.getPipelineParallelism(),
55-
worldConfig.enableAttentionDP(), worldConfig.getTensorParallelRank(), worldConfig.getTensorParallelism()}
55+
worldConfig.getContextParallelism(), worldConfig.enableAttentionDP(), worldConfig.getTensorParallelRank(),
56+
worldConfig.getTensorParallelism()}
5657
, mDataType{dataType}
5758
, mAttentionConfig(attentionType, kvFactor)
5859
{
5960
}
6061

6162
CacheState(std::vector<SizeType32> nbKvHeadPerLayer, SizeType32 sizePerHead, SizeType32 tokensPerBlock,
62-
SizeType32 tensorParallelism, SizeType32 pipelineParallelism, nvinfer1::DataType dataType,
63-
AttentionType attentionType = AttentionType::kDEFAULT, int kvFactor = 2, bool enableAttentionDP = false,
64-
int DPrank = 0, int DPsize = 0)
63+
SizeType32 tensorParallelism, SizeType32 pipelineParallelism, SizeType32 contextParallelism,
64+
nvinfer1::DataType dataType, AttentionType attentionType = AttentionType::kDEFAULT, int kvFactor = 2,
65+
bool enableAttentionDP = false, int DPrank = 0, int DPsize = 0)
6566
: mModelConfig{std::move(nbKvHeadPerLayer), sizePerHead, tokensPerBlock}
66-
, mParallelConfig{tensorParallelism, pipelineParallelism, enableAttentionDP, DPrank, DPsize}
67+
, mParallelConfig{tensorParallelism, pipelineParallelism, contextParallelism, enableAttentionDP, DPrank, DPsize}
6768
, mDataType{dataType}
6869
, mAttentionConfig(attentionType, kvFactor)
6970
{
7071
}
7172

7273
CacheState(SizeType32 nbAttentionLayers, SizeType32 nbKvHeads, SizeType32 sizePerHead, SizeType32 tokensPerBlock,
73-
SizeType32 tensorParallelism, SizeType32 pipelineParallelism, nvinfer1::DataType dataType,
74-
AttentionType attentionType = AttentionType::kDEFAULT, int kvFactor = 2, bool enableAttentionDP = false,
75-
int DPrank = 0, int DPsize = 0)
74+
SizeType32 tensorParallelism, SizeType32 pipelineParallelism, SizeType32 contextParallelism,
75+
nvinfer1::DataType dataType, AttentionType attentionType = AttentionType::kDEFAULT, int kvFactor = 2,
76+
bool enableAttentionDP = false, int DPrank = 0, int DPsize = 0)
7677
: mModelConfig{std::vector(nbAttentionLayers, nbKvHeads), sizePerHead, tokensPerBlock}
77-
, mParallelConfig{tensorParallelism, pipelineParallelism, enableAttentionDP, DPrank, DPsize}
78+
, mParallelConfig{tensorParallelism, pipelineParallelism, contextParallelism, enableAttentionDP, DPrank, DPsize}
7879
, mDataType{dataType}
7980
, mAttentionConfig(attentionType, kvFactor)
8081
{
@@ -83,7 +84,7 @@ class CacheState final
8384
[[nodiscard]] bool operator==(kv_cache::CacheState const& other) const noexcept
8485
{
8586
return mModelConfig == other.mModelConfig && mParallelConfig == other.mParallelConfig
86-
&& mDataType == other.mDataType;
87+
&& mAttentionConfig == other.mAttentionConfig && mDataType == other.mDataType;
8788
}
8889

8990
struct ModelConfig
@@ -103,15 +104,16 @@ class CacheState final
103104
{
104105
SizeType32 mTensorParallelism;
105106
SizeType32 mPipelineParallelism;
107+
SizeType32 mContextParallelism;
106108
bool mEnableAttentionDP;
107109
SizeType32 mDPrank;
108110
SizeType32 mDPsize;
109111

110112
[[nodiscard]] bool operator==(ParallelConfig const& other) const noexcept
111113
{
112114
return mTensorParallelism == other.mTensorParallelism && mPipelineParallelism == other.mPipelineParallelism
113-
&& mEnableAttentionDP == other.mEnableAttentionDP && mDPrank == other.mDPrank
114-
&& mDPsize == other.mDPsize;
115+
&& mContextParallelism == other.mContextParallelism && mEnableAttentionDP == other.mEnableAttentionDP
116+
&& mDPrank == other.mDPrank && mDPsize == other.mDPsize;
115117
}
116118
};
117119

@@ -125,6 +127,11 @@ class CacheState final
125127
{
126128
}
127129

130+
[[nodiscard]] bool operator==(AttentionConfig const& other) const noexcept
131+
{
132+
return mAttentionType == other.mAttentionType && mKvFactor == other.mKvFactor;
133+
}
134+
128135
// attentionType ;
129136
AttentionType mAttentionType;
130137
int mKvFactor;
@@ -162,6 +169,7 @@ class CacheState final
162169
sstring << "mTokensPerBlock:" << mModelConfig.mTokensPerBlock << "\n";
163170
sstring << "tp:" << mParallelConfig.mTensorParallelism << "\n";
164171
sstring << "pp:" << mParallelConfig.mPipelineParallelism << "\n";
172+
sstring << "cp:" << mParallelConfig.mContextParallelism << "\n";
165173
sstring << "enableAttentionDP:" << mParallelConfig.mEnableAttentionDP << "\n";
166174
sstring << "datatype:" << static_cast<int32_t>(mDataType) << "\n";
167175
sstring << "attentionType:" << static_cast<int32_t>(mAttentionConfig.mAttentionType) << "\n";

cpp/micro_benchmarks/mixtureOfExpertsBackendBenchmarkFixture.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ class MixtureOfExpertsBenchmark : public ::benchmark::Fixture
833833
// Runs for 3 iterations or 1 second and picks the best option
834834
int pickBestTactic(MOEParallelismConfig parallelism_config, GemmToProfile gemm_to_profile)
835835
{
836-
auto tactics = mMoERunner.getTactics();
836+
auto tactics = mMoERunner.getTactics(static_cast<MoeGemmId>(gemm_to_profile));
837837
::nvtx3::scoped_range nvtx(tensorrt_llm::common::nvtx::nextColor(),
838838
"Tactic Profiling GEMM " + std::to_string(static_cast<int>(gemm_to_profile)));
839839
// We save space by reusing the same workspace buffer for all tactics when doing full layer profiling. So we
@@ -925,12 +925,14 @@ class MixtureOfExpertsBenchmark : public ::benchmark::Fixture
925925
std::pair<int, int> setTactic(
926926
int tactic_idx1, int tactic_idx2, MOEParallelismConfig parallelism_config, GemmToProfile gemm_to_profile)
927927
{
928-
auto tactics = mMoERunner.getTactics();
928+
auto tactics1 = mMoERunner.getTactics(MoeGemmId::GEMM_1);
929+
auto tactics2 = mMoERunner.getTactics(MoeGemmId::GEMM_2);
929930
std::vector<std::pair<std::reference_wrapper<int>, GemmToProfile>> tactics_to_profile{
930931
{tactic_idx1, GemmToProfile::GEMM_1}, {tactic_idx2, GemmToProfile::GEMM_2}};
931932
for (auto& combo : tactics_to_profile)
932933
{
933934
auto& t = combo.first.get();
935+
auto& tactics = combo.second == GemmToProfile::GEMM_1 ? tactics1 : tactics2;
934936
if (combo.second != gemm_to_profile && gemm_to_profile != GemmToProfile::LAYER)
935937
{
936938
t = 0; // Unneeded tactic, set to 0
@@ -947,7 +949,7 @@ class MixtureOfExpertsBenchmark : public ::benchmark::Fixture
947949
}
948950
}
949951

950-
mMoERunner.setTactic(tactics[tactic_idx1], tactics[tactic_idx2]);
952+
mMoERunner.setTactic(tactics1[tactic_idx1], tactics2[tactic_idx2]);
951953
mBestTacticGemm1 = tactic_idx1;
952954
mBestTacticGemm2 = tactic_idx2;
953955
return {tactic_idx1, tactic_idx2};
@@ -965,7 +967,7 @@ class MixtureOfExpertsBenchmark : public ::benchmark::Fixture
965967
auto expert_weights_size
966968
= gemm_to_profile == GemmToProfile::GEMM_1 ? mExpertWeight1Size : mExpertWeight2Size;
967969

968-
auto tactics = mMoERunner.getTactics()[tactic_idx];
970+
auto tactics = mMoERunner.getTactics(static_cast<MoeGemmId>(gemm_to_profile))[tactic_idx];
969971
if (static_cast<int>(gemm_to_profile) != static_cast<int>(mGemmProfilerBackend.mGemmToProfile))
970972
{
971973
throw std::runtime_error("Configuration mismatch between mGemmProfilerBackend and runMoEPermute");
@@ -1074,11 +1076,12 @@ void MixtureOfExpertsBenchmark<TypeTuple_>::runBenchmark(benchmark::State& state
10741076
}
10751077
if (LOG_LEVEL >= INFO)
10761078
{
1077-
auto tactics = mMoERunner.getTactics();
1078-
std::cout << "Selected tactic #1: " << tactic_idx1 << "/" << tactics.size() << "\n"
1079-
<< tactics[tactic_idx1].toString() << std::endl;
1080-
std::cout << "Selected tactic #2: " << tactic_idx2 << "/" << tactics.size() << "\n"
1081-
<< tactics[tactic_idx2].toString() << std::endl;
1079+
auto tactics1 = mMoERunner.getTactics(MoeGemmId::GEMM_1);
1080+
auto tactics2 = mMoERunner.getTactics(MoeGemmId::GEMM_2);
1081+
std::cout << "Selected tactic #1: " << tactic_idx1 << "/" << tactics1.size() << "\n"
1082+
<< tactics1[tactic_idx1].toString() << std::endl;
1083+
std::cout << "Selected tactic #2: " << tactic_idx2 << "/" << tactics2.size() << "\n"
1084+
<< tactics2[tactic_idx2].toString() << std::endl;
10821085
}
10831086
state.counters["tactic_idx1"] = tactic_idx1;
10841087
state.counters["tactic_idx2"] = tactic_idx2;

0 commit comments

Comments
 (0)