@@ -41,7 +41,11 @@ def _parse_preflight_timeout(value):
4141
4242
4343def _validate_limits (
44- parser , args , * , prefix_capture_slots = 0 , prefix_checkpoint_prompt_end = False
44+ parser ,
45+ args ,
46+ * ,
47+ prefix_capture_slots = 0 ,
48+ prefix_checkpoint_prompt_end = False ,
4549) -> int :
4650 for flag , value in (
4751 ("--max-context" , args .max_context ),
@@ -60,15 +64,12 @@ def _validate_limits(
6064 "--prefix-checkpoint-prompt-end cannot be combined with "
6165 "--prefix-checkpoint-interval"
6266 )
63- if (
64- args .prefix_checkpoint_interval or prefix_checkpoint_prompt_end
65- ) and not args .prefix_cache_entries :
66- flag = (
67- "--prefix-checkpoint-prompt-end"
68- if prefix_checkpoint_prompt_end
69- else "--prefix-checkpoint-interval"
67+ if prefix_checkpoint_prompt_end and not args .prefix_cache_entries :
68+ parser .error (
69+ "--prefix-checkpoint-prompt-end requires --prefix-cache-entries > 0"
7070 )
71- parser .error (f"{ flag } requires --prefix-cache-entries > 0" )
71+ if args .prefix_checkpoint_interval and not args .prefix_cache_entries :
72+ parser .error ("--prefix-checkpoint-interval requires --prefix-cache-entries > 0" )
7273 if not 0 <= prefix_capture_slots <= _MAX_INT32 :
7374 parser .error (f"--prefix-capture-slots must be between 0 and { _MAX_INT32 } " )
7475 # Mirrors ServingRuntimeConfig::resolved_prefix_captures for row validation.
@@ -78,9 +79,12 @@ def _validate_limits(
7879 prefix_capture_slots = min (prefix_capture_slots , 2 )
7980 if not args .prefix_cache_entries :
8081 prefix_capture_slots = 0
81- physical_sessions = (
82- args .max_sessions + args .prefix_cache_entries + prefix_capture_slots
82+ snapshots = (
83+ args .max_sessions * args .prefix_cache_entries
84+ if prefix_checkpoint_prompt_end
85+ else args .prefix_cache_entries
8386 )
87+ physical_sessions = args .max_sessions + snapshots + prefix_capture_slots
8488 if physical_sessions > _MAX_INT32 :
8589 parser .error ("session and prefix-cache capacity exceeds the row limit" )
8690 if not 1 <= args .port <= 65535 :
@@ -118,11 +122,15 @@ def _parse_args(argv=None):
118122 parser .add_argument ("--max-sessions" , type = int , default = 16 )
119123 parser .add_argument ("--max-decode-sequences" , type = int , default = 8 )
120124 parser .add_argument ("--max-inflight-requests" , type = int , default = 64 )
121- parser .add_argument ("--prefix-cache-entries" , type = int , default = 0 )
125+ parser .add_argument (
126+ "--prefix-cache-entries" ,
127+ type = int ,
128+ help = "Retained snapshots: shared by default (0), per named session with prompt-end checkpoints (8)" ,
129+ )
122130 parser .add_argument (
123131 "--prefix-checkpoint-prompt-end" ,
124132 action = "store_true" ,
125- help = "Best-effort retention of each request's prompt end in the bounded prefix cache " ,
133+ help = "Retain prompt- end checkpoints separately for each named session " ,
126134 )
127135 parser .add_argument (
128136 "--prefix-capture-slots" ,
@@ -148,6 +156,8 @@ def _parse_args(argv=None):
148156 parser .add_argument ("--host" , default = "127.0.0.1" )
149157 parser .add_argument ("--port" , type = int , default = 8000 )
150158 args = parser .parse_args (argv )
159+ if args .prefix_cache_entries is None :
160+ args .prefix_cache_entries = 8 if args .prefix_checkpoint_prompt_end else 0
151161
152162 _validate_limits (
153163 parser ,
0 commit comments