[misc] Rename SGLANG_OPT_SWA_RELEASE_LEAF_LOCK_AFTER_WINDOW to SGLANG_OPT_RELEASE_PREFILL_SWA (#42657)

This commit is contained in:
Liangsheng Yin
2026-10-05 17:24:15 -07:00
committed by GitHub
parent 4409d2fd22
commit f3fe753475
4 changed files with 12 additions and 11 deletions
+5 -1
View File
@@ -691,7 +691,11 @@ class Envs:
# - Source builds with a missing or unusable Rust toolchain.
# This also applies when Rust is explicitly selected.
SGLANG_UNIFIED_RADIX_TREE_CORE_BACKEND = EnvStr("rust")
SGLANG_OPT_SWA_RELEASE_LEAF_LOCK_AFTER_WINDOW = EnvBool(False)
# Once decode passes the sliding window, drop the SWA part of the prefill's
# tree lock; its SWA KV becomes evictable rather than freed.
SGLANG_OPT_RELEASE_PREFILL_SWA = EnvBoolWithAlias(
False, deprecated_name="SGLANG_OPT_SWA_RELEASE_LEAF_LOCK_AFTER_WINDOW"
)
# ===================================================================
# PD disaggregation runtime
+4 -7
View File
@@ -3919,9 +3919,8 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
# Auxiliary windows check their own cursors and prefix locks.
has_auxiliary_swa = self.tree_cache.supports_auxiliary_swa()
release_leaf_lock = (
envs.SGLANG_OPT_SWA_RELEASE_LEAF_LOCK_AFTER_WINDOW.get()
and hasattr(self.tree_cache, "dec_swa_lock_only")
release_leaf_lock = envs.SGLANG_OPT_RELEASE_PREFILL_SWA.get() and hasattr(
self.tree_cache, "dec_swa_lock_only"
)
eviction_interval = max(1, envs.SGLANG_SWA_EVICTION_INTERVAL.get())
@@ -3949,10 +3948,8 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
),
)
# Once the decode position has moved past the sliding window,
# the SWA portion of the prefill-time tree lock is no longer
# needed by this request. Convert it from protected to
# evictable so SWA LRU can reclaim it under pressure.
# Past the window the request no longer reads its prefill's SWA;
# release that part of the tree lock so SWA LRU can reclaim it.
if (
release_leaf_lock
and not req.swa_prefix_lock_released
@@ -7,7 +7,7 @@ of alignment slack, so this reproduces the historical trip conditions rather
than a line that still exists.
Trip conditions (all required):
1. Fork-only SWA leaf early-release on (`SGLANG_OPT_SWA_RELEASE_LEAF_LOCK_AFTER_WINDOW=1`)
1. Early SWA release of the prefill lock on (`SGLANG_OPT_RELEASE_PREFILL_SWA=1`)
2. Multiple requests share a long prefix (so one req's tombstoned leaf
poisons match_prefix for others walking the same radix path).
3. Memory pressure forces retract while at least one req has tombstoned
@@ -47,7 +47,7 @@ class TestSWAEvictionInterval(unittest.TestCase):
with (
self.subTest(protected=protected, shield=shield, auxiliary=auxiliary),
envs.SGLANG_SWA_EVICTION_INTERVAL.override(128),
envs.SGLANG_OPT_SWA_RELEASE_LEAF_LOCK_AFTER_WINDOW.override(False),
envs.SGLANG_OPT_RELEASE_PREFILL_SWA.override(False),
):
cache = _SwaCache(auxiliary=auxiliary)
req = SimpleNamespace(
@@ -113,7 +113,7 @@ class TestSWAEvictionInterval(unittest.TestCase):
patch("sglang.srt.managers.schedule_batch._is_hip", True),
envs.SGLANG_AMD_USE_FLYDSL_MEGA_MOE.override(True),
envs.SGLANG_SWA_EVICTION_INTERVAL.override(128),
envs.SGLANG_OPT_SWA_RELEASE_LEAF_LOCK_AFTER_WINDOW.override(False),
envs.SGLANG_OPT_RELEASE_PREFILL_SWA.override(False),
):
batch.maybe_evict_swa()
free.assert_not_called()