Repository navigation
[TRTLLM-17005][refactor] Component-local C++ Tests (Part 5) #21024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Funatiq
merged 23 commits into
NVIDIA:main
from
Funatiq:dev/refactor/component-local-tests-5
Nov 6, 2026
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c4e514a
build: link whole-archive components in a foreach loop
Funatiq 953aff3
build: extract profiler configuration utilities into a common component
Funatiq b3f4c41
build: extract the runtime worker pool and migrate its unit test
Funatiq 15e8e78
build: extract NumPy tensor I/O into a runtime component
Funatiq 6fd2adb
build: extract the GDRCopy runtime wrapper and migrate its test
Funatiq 58e629b
build: extract runtime locality-domain support and migrate its test
Funatiq 1281e73
build: make the IPC/NVLS memory archive component-local
Funatiq 3e11e8a
build: decouple Torch utilities from the inference shared library
Funatiq 08f8322
build: extract host-only transfer agent identity generation
Funatiq 08f5a11
build: extract host context-transfer consensus from the MPI coordinator
Funatiq 1775766
build: extract LoRA modules and request validation into a runtime com…
Funatiq c8c0b6a
build: extract LoRA cache storage and migrate its unit test
Funatiq 00473d5
build: extract runtime utilities needed by component-local PEFT tests
Funatiq f5db879
build: extract PEFT cache management and migrate its unit test
Funatiq be4ebba
build: migrate host-accessible device allocator tests to a runtime co…
Funatiq 217c579
fix: reuse runtime topology in host-accessible memory component
Funatiq 3e5ce2c
build: make executor serialization utility tests component-local
Funatiq fd0752a
build: migrate user-buffer tests to a focused static kernel component
Funatiq eae75fc
fixup! build: decouple Torch utilities from the inference shared library
Funatiq d1540b5
refactor: share facade component targets in CMake
Funatiq 3a2cc51
docs: explain Torch utility C++20 requirement
Funatiq 7269ada
docs: clarify Torch utility consumer link requirements
Funatiq 656325d
build: sort facade component targets lexicographically
Funatiq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
cpp/tensorrt_llm/batch_manager/contextTransferVoteReducer.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * 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. | ||
| */ | ||
|
|
||
| #include "tensorrt_llm/batch_manager/contextTransferCoordinator.h" | ||
|
|
||
| #include "tensorrt_llm/common/assert.h" | ||
|
|
||
| namespace tensorrt_llm::batch_manager | ||
| { | ||
|
|
||
| ContextTransferVoteReducer::ContextTransferVoteReducer(int const participantCount) | ||
| : mParticipantCount(participantCount) | ||
| { | ||
| TLLM_CHECK_WITH_INFO(participantCount > 0, "Context-transfer consensus requires at least one participant."); | ||
| } | ||
|
|
||
| void ContextTransferVoteReducer::recordVote( | ||
| int const participantRank, std::uint64_t const requestId, ContextTransferVote const vote) | ||
| { | ||
| TLLM_CHECK_WITH_INFO(participantRank >= 0 && participantRank < mParticipantCount, | ||
| "Context-transfer consensus participant rank is out of range."); | ||
| TLLM_CHECK_WITH_INFO(vote == ContextTransferVote::kCompleted || vote == ContextTransferVote::kFailed, | ||
| "Context-transfer consensus received an invalid vote."); | ||
|
|
||
| auto [requestIt, inserted] = mRequestVotes.try_emplace(requestId, mParticipantCount); | ||
| static_cast<void>(inserted); | ||
| auto& requestVotes = requestIt->second; | ||
| auto& recordedVote = requestVotes.votes.at(static_cast<std::size_t>(participantRank)); | ||
| auto const packedVote = static_cast<std::uint64_t>(vote); | ||
| if (recordedVote != 0) | ||
| { | ||
| TLLM_CHECK_WITH_INFO( | ||
| recordedVote == packedVote, "Context-transfer participant changed its terminal vote for a request."); | ||
| return; | ||
| } | ||
|
|
||
| recordedVote = packedVote; | ||
| ++requestVotes.terminalCount; | ||
| requestVotes.failed = requestVotes.failed || vote == ContextTransferVote::kFailed; | ||
| } | ||
|
|
||
| void ContextTransferVoteReducer::recordTimeout(std::uint64_t const requestId) | ||
| { | ||
| auto [requestIt, inserted] = mRequestVotes.try_emplace(requestId, mParticipantCount); | ||
| static_cast<void>(inserted); | ||
| auto& requestVotes = requestIt->second; | ||
| if (!requestVotes.timedOut) | ||
| { | ||
| requestVotes.timedOut = true; | ||
| requestVotes.timeoutPending = true; | ||
| } | ||
| } | ||
|
|
||
| ContextTransferConsensusResult ContextTransferVoteReducer::takeReady() | ||
| { | ||
| ContextTransferConsensusResult result; | ||
| for (auto requestIt = mRequestVotes.begin(); requestIt != mRequestVotes.end();) | ||
| { | ||
| auto& requestVotes = requestIt->second; | ||
| if (requestVotes.timeoutPending) | ||
| { | ||
| result.timedOutRequestIds.insert(requestIt->first); | ||
| requestVotes.timeoutPending = false; | ||
| } | ||
| if (requestVotes.terminalCount != mParticipantCount) | ||
| { | ||
| ++requestIt; | ||
| continue; | ||
| } | ||
|
|
||
| auto& terminalRequestIds | ||
| = (requestVotes.failed || requestVotes.timedOut) ? result.failedRequestIds : result.completedRequestIds; | ||
| terminalRequestIds.insert(requestIt->first); | ||
| requestIt = mRequestVotes.erase(requestIt); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| void ContextTransferVoteReducer::clear() noexcept | ||
| { | ||
| mRequestVotes.clear(); | ||
| } | ||
|
|
||
| } // namespace tensorrt_llm::batch_manager |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.