Repository navigation
Commit 2bc35c4
fix: the CUDA server answers malformed requests with 400 and failed ones with 500 or a stream error event
The CUDA server caught only RequestError. A request the checkpoint's chat template refused (raise_exception), a chat_template_kwargs that dict() could not convert, or a temperature, top_p, top_k or seed that did not convert closed the connection with no response. Sampling was resolved after a stream's headers and role chunk, so a streamed request with a bad temperature or seed ended after the role chunk. An engine failure closed the connection too: no response for a non-streamed request, no error event and no [DONE] for a streamed one.
- Preparing a request now checks what it reads: chat_template_kwargs must be an object or null (null is read as absent; every other value, [], "", false and 0 included, is refused), a template refusal becomes "the chat template rejected the request: ...", and temperature, top_p, top_k and seed go through parse_numbers, as on the Mac. The Sampling is built there and carried on PreparedRequest, so check(), prepare() and GlmApp.check refuse the same requests, and a streamed one is refused with HTTP 400 before its headers.
- Any other failure while preparing gets HTTP 400 with its message, as on the Mac, and is logged with its traceback. A body that is not UTF-8 gets the existing "not JSON" 400.
- A failure during generation is logged with its traceback and answered as the Mac server answers it: HTTP 500 {"error": {"message"}} for a non-streamed request, an error event of type server_error then [DONE] for a streamed one.
- Valid requests make the same engine calls with the same Sampling; it is built before the stream opens instead of after.
Accepted before, refused now: a boolean in any of the four sampling fields (read as 1 or 0), a non-finite temperature or top_p, a non-integral top_k or seed (truncated before), a malformed top_p, top_k or seed on a greedy request (not read before), chat_template_kwargs as [], "", false or 0 (read as absent before), and chat_template_kwargs as a list of key/value pairs.
Tests: tests/test_cuda_server_errors.py (202 cases; 140 fail without the fix; the 60 that check valid requests reach the engine with the same Sampling, and the 2 that check a null or empty chat_template_kwargs is read as absent, pass with and without it), and tests/cuda/test_qwen27_server_errors.py for the 27B checkpoint and engine on a GPU.
(cherry picked from commit 4236863)1 parent 5fd5bf7 commit 2bc35c4
3 files changed
Lines changed: 508 additions & 18 deletions
File tree
- src/tensorfold/cuda
- tests
- cuda
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| 80 | + | |
75 | 81 | | |
76 | 82 | | |
77 | 83 | | |
| |||
156 | 162 | | |
157 | 163 | | |
158 | 164 | | |
| 165 | + | |
| 166 | + | |
159 | 167 | | |
160 | 168 | | |
161 | 169 | | |
162 | 170 | | |
163 | 171 | | |
164 | 172 | | |
165 | 173 | | |
166 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
167 | 180 | | |
168 | 181 | | |
169 | 182 | | |
170 | 183 | | |
171 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
172 | 188 | | |
173 | 189 | | |
174 | 190 | | |
175 | 191 | | |
176 | 192 | | |
177 | 193 | | |
178 | 194 | | |
179 | | - | |
| 195 | + | |
| 196 | + | |
180 | 197 | | |
181 | 198 | | |
182 | 199 | | |
| |||
218 | 235 | | |
219 | 236 | | |
220 | 237 | | |
221 | | - | |
| 238 | + | |
222 | 239 | | |
223 | 240 | | |
224 | 241 | | |
225 | | - | |
| 242 | + | |
| 243 | + | |
226 | 244 | | |
227 | 245 | | |
228 | | - | |
229 | | - | |
230 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
231 | 249 | | |
232 | 250 | | |
233 | 251 | | |
| |||
238 | 256 | | |
239 | 257 | | |
240 | 258 | | |
241 | | - | |
| 259 | + | |
242 | 260 | | |
243 | 261 | | |
244 | 262 | | |
| |||
352 | 370 | | |
353 | 371 | | |
354 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
355 | 382 | | |
356 | 383 | | |
357 | 384 | | |
| |||
370 | 397 | | |
371 | 398 | | |
372 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
373 | 410 | | |
374 | 411 | | |
375 | 412 | | |
| |||
384 | 421 | | |
385 | 422 | | |
386 | 423 | | |
387 | | - | |
| 424 | + | |
388 | 425 | | |
389 | 426 | | |
390 | 427 | | |
391 | 428 | | |
392 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
393 | 433 | | |
394 | 434 | | |
395 | 435 | | |
| |||
427 | 467 | | |
428 | 468 | | |
429 | 469 | | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
438 | 474 | | |
439 | 475 | | |
440 | 476 | | |
| |||
462 | 498 | | |
463 | 499 | | |
464 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
465 | 508 | | |
466 | 509 | | |
467 | 510 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
0 commit comments