2525
2626class ResponseComparator (JSONSnapshotExtension ):
2727 rtol = 0.2
28+
2829 def serialize (
2930 self ,
3031 data ,
@@ -69,7 +70,9 @@ def eq_prefill_token(prefill_token: InputToken, other: InputToken) -> bool:
6970 prefill_token .id == other .id
7071 and prefill_token .text == other .text
7172 and (
72- math .isclose (prefill_token .logprob , other .logprob , rel_tol = self .rtol )
73+ math .isclose (
74+ prefill_token .logprob , other .logprob , rel_tol = self .rtol
75+ )
7376 if prefill_token .logprob is not None
7477 else prefill_token .logprob == other .logprob
7578 )
@@ -153,6 +156,7 @@ class GenerousResponseComparator(ResponseComparator):
153156 # Needed for GPTQ with exllama which has serious numerical fluctuations.
154157 rtol = 0.75
155158
159+
156160class LauncherHandle :
157161 def __init__ (self , port : int ):
158162 self .client = AsyncClient (f"http://localhost:{ port } " )
@@ -198,6 +202,7 @@ def _inner_health(self) -> bool:
198202def response_snapshot (snapshot ):
199203 return snapshot .use_extension (ResponseComparator )
200204
205+
201206@pytest .fixture
202207def generous_response_snapshot (snapshot ):
203208 return snapshot .use_extension (GenerousResponseComparator )
@@ -219,7 +224,7 @@ def local_launcher(
219224 quantize : Optional [str ] = None ,
220225 trust_remote_code : bool = False ,
221226 use_flash_attention : bool = True ,
222- dtype : Optional [str ] = None
227+ dtype : Optional [str ] = None ,
223228 ):
224229 port = random .randint (8000 , 10_000 )
225230 master_port = random .randint (10_000 , 20_000 )
@@ -282,7 +287,7 @@ def docker_launcher(
282287 quantize : Optional [str ] = None ,
283288 trust_remote_code : bool = False ,
284289 use_flash_attention : bool = True ,
285- dtype : Optional [str ] = None
290+ dtype : Optional [str ] = None ,
286291 ):
287292 port = random .randint (8000 , 10_000 )
288293
@@ -335,7 +340,7 @@ def docker_launcher(
335340 ],
336341 volumes = volumes ,
337342 ports = {"80/tcp" : port },
338- shm_size = "1G"
343+ shm_size = "1G" ,
339344 )
340345
341346 yield ContainerLauncherHandle (client , container .name , port )
0 commit comments