Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions vllm/config/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ class ParallelConfig:
enable_elastic_ep: bool = False
"""Enable elastic expert parallelism with stateless NCCL groups for DP/EP."""

enable_ep_fault_tolerance: bool = False
"""Enable EP fault tolerance. When a DP engine process dies, the redesign's
fault-tolerance supervisor publishes ``FaultInfo(DEAD)`` on its bus; an
external orchestrator (or operator) can then ``POST /fault_tolerance/apply``
with ``instruction="scale_down"`` to recover. Requires
``enable_elastic_ep=True``, ``data_parallel_backend="ray"``,
``tensor_parallel_size=1``, and ``enable_fault_tolerance=True`` (the master
FT switch)."""

enable_fault_tolerance: bool = False
"""Master switch for the fault-tolerance framework. Enables the
:class:`~vllm.v1.fault_tolerance.default_supervisor.DefaultFaultSupervisor`
on each engine, registers HTTP endpoints under ``/fault_tolerance/*``, and
activates the typed ``FaultSignal`` path on ``ModelRunnerOutput``. This
flag is orthogonal to ``enable_ep_fault_tolerance``: it provides the
framework; ``enable_ep_fault_tolerance`` gates the EP-specific
scale-down plan."""

enable_dbo: bool = False
"""Enable dual batch overlap for the model executor."""
ubatch_size: int = 0
Expand Down Expand Up @@ -653,13 +671,26 @@ def local_world_size(self) -> int:
return self.world_size // self.nnodes_within_dp

@staticmethod
def has_unfinished_dp(dp_group: ProcessGroup, has_unfinished: bool) -> bool:
def has_unfinished_dp(
dp_group: ProcessGroup,
has_unfinished: bool,
fault_tolerant: bool = False,
) -> bool:
tensor = torch.tensor([has_unfinished], dtype=torch.int32, device="cpu")
# dp rank 0: has_unfinished_seqs=True
# dp rank 1: has_unfinished_seqs=False
# aggregated: has_unfinished_seqs=True
# so this is an OR operation, i.e. MAX in integers
torch.distributed.all_reduce(tensor, op=ReduceOp.MAX, group=dp_group)
try:
torch.distributed.all_reduce(tensor, op=ReduceOp.MAX, group=dp_group)
except Exception:
if not fault_tolerant:
raise
logger.warning(
"DP all-reduce timed out — a peer may be dead. "
"Continuing in fault-tolerant mode."
)
return True
aggregated_has_unfinished = bool(tensor.item())
return aggregated_has_unfinished

Expand Down Expand Up @@ -782,6 +813,17 @@ def __post_init__(self) -> None:
"server and core client to coordinate scale up/down."
)

if self.enable_ep_fault_tolerance:
if not self.enable_elastic_ep:
raise ValueError("EP fault tolerance requires enable_elastic_ep=True.")
if self.tensor_parallel_size > 1:
raise ValueError(
"EP fault tolerance requires tensor_parallel_size=1. "
"With TP>1, a dead process would hang the NCCL TP group."
)
if self.data_parallel_size <= 1:
raise ValueError("EP fault tolerance requires data_parallel_size > 1.")

if self.data_parallel_size > 1 or self.data_parallel_size_local == 0:
# Data parallel was specified in the engine args.
if self.distributed_executor_backend == "external_launcher":
Expand Down
49 changes: 49 additions & 0 deletions vllm/distributed/device_communicators/all2all.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,14 @@ def set_num_sms(self, num_sms: int):
class DeepEPLLAll2AllManager(DeepEPAll2AllManagerBase):
"""
All2All communication based on DeepEP Low-Latency kernels.

Implements the :class:`vllm.v1.fault_tolerance.maskable.FTMaskBuffer`
capability for FT-aware backends — see ``query_mask`` / ``clean_mask``.
"""

def __init__(self, cpu_group, tcp_store_group=None):
super().__init__(cpu_group, tcp_store_group)
self._buffer: Any = None

def _make_all2all_kwargs(
self,
Expand Down Expand Up @@ -317,17 +321,44 @@ def get_handle(self, kwargs):
handle: deep_ep.Buffer = self.handle_cache.get_or_create(
buffer_kwargs, deep_ep.Buffer
)
# Remember the buffer so query_mask / clean_mask can reach it.
self._buffer = handle
return handle

# DeepEP LL uses RDMA so no SMs are used for communication
def max_sms_used(self) -> int | None:
return 0

# ---- FTMaskBuffer capability (vllm.v1.fault_tolerance.maskable) --------

def query_mask(self, mask: torch.Tensor) -> torch.Tensor:
"""Read the per-peer fault mask. See FTMaskBuffer protocol."""
import deep_ep # type: ignore[import-not-found]

if not isinstance(self._buffer, deep_ep.Buffer):
raise RuntimeError(
"DeepEPLLAll2AllManager.query_mask called before get_handle"
)
return self._buffer.low_latency_query_mask_buffer(mask)

def clean_mask(self) -> None:
"""Reset the per-peer fault mask to zero. See FTMaskBuffer protocol."""
import deep_ep # type: ignore[import-not-found]

if not isinstance(self._buffer, deep_ep.Buffer):
raise RuntimeError(
"DeepEPLLAll2AllManager.clean_mask called before get_handle"
)
self._buffer.low_latency_clean_mask_buffer()


class NixlEPAll2AllManager(All2AllManagerBase):
"""
All2All communication based on NIXL EP kernels.
This backend supports elastic EP with dynamic rank connection/disconnection.

Implements the :class:`vllm.v1.fault_tolerance.maskable.FTMaskBuffer`
capability for FT-aware backends — see ``query_mask`` / ``clean_mask``.
"""

# (nixl_ep_buffer, ep_size)
Expand Down Expand Up @@ -438,6 +469,24 @@ def destroy(self):
def max_sms_used(self) -> int | None:
return 0

# ---- FTMaskBuffer capability (vllm.v1.fault_tolerance.maskable) --------

def query_mask(self, mask: torch.Tensor) -> torch.Tensor:
"""Read the per-peer fault mask. See FTMaskBuffer protocol."""
if NixlEPAll2AllManager._buffer is None:
raise RuntimeError(
"NixlEPAll2AllManager.query_mask called before buffer init"
)
return NixlEPAll2AllManager._buffer[0].query_mask_buffer(mask)

def clean_mask(self) -> None:
"""Reset the per-peer fault mask to zero. See FTMaskBuffer protocol."""
if NixlEPAll2AllManager._buffer is None:
raise RuntimeError(
"NixlEPAll2AllManager.clean_mask called before buffer init"
)
NixlEPAll2AllManager._buffer[0].clean_mask_buffer()


class FlashInferNVLinkTwoSidedManager(All2AllManagerBase):
"""
Expand Down
18 changes: 18 additions & 0 deletions vllm/distributed/device_communicators/base_device_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ def combine(self, hidden_states: torch.Tensor, is_sequence_parallel: bool = Fals
def destroy(self):
pass

def abort(self):
"""Forcefully abort without waiting for peers.

No NCCL comms in the base class. Subclasses that introduce NCCL
communicators must override this to call ncclCommAbort instead of
ncclCommDestroy to avoid hanging when a peer rank has died.
"""
pass


class DeviceCommunicatorBase:
"""
Expand Down Expand Up @@ -312,6 +321,15 @@ def broadcast(self, tensor: torch.Tensor, src: int = 0) -> torch.Tensor:
def destroy(self):
pass

def abort(self):
"""Forcefully abort the communicator without waiting for peers.

Subclasses that wrap NCCL communicators must override this to
call ncclCommAbort instead of ncclCommDestroy to avoid hanging
when a peer rank has died.
"""
pass

def prepare_communication_buffer_for_model(self, model: torch.nn.Module) -> None:
"""
Prepare the communication buffer for the model.
Expand Down
23 changes: 23 additions & 0 deletions vllm/distributed/device_communicators/cuda_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,29 @@ def destroy(self):
self.all2all_manager.destroy()
self.all2all_manager = None # type: ignore[assignment]

def abort(self):
"""Forcefully abort the NCCL communicator via ncclCommAbort.

Unlike destroy() (which calls ncclCommDestroy and may trigger an
implicit ncclCommFinalize collective that hangs when a peer is
dead), abort is unconditionally safe in fault scenarios.

Sub-communicators (fi_ar_comm, all2all_manager) don't wrap NCCL
comms today, but we call abort() for consistency so that the
fault path stays correct if they ever gain NCCL dependencies.
"""
if self.pynccl_comm is not None:
self.pynccl_comm.abort()
self.pynccl_comm = None
if self.ca_comm is not None:
self.ca_comm = None
if self.fi_ar_comm is not None:
self.fi_ar_comm.abort()
self.fi_ar_comm = None
if self.all2all_manager is not None:
self.all2all_manager.abort()
self.all2all_manager = None # type: ignore[assignment]

def all_gatherv(
self,
input_: torch.Tensor | list[torch.Tensor],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,12 @@ def all_reduce(self, input_tensor: torch.Tensor) -> torch.Tensor:
def destroy(self):
if not self.disabled:
destroy_fi_ar_workspace()

def abort(self):
"""Forcefully abort without waiting for peers.

No NCCL comms here. If NCCL communicators are ever added, this
must call ncclCommAbort instead of ncclCommDestroy to avoid
hanging when a peer rank has died.
"""
self.destroy()
13 changes: 13 additions & 0 deletions vllm/distributed/device_communicators/pynccl.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ def destroy(self):
self.available = False
self.disabled = True

def abort(self):
"""Forcefully abort the NCCL communicator via ncclCommAbort.

Unlike destroy() (which calls ncclCommDestroy and may trigger an
implicit ncclCommFinalize collective), abort is safe to call when
a peer rank has died and would otherwise cause destroy to hang.
"""
if self.available and not self.disabled:
with torch.accelerator.device_index(self.device.index):
self.nccl.ncclCommAbort(self.comm)
self.available = False
self.disabled = True

def all_reduce(
self,
in_tensor: torch.Tensor,
Expand Down
5 changes: 5 additions & 0 deletions vllm/distributed/device_communicators/pynccl_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ class NCCLLibrary:
# it is better not to call it at all.
# ncclResult_t ncclCommDestroy(ncclComm_t comm);
Function("ncclCommDestroy", ncclResult_t, [ncclComm_t]),
# ncclResult_t ncclCommAbort(ncclComm_t comm);
Function("ncclCommAbort", ncclResult_t, [ncclComm_t]),
# ncclResult_t ncclGroupStart();
Function("ncclGroupStart", ncclResult_t, []),
# ncclResult_t ncclGroupEnd();
Expand Down Expand Up @@ -548,6 +550,9 @@ def ncclBroadcast(
def ncclCommDestroy(self, comm: ncclComm_t) -> None:
self.NCCL_CHECK(self._funcs["ncclCommDestroy"](comm))

def ncclCommAbort(self, comm: ncclComm_t) -> None:
self.NCCL_CHECK(self._funcs["ncclCommAbort"](comm))

def ncclGroupStart(self) -> None:
self.NCCL_CHECK(self._funcs["ncclGroupStart"]())

Expand Down
Loading
Loading