vlm: enforce pybase64 for image and str encode/decode (#10700)

This commit is contained in:
b8zhong
2025-10-21 19:05:32 +08:00
committed by GitHub
parent 05d3667ab9
commit d0a64c7e2c
8 changed files with 20 additions and 36 deletions
@@ -1,9 +1,9 @@
import base64
import pickle
import time
from pathlib import Path
from typing import Any, List, Optional
import pybase64
import torch
from sglang.srt.utils import MultiprocessingSerializer
@@ -77,14 +77,16 @@ class NaiveDistributed:
)
_get_path(self._rank).write_text(
base64.b64encode(pickle.dumps(obj)).decode("utf-8") + text_postfix
pybase64.b64encode(pickle.dumps(obj)).decode("utf-8") + text_postfix
)
def _read_one(interesting_rank: int):
p = _get_path(interesting_rank)
while True:
if p.exists() and (text := p.read_text()).endswith(text_postfix):
return pickle.loads(base64.b64decode(text[: -len(text_postfix)]))
return pickle.loads(
pybase64.b64decode(text[: -len(text_postfix)], validate=True)
)
time.sleep(0.001)
return [