Introduce CUDA graph debug mode with breakable CUDA graph (#19102)

Co-authored-by: Cheng Wan <54331508+ch-wan@users.noreply.github.com>
Co-authored-by: Cheng Wan <chwan@rice.edu>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
cctry
2026-04-11 00:36:56 -07:00
committed by GitHub
co-authored by Cheng Wan Cheng Wan Claude Opus 4.6
parent d11da2403c
commit f855a0bde6
9 changed files with 896 additions and 7 deletions
+25
View File
@@ -622,6 +622,7 @@ class ServerArgs:
disable_cuda_graph_padding: bool = False
enable_profile_cuda_graph: bool = False
enable_cudagraph_gc: bool = False
debug_cuda_graph: bool = False
enable_layerwise_nvtx_marker: bool = False
enable_nccl_nvls: bool = False
enable_symm_mem: bool = False
@@ -1167,6 +1168,9 @@ class ServerArgs:
# 17. Context parallel
if self.attn_cp_size > 1:
self.disable_piecewise_cuda_graph = True
# 18. CUDA Graph debug mode
if self.debug_cuda_graph:
self.disable_piecewise_cuda_graph = True
def _handle_gpu_memory_settings(self, gpu_mem):
"""
@@ -3629,6 +3633,19 @@ class ServerArgs:
envs.SGLANG_ENABLE_DETERMINISTIC_INFERENCE.set(
"1" if self.enable_deterministic_inference else "0"
)
if self.debug_cuda_graph:
if not is_cuda():
logger.warning(
"--debug-cuda-graph is not supported on non CUDA devices. "
"Disabling breakable CUDA graph."
)
self.debug_cuda_graph = False
else:
envs.SGLANG_USE_BREAKABLE_CUDA_GRAPH.set("1")
logger.warning(
"Debug mode for CUDA graph is enabled via breakable CUDA graph. "
"All operations will run eagerly through the graph capture/replay path."
)
def _handle_cache_compatibility(self):
if self.enable_hierarchical_cache and self.disable_radix_cache:
@@ -5650,6 +5667,14 @@ class ServerArgs:
action="store_true",
help="Enable garbage collection during CUDA graph capture. If disabled (default), GC is frozen during capture to speed up the process.",
)
parser.add_argument(
"--debug-cuda-graph",
action="store_true",
help="Enable debug/eager mode for CUDA graph using breakable CUDA graph. "
"When enabled, graph breaks are inserted so every operation runs eagerly "
"while still going through the CUDA graph capture / replay path. "
"Useful for debugging CUDA graph capture / replay issues.",
)
parser.add_argument(
"--enable-layerwise-nvtx-marker",
action="store_true",