From 6bce72d9687d8a0ca9babf47821ed60f5baa16e3 Mon Sep 17 00:00:00 2001 From: Chetan Kumar Verma <39086835+ckvermaAI@users.noreply.github.com> Date: Thu, 9 Jul 2026 07:51:43 +0530 Subject: [PATCH] [Intel GPU] xpu_piecewise: fall back to eager when PCG capture stream is unset (#30235) Co-authored-by: Claude Opus 4.8 (1M context) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Ma Mingfei --- .../srt/compilation/xpu_piecewise_backend.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/compilation/xpu_piecewise_backend.py b/python/sglang/srt/compilation/xpu_piecewise_backend.py index e85ccb713..ca269d135 100644 --- a/python/sglang/srt/compilation/xpu_piecewise_backend.py +++ b/python/sglang/srt/compilation/xpu_piecewise_backend.py @@ -13,6 +13,7 @@ from sglang.srt.compilation.cuda_piecewise_backend import ( CUDAPiecewiseBackend, weak_ref_tensors, ) +from sglang.srt.utils.common import print_warning_once class XPUPiecewiseBackend(CUDAPiecewiseBackend): @@ -57,10 +58,22 @@ class XPUPiecewiseBackend(CUDAPiecewiseBackend): entry.num_finished_warmup += 1 return entry.runnable(*args) + # During normal capture (PiecewiseCudaGraphRunner.capture()), + # set_pcg_capture_stream() guarantees a valid stream. However, + # Dynamo may silently recompile on serving batches whose token + # count exceeds the captured range (e.g. chunked prefill running + # at 8192 tokens when the capture grid tops out at 512). The + # recompiled backend instance has no capture stream; fall back to + # eager for that sub-graph instead of crashing the scheduler. + # Mirrors the HIP fallback in CUDAPiecewiseBackend.__call__. stream = get_pcg_capture_stream() - assert ( - stream is not None - ), "PCG capture stream is not set, please check if runtime recompilation happened" + if stream is None: + print_warning_once( + "PCG capture stream is not set; likely a Dynamo runtime " + "recompilation. Falling back to eager execution for this " + "subgraph." + ) + return entry.runnable(*args) if self.compile_config.get_enable_debug_mode(): entry.input_addresses = [