Make CUDA graph disabling PD-role-aware (prefill/decode) (#30409)
This commit is contained in:
@@ -76,8 +76,6 @@ def handle_pd_disaggregation(server_args: ServerArgs) -> None:
|
||||
server_args.disaggregation_transfer_backend != "fake"
|
||||
), "Prefill server does not support 'fake' as the transfer backend"
|
||||
|
||||
server_args.disable_cuda_graph = True
|
||||
|
||||
if server_args.disaggregation_mode in ("prefill", "decode"):
|
||||
if (
|
||||
envs.SGLANG_DISAGG_STAGING_BUFFER.get()
|
||||
|
||||
@@ -3335,11 +3335,10 @@ class ServerArgs:
|
||||
# ------------------------------------------------------------------
|
||||
# CUDA graph configuration resolution
|
||||
# ------------------------------------------------------------------
|
||||
# TODO: add unit tests in test/srt/test_server_args.py covering the
|
||||
# precedence cascade + auto-disable matrix (follow-up PR).
|
||||
def _handle_cuda_graph_config(self):
|
||||
self._parse_cuda_graph_config()
|
||||
self._apply_cuda_graph_compatibility()
|
||||
self._apply_cuda_graph_disaggregation_roles()
|
||||
self._validate_cuda_graph_config()
|
||||
# Warn on the final resolved config (not inside the compat cascade —
|
||||
# that path is skipped when the user explicitly sets the backend,
|
||||
@@ -3429,6 +3428,14 @@ class ServerArgs:
|
||||
elif self.cuda_graph_config.prefill.backend == Backend.FULL:
|
||||
self._disable_full_prefill_cudagraph_if_incompatible()
|
||||
|
||||
def _apply_cuda_graph_disaggregation_roles(self):
|
||||
if self.disaggregation_mode == "prefill":
|
||||
if (Phase.DECODE, "backend") not in self._cuda_graph_config_locked:
|
||||
self.cuda_graph_config.decode.backend = Backend.DISABLED
|
||||
elif self.disaggregation_mode == "decode":
|
||||
if (Phase.PREFILL, "backend") not in self._cuda_graph_config_locked:
|
||||
self.cuda_graph_config.prefill.backend = Backend.DISABLED
|
||||
|
||||
def _disable_tc_piecewise_cudagraph_if_incompatible(self):
|
||||
from sglang.srt.arg_groups.overrides import resolved_view as _resolved_view
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from sglang.srt.distributed import get_tp_group
|
||||
from sglang.srt.managers.schedule_batch import ScheduleBatch
|
||||
from sglang.srt.managers.scheduler import GenerationBatchResult
|
||||
from sglang.srt.managers.tp_worker import TpModelWorker
|
||||
from sglang.srt.model_executor.cuda_graph_config import Backend
|
||||
from sglang.srt.model_executor.forward_batch_info import (
|
||||
CaptureHiddenMode,
|
||||
ForwardBatch,
|
||||
@@ -287,7 +288,9 @@ class DFlashWorkerV2(BaseSpecWorker):
|
||||
self._draft_worker.init_attention_backends()
|
||||
|
||||
def init_cuda_graphs(self):
|
||||
capture_decode_cuda_graph = not self.server_args.disable_cuda_graph
|
||||
capture_decode_cuda_graph = (
|
||||
self.server_args.cuda_graph_config.decode.backend != Backend.DISABLED
|
||||
)
|
||||
if is_cuda() and capture_decode_cuda_graph:
|
||||
available_mem = get_available_gpu_memory(self.device, self.gpu_id)
|
||||
if available_mem < 1.0:
|
||||
|
||||
@@ -1154,7 +1154,7 @@ class EAGLEWorkerV2(BaseSpecWorker):
|
||||
self.adaptive_controller.init_states(
|
||||
cuda_graph_bs=(
|
||||
None
|
||||
if self.server_args.disable_cuda_graph
|
||||
if check_cuda_graph_backend(Phase.DECODE, Backend.DISABLED)
|
||||
else self.server_args.cuda_graph_bs_decode
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user