Repository navigation
[None][fix] Decouple protected context-first GEN cancellation from retirement #22205
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
Open
chienchunhung
wants to merge
2
commits into
NVIDIA:main
Choose a base branch
from
chienchunhung:dev/pact-bf16-gen-cancellation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,621
−122
Open
Changes from all commits
Commits
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
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 |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from threading import Event, Lock, Thread | ||
| from typing import Callable, Optional | ||
|
|
@@ -125,6 +128,26 @@ def send(self, messages: list[bytes], recipient: Optional[bytes] = None) -> None | |
| else: | ||
| self._socket.send_multipart(messages) | ||
|
|
||
| def try_send(self, messages: list[bytes]) -> bool: | ||
| """Queue one DEALER message without waiting for transport capacity. | ||
|
|
||
| Args: | ||
| messages: Complete multipart message to queue. | ||
|
|
||
| Returns: | ||
| False on backpressure; the caller retains responsibility for retry. | ||
|
|
||
| Raises: | ||
| ValueError: The messenger is not a DEALER socket. | ||
| """ | ||
| if self._mode != "DEALER": | ||
| raise ValueError("try_send requires a DEALER socket") | ||
| try: | ||
| self._socket.send_multipart(messages, flags=zmq.DONTWAIT) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Nice to have] (R1: PR process) This PR overlaps open PRs that the description does not name; please state the merge order:
|
||
| except zmq.Again: | ||
| return False | ||
| return True | ||
|
|
||
| def receive(self, timeout_ms: Optional[int] = None) -> list[bytes]: | ||
| if timeout_ms is not None and not self._socket.poll(timeout_ms, zmq.POLLIN): | ||
| raise TimeoutError("Timed out waiting for a peer response") | ||
|
|
||
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
55 changes: 55 additions & 0 deletions
55
tensorrt_llm/_torch/disaggregation/orchestration/cancellation.py
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,55 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| """Request-level cancellation agreement, independent of backend evidence collection.""" | ||
|
|
||
| from dataclasses import dataclass | ||
| from enum import Enum | ||
| from typing import Sequence | ||
|
|
||
|
|
||
| class ReceiveCancellation(Enum): | ||
| """Logical cancellation disposition; no member authorizes memory reuse.""" | ||
|
|
||
| NOT_HANDLED = "not_handled" | ||
| PENDING = "pending" | ||
| CANCELLED = "cancelled" | ||
| FAILED = "failed" | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class ReceiveCancellationVote: | ||
| """Facts supplied by one qualified owner after closing further admission.""" | ||
|
|
||
| prior_failure: bool | ||
| access_ended: bool | ||
|
|
||
|
|
||
| def agree_receive_cancellation( | ||
| committed: ReceiveCancellation, | ||
| votes: Sequence[ReceiveCancellationVote | None], | ||
| ) -> tuple[ReceiveCancellation, bool]: | ||
| """Commit one logical outcome and separately agree physical retirement. | ||
|
|
||
| Args: | ||
| committed: PENDING until the first complete vote; terminal afterwards. | ||
| votes: One entry per required participant; None means no vote yet. | ||
|
|
||
| Returns: | ||
| The immutable logical outcome and whether every participant supplied | ||
| access-end evidence. The binding must still close its real owners. | ||
|
|
||
| Raises: | ||
| ValueError: An unsupported request was included in agreement. | ||
| """ | ||
| if committed is ReceiveCancellation.NOT_HANDLED: | ||
| raise ValueError("Unsupported cancellation cannot enter group agreement") | ||
| if not votes or any(vote is None for vote in votes): | ||
| return committed, False | ||
| present = [vote for vote in votes if vote is not None] | ||
| if committed is ReceiveCancellation.PENDING: | ||
| committed = ( | ||
| ReceiveCancellation.FAILED | ||
| if any(vote.prior_failure for vote in present) | ||
| else ReceiveCancellation.CANCELLED | ||
| ) | ||
| return committed, all(vote.access_ended for vote in present) |
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.