feat: add gc_threshold arg (#21481)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Muqi Li
2026-03-27 13:42:46 -07:00
committed by GitHub
co-authored by gemini-code-assist[bot]
parent 4e905febd2
commit 38ad251738
2 changed files with 21 additions and 0 deletions
+8
View File
@@ -616,6 +616,7 @@ class Engine(EngineBase):
configure_logger(server_args)
_set_envs_and_config(server_args)
server_args.check_server_args()
_set_gc(server_args)
# Allocate ports for inter-process communications
if port_args is None:
@@ -1179,6 +1180,13 @@ def _set_envs_and_config(server_args: ServerArgs):
mp.set_start_method("spawn", force=True)
def _set_gc(server_args: ServerArgs):
if gc_threshold := server_args.gc_threshold:
import gc
gc.set_threshold(*gc_threshold)
def _wait_for_scheduler_ready(
scheduler_pipe_readers: List,
scheduler_procs: List,
+13
View File
@@ -661,6 +661,7 @@ class ServerArgs:
enable_deterministic_inference: bool = False
rl_on_policy_target: Optional[str] = None
enable_attn_tp_input_scattered: bool = False
gc_threshold: Optional[List[int]] = None
# Context parallelism used in the long sequence prefill phase of DeepSeek v3.2
enable_nsa_prefill_context_parallel: bool = False
nsa_prefill_cp_mode: str = "round-robin-split"
@@ -5600,6 +5601,12 @@ class ServerArgs:
action="store_true",
help="Enable fused moe triton and sum all reduce.",
)
parser.add_argument(
"--gc-threshold",
type=int,
nargs="+",
help="Set the garbage collection thresholds (the collection frequency). Accepts 1 to 3 integers.",
)
# Dynamic batch tokenizer
parser.add_argument(
@@ -6116,6 +6123,12 @@ class ServerArgs:
"When enabling two batch overlap, moe_a2a_backend cannot be 'none'."
)
if self.gc_threshold:
if not (1 <= len(self.gc_threshold) <= 3):
raise ValueError(
"When setting gc_threshold, it must contain 1 to 3 integers."
)
def check_lora_server_args(self):
assert self.max_loras_per_batch > 0, "max_loras_per_batch must be positive"