Commit 9efd2f5
gemma-4-31B-it: hot-patch transformers CUDA→numpy crash on image requests
Multimodal requests to gemma-4-31B-it return HTTP 500 with
`TypeError: can't convert cuda:0 device type tensor to numpy` for inputs
SGLang decodes to a GPU tensor (video data-URLs, broken image URLs, etc).
The crash is a bare `image.numpy()` on a CUDA tensor at
transformers/image_processing_backends.py:458, reached via the gemma4 image
processor. `--disable-fast-image-processor` (added in v0.0.196) only closed
the generic fast-processor path; this second path is unaffected because the
tensor is already on GPU upstream of that flag.
Wrap `sglang serve` in a shell that sed-patches the line to
`image.cpu().numpy()` before launch. `.cpu()` is a no-op on CPU tensors, so
the patch is idempotent and safe across restarts. Avoids rebuilding the
pinned SGLang image; all serve flags (incl. --disable-fast-image-processor)
are unchanged.
Verified: valid images already return 200; video/broken-URL inputs reproduce
the 500 on both backends pre-patch. See nearai/infra#156.1 parent f8ad79e commit 9efd2f5
1 file changed
Lines changed: 34 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
531 | 544 | | |
532 | 545 | | |
533 | 546 | | |
| |||
0 commit comments