From be17475a1bf0360e6e3505a74a15df86a4f04e53 Mon Sep 17 00:00:00 2001 From: Liangsheng Yin Date: Sun, 28 Jun 2026 18:51:38 -0700 Subject: [PATCH] [Spec] Publish DFLASH verify read-done event for fine-grained WAR barrier (#29541) --- .../runner/decode_cuda_graph_runner.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/python/sglang/srt/model_executor/runner/decode_cuda_graph_runner.py b/python/sglang/srt/model_executor/runner/decode_cuda_graph_runner.py index ab7995237..c5d727a6b 100644 --- a/python/sglang/srt/model_executor/runner/decode_cuda_graph_runner.py +++ b/python/sglang/srt/model_executor/runner/decode_cuda_graph_runner.py @@ -995,14 +995,13 @@ class DecodeCudaGraphRunner(BaseCudaGraphRunner): ) with timer_ctx, self.backend.replay_session(): self.load_batch(forward_batch, pp_proxy_tensors) - # Snapshot built -- publish a read-done event for the WAR barrier. - # Only plain DECODE: the captured decode graph reads only its static - # snapshot, so the forward is done reading the shared pool here. Spec - # verify (target_verify/dllm_extend) replays on this runner too, but - # those are NOT the step's last shared-buffer-reading phase (eagle - # publishes from draft_extend; ngram/dflash must not publish here), - # and some verify graphs may read beyond the snapshot in replay. - if forward_batch.forward_mode.is_decode(): + # Publish a read-done event for the WAR barrier: a cuda-graph forward + # finishes its shared req_to_token / SWA reads at this pre-replay + # snapshot, so plain DECODE and DFLASH TARGET_VERIFY both qualify. + if forward_batch.forward_mode.is_decode() or ( + forward_batch.forward_mode.is_target_verify() + and self.model_runner.spec_algorithm.is_dflash() + ): read_done = self.device_module.Event() read_done.record() self.model_runner.war_fastpath_read_done_event = read_done