4040bytestr = Union [bytes , bytearray , memoryview , zmq .Frame ]
4141
4242
43+ def _log_insecure_serialization_warning ():
44+ logger .warning_once ("Allowing insecure serialization using pickle due to "
45+ "VLLM_ALLOW_INSECURE_SERIALIZATION=1" )
46+
47+
4348class MsgpackEncoder :
4449 """Encoder with custom torch tensor and numpy array serialization.
4550
@@ -60,9 +65,7 @@ def __init__(self, size_threshold: Optional[int] = None):
6065 self .aux_buffers : Optional [list [bytestr ]] = None
6166 self .size_threshold = size_threshold
6267 if envs .VLLM_ALLOW_INSECURE_SERIALIZATION :
63- logger .warning (
64- "Allowing insecure serialization using pickle due to "
65- "VLLM_ALLOW_INSECURE_SERIALIZATION=1" )
68+ _log_insecure_serialization_warning ()
6669
6770 def encode (self , obj : Any ) -> Sequence [bytestr ]:
6871 try :
@@ -119,7 +122,9 @@ def enc_hook(self, obj: Any) -> Any:
119122 for item in itemlist ]
120123
121124 if not envs .VLLM_ALLOW_INSECURE_SERIALIZATION :
122- raise TypeError (f"Object of type { type (obj )} is not serializable" )
125+ raise TypeError (f"Object of type { type (obj )} is not serializable"
126+ "Set VLLM_ALLOW_INSECURE_SERIALIZATION=1 to allow "
127+ "fallback to pickle-based serialization." )
123128
124129 if isinstance (obj , FunctionType ):
125130 # `pickle` is generally faster than cloudpickle, but can have
@@ -202,9 +207,7 @@ def __init__(self, t: Optional[Any] = None):
202207 dec_hook = self .dec_hook )
203208 self .aux_buffers : Sequence [bytestr ] = ()
204209 if envs .VLLM_ALLOW_INSECURE_SERIALIZATION :
205- logger .warning (
206- "Allowing insecure deserialization using pickle due to "
207- "VLLM_ALLOW_INSECURE_SERIALIZATION=1" )
210+ _log_insecure_serialization_warning ()
208211
209212 def decode (self , bufs : Union [bytestr , Sequence [bytestr ]]) -> Any :
210213 if isinstance (bufs , (bytes , bytearray , memoryview , zmq .Frame )):
0 commit comments