mirror of
https://github.com/deepseek-ai/DeepEP.git
synced 2026-11-05 00:47:32 +00:00
[PR #370] [MERGED] [Feature] Add Elasticity Support to DeepEP for Fault-Tolerant EP Inference #538
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepEP#538
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepEP/pull/370
Author: @jammycc
Created: 8/21/2025
Status: ✅ Merged
Merged: 9/25/2025
Merged by: @sphish
Base:
main← Head:elastic📝 Commits (10+)
78349f8support EP elastic shrink3507f2aAdd test script for EP shrink failover6195f87add coll buffer and allgather apic7e11f5remove allgather api, merge barrier and clean kernels, rename elastic to shrink0535a7bfix bug6bd18ffrefine code, add shrink test scriptef616aarefine codec683c3frefine code3e326a7fix bugc6a7030add/remove blank lines📊 Changes
6 files changed (+420 additions, -102 deletions)
View changed files
📝
csrc/deep_ep.cpp(+44 -2)📝
csrc/deep_ep.hpp(+12 -1)📝
csrc/kernels/api.cuh(+9 -0)📝
csrc/kernels/internode_ll.cu(+259 -90)📝
deep_ep/buffer.py(+32 -2)📝
tests/test_low_latency.py(+64 -7)📄 Description
Motivation and Target
This PR ensures that large-scale Expert Parallel (EP) inference remain operational in a downscaled state when encountering failures — such as individual GPU, NIC, or node outages, or even corner-case engine failures, instead of a full teardown.
This provides the following benefits:
The downscaled deployment can still provide degraded (lower-capacity) service
For multi-endpoint/API-server setups, most requests will only experience a brief stall before resuming processing, rather than being entirely aborted.
This graceful degradation provides sufficient time for instance-level redeployment or recovery actions.
This PR includes
Enable
dispatchandcombineoperations to bypass failed ranks by introducing per-rank status information in the buffer, achieving real-time degradation.Decentralized rank failure detection, with each rank monitoring communication timeout to determine failure.
Provide query and update APIs for the engine to query and update per-rank status.
This PR does not include (as future work)
Support for Prefill phase / Normal kernels
If a Prefill request fails, it usually needs to be fully re-executed anyway, making fault tolerance less impactful.
In PD-disaggregated architectures, the Prefill stage typically uses smaller EP sizes — sometimes even single-node deployments.
Dynamic scaling up (expansion)
DeepEP Modifications
Currently, DeepEP’s low-latency (LL) kernels hang when any rank fails, causing the entire EP inference service and request processing pipeline to stall. We aim to enhance DeepEP with failure detection, graceful exit on faults, and dynamic downscaling. To this end, all communication-related APIs — including
low_latency_dispatch,low_latency_combine, andclean_low_latency_buffer— must support these capabilities.Additionally, since other engine-level collective communications (e.g., metadata synchronization within DP groups) can also be affected by rank failures, we introduce a new
low_latency_allgatherAPI to replace these collectives.1. Failure Detection and Downscaling via Mask Buffer
Each node maintains a mask buffer to track the status of all ranks. Once a rank failure is detected, its corresponding status in the mask buffer is set to 1, indicating that subsequent communication with this rank should be skipped.
Key Changes:
Add
enable_elasticparameter during buffer initialization to enable elastic mode. This triggers allocation of an additionalmask_bufferof sizenum_ranks(int32).Add timeout-based failure detection and rank masking in all communication APIs (
low_latency_dispatch,low_latency_combine,clean_low_latency_buffer) :If a rank's data is not received within
NUM_TIMEOUT_CYCLES, its status in the mask buffer is set to 1.Subsequent communication will neither receive data from nor send data to masked ranks.
New APIs:
low_latency_query_mask_buffer: Query current rank mask status.low_latency_update_mask_buffer: Manually update the mask status of a specific rank.2. Synchronization Mechanism via Sync Buffer
For non-dispatch/combine communication (e.g.,
clean_low_latency_buffer), global synchronization is required. Previously, this relied on NVSHMEM barriers, which fail if any rank is down.To support synchronization in downscaled scenarios:
Introduce a dedicated sync_buffer to track synchronization counters.
Replace global
nvshmem_barriercalls inclean_low_latency_bufferwith sync-buffer-based logic, enabling barrier even when some ranks are masked.3. New Collective Communication:
low_latency_allgatherWe observed that non-EP collectives (e.g., metadata sync in pure DP attention) can also be blocked by rank failures. To address this, we implement a fault-tolerant
low_latency_allgatherAPI to replace these communication.Add
num_coll_buffer_bytesparameter during initialization to allocate space for collective communication buffers.Use the sync_buffer for synchronization and skip masked ranks.
Engine Integration Example
We have validated this design by integrating DeepEP into vLLM. We briefly describe below how the engine integrates with DeepEP’s fault-tolerance features, using vLLM v1 as an example.
1. Enable Elastic Mode in DeepEP Initialization
2. Check Status After Each Decode Step
In
gpu_worker.py, theWorkerclass exposes acheck_step_statusmethod, called via RPC byEngineCoreto check for failures:3. Handle Detected Failures
Once
EngineCoredetects new failed ranks:Report to
LLMEngineTrigger expert rebalance (EPLB)
Recover requests (via migration or recomputation)
4. Handling Externally Triggered Failures
In
gpu_worker.py, theWorkerclass exposes aupdate_deepep_mask_buffermethod, called via RPC byEngineCoreto manually mask a rank:5. Redundant Expert Slots for CUDAGraph
Reserve extra expert slots per rank to accommodate experts from failed ranks.
Ensures sufficient capacity for redistribution upon single-rank failure.
6. Decoupling from Other Communication Backends
Replace other collectives (e.g., DP-group metadata sync) with DeepEP’s extended
low_latency_allgather.TP-group communication is not replaced, as entire TP groups can be treated as atomic units — if one fails, the whole group is isolated.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.