@@ -713,19 +713,26 @@ def __init__(
713
713
self .is_pooler = False
714
714
715
715
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
+
722
728
requested_gc_thrs = [0 ] * len (default_gc_thrs )
723
729
for i in range (len (default_gc_thrs )):
724
730
requested_gc_thrs [i ] = int (
725
731
os .environ .get (f'VLLM_GC_THR_GEN{ i } ' , default_gc_thrs [i ]))
726
732
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 ))
729
736
requested_gc_thrs = [
730
737
t * gc_thr_multiplier for t in default_gc_thrs
731
738
]
0 commit comments