diff --git a/python/sglang/srt/environ.py b/python/sglang/srt/environ.py index b02400e1d..e0c9f7e25 100644 --- a/python/sglang/srt/environ.py +++ b/python/sglang/srt/environ.py @@ -309,6 +309,10 @@ class Envs: # Scheduler: others: SGLANG_EMPTY_CACHE_INTERVAL = EnvFloat(-1) # in seconds. Set if you observe high memory accumulation over a long serving period. SGLANG_DISABLE_CONSECUTIVE_PREFILL_OVERLAP = EnvBool(False) + # Force-enable the WAR (write-after-read) barrier for the overlap scheduler + # even when is_cuda() is False (e.g. AMD/ROCm). On CUDA the barrier is + # already enabled regardless of this flag (see start_event_loop). + SGLANG_ENABLE_WAR_BARRIER = EnvBool(False) # PP: skip output send/recv when the entire batch consists of non-final chunked prefill requests, # since process_batch_result_prefill discards next_token_ids for those anyway. SGLANG_PP_SKIP_PURE_CHUNKED_OUTPUT_COMM = EnvBool(False) diff --git a/python/sglang/srt/managers/scheduler.py b/python/sglang/srt/managers/scheduler.py index baac7d214..0603e5473 100644 --- a/python/sglang/srt/managers/scheduler.py +++ b/python/sglang/srt/managers/scheduler.py @@ -1424,7 +1424,9 @@ class Scheduler( # DFLASH fences its shared req_to_token writes with verify_done / # plan-stream deps, so the global WAR barrier only serializes plan # overlap. TODO: generalize this global-barrier enablement policy. - self._war_barrier_enabled = is_cuda() and not self.spec_algorithm.is_dflash() + self._war_barrier_enabled = ( + is_cuda() or envs.SGLANG_ENABLE_WAR_BARRIER.get() + ) and not self.spec_algorithm.is_dflash() with self.device_module.StreamContext(self.schedule_stream): dispatch_event_loop(self)