Skip to content

Commit 4dd96bb

Browse files
authored
[SW-212036] Change gc thr multiplier to 16 (vllm-project#832)
https://docs.python.org/3/library/gc.html#gc.set_threshold We see every X calls a gap of 100-1s depending on the benchmark when garbage collector is called and increasing the default of this multiplier is fixing the issue.
1 parent e6b7eae commit 4dd96bb

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

vllm/worker/hpu_model_runner.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -713,19 +713,26 @@ def __init__(
713713
self.is_pooler = False
714714

715715
def _set_gc_threshold(self) -> None:
716-
# Read https://docs.python.org/3/library/gc.html#gc.set_threshold
717-
# for comprehensive description of gc generations.
718-
# We can either use VLLM_GC_THR_GEN[0-2] (this has higher priority)
719-
# to set particular generation threshold or use simpler
720-
# VLLM_GC_THR_MULTIPLIER to multiply default values.
721-
default_gc_thrs = list(gc.get_threshold())
716+
"""
717+
Read https://docs.python.org/3/library/gc.html#gc.set_threshold
718+
for comprehensive description of gc generations.
719+
We can either use VLLM_GC_THR_GEN[0-2] (this has higher priority)
720+
to set particular generation threshold or use simpler
721+
VLLM_GC_THR_MULTIPLIER to multiply default values.
722+
"""
723+
724+
# gc.get_threshold default, avoiding potential overflow due to
725+
# multiplier and set later (get->mult->set->repeat->...->overflow)
726+
default_gc_thrs = [700, 10, 10]
727+
722728
requested_gc_thrs = [0] * len(default_gc_thrs)
723729
for i in range(len(default_gc_thrs)):
724730
requested_gc_thrs[i] = int(
725731
os.environ.get(f'VLLM_GC_THR_GEN{i}', default_gc_thrs[i]))
726732
if requested_gc_thrs == default_gc_thrs:
727-
gc_thr_multiplier = int(os.environ.get('VLLM_GC_THR_MULTIPLIER',
728-
2))
733+
# 16*threshold is rare enough for gc to not cause perf issues
734+
gc_thr_multiplier = int(
735+
os.environ.get('VLLM_GC_THR_MULTIPLIER', 16))
729736
requested_gc_thrs = [
730737
t * gc_thr_multiplier for t in default_gc_thrs
731738
]

0 commit comments

Comments
 (0)