@@ -53,47 +53,51 @@ def test_prefix_capture_override_reaches_worker(arguments, captures):
5353 assert f"--prefix_capture_slots={ captures } " in serve_batching ._worker_command (args )
5454
5555
56- def test_prompt_end_capture_is_opt_in_and_reaches_worker (arguments , capsys ):
57- default = serve_batching ._parse_args (arguments + ["--prefix-cache-entries" , "4" ])
58- assert not default .prefix_checkpoint_prompt_end
59- assert not any (
60- "prefix_checkpoint_prompt_end" in flag
61- for flag in serve_batching ._worker_command (default )
62- )
63- enabled = serve_batching ._parse_args (arguments + ["--prefix-checkpoint-prompt-end" ])
56+ @pytest .mark .parametrize (
57+ "options" ,
58+ [[], ["--prefix-checkpoint-prompt-end" ], ["--prefix-checkpoint-prompt-end=true" ]],
59+ )
60+ def test_prompt_end_capture_defaults_on_and_reaches_worker (arguments , options ):
61+ enabled = serve_batching ._parse_args (arguments + options )
62+ assert enabled .prefix_checkpoint_prompt_end
6463 assert enabled .prefix_cache_entries == 8
6564 assert "--prefix_checkpoint_prompt_end=true" in serve_batching ._worker_command (
6665 enabled
6766 )
6867 assert "--prefix_cache_entries=8" in serve_batching ._worker_command (enabled )
68+
69+
70+ @pytest .mark .parametrize ("capacity" , [None , 0 , 3 ])
71+ def test_prompt_end_capture_opt_out_reaches_worker (arguments , capacity ):
72+ options = ["--prefix-checkpoint-prompt-end=false" ]
73+ if capacity is not None :
74+ options += ["--prefix-cache-entries" , str (capacity )]
75+ disabled = serve_batching ._parse_args (arguments + options )
76+ assert not disabled .prefix_checkpoint_prompt_end
77+ assert disabled .prefix_cache_entries == (capacity or 0 )
78+ command = serve_batching ._worker_command (disabled )
79+ assert "--prefix_checkpoint_prompt_end=false" in command
80+ assert f"--prefix_cache_entries={ capacity or 0 } " in command
81+ assert ("--prefix_capture_slots=0" in command ) == bool (capacity )
82+
83+
84+ def test_prompt_end_capture_rejects_invalid_combinations (arguments , capsys ):
6985 with pytest .raises (SystemExit ):
70- serve_batching ._parse_args (
71- arguments
72- + ["--prefix-checkpoint-prompt-end" , "--prefix-cache-entries" , "0" ]
73- )
86+ serve_batching ._parse_args (arguments + ["--prefix-cache-entries" , "0" ])
87+ assert "requires --prefix-cache-entries > 0" in capsys .readouterr ().err
7488 with pytest .raises (SystemExit ):
75- serve_batching ._parse_args (
76- arguments
77- + [
78- "--prefix-checkpoint-prompt-end" ,
79- "--prefix-checkpoint-interval" ,
80- "64" ,
81- ]
82- )
89+ serve_batching ._parse_args (arguments + ["--prefix-checkpoint-interval" , "64" ])
8390 assert "cannot be combined" in capsys .readouterr ().err
8491
8592
8693def test_session_checkpoint_capacity_override_and_row_overflow (arguments ):
87- args = serve_batching ._parse_args (
88- arguments + ["--prefix-checkpoint-prompt-end" , "--prefix-cache-entries" , "2" ]
89- )
94+ args = serve_batching ._parse_args (arguments + ["--prefix-cache-entries" , "2" ])
9095 assert "--prefix_cache_entries=2" in serve_batching ._worker_command (args )
9196 for capacity in (0 , - 1 , (1 << 31 ) - 1 ):
9297 with pytest .raises (SystemExit ):
9398 serve_batching ._parse_args (
9499 arguments
95100 + [
96- "--prefix-checkpoint-prompt-end" ,
97101 "--prefix-cache-entries" ,
98102 str (capacity ),
99103 ]
@@ -110,6 +114,7 @@ def test_worker_forwards_mg_options(arguments):
110114 "2048" ,
111115 "--prefix-cache-entries" ,
112116 "3" ,
117+ "--prefix-checkpoint-prompt-end=false" ,
113118 "--prefix-checkpoint-interval" ,
114119 "512" ,
115120 ]
@@ -127,6 +132,7 @@ def test_worker_forwards_mg_options(arguments):
127132 assert flags ["--bos_id" ] == "200000"
128133 assert flags ["--eos_id" ] == "200001"
129134 assert flags ["--prefix_checkpoint_interval" ] == "512"
135+ assert flags ["--prefix_checkpoint_prompt_end" ] == "false"
130136
131137
132138@pytest .mark .parametrize ("options,enabled" , [([], "false" ), (["--dflash" ], "true" )])
@@ -160,6 +166,7 @@ def test_draft_count_forwarded(arguments, n_draft):
160166 ("--max-vision-patches" , str (1 << 31 )),
161167 ("--prefix-checkpoint-interval" , "8" ),
162168 ("--prefix-checkpoint-interval" , "-1" ),
169+ ("--prefix-checkpoint-prompt-end" , "invalid" ),
163170 ("--prefix-capture-slots" , "-1" ),
164171 ("--prefix-capture-slots" , str (1 << 31 )),
165172 ],
0 commit comments