chore: include a minimum image for vlms when warming-up (#9528)

This commit is contained in:
Mick
2025-11-10 14:56:59 +08:00
committed by GitHub
parent a30f190762
commit 95876d75cb
3 changed files with 49 additions and 8 deletions

View File

@@ -483,6 +483,8 @@ async def get_model_info():
"is_generation": _global_state.tokenizer_manager.is_generation,
"preferred_sampling_params": _global_state.tokenizer_manager.server_args.preferred_sampling_params,
"weight_version": _global_state.tokenizer_manager.server_args.weight_version,
"has_image_understanding": _global_state.tokenizer_manager.model_config.is_image_understandable_model,
"has_audio_understanding": _global_state.tokenizer_manager.model_config.is_audio_understandable_model,
}
return result
@@ -1429,6 +1431,10 @@ def launch_server(
_global_state.tokenizer_manager.socket_mapping.clear_all_sockets()
# Minimal 2x2 black PNG (base64, 1x1 image would cause ambiguous in image channel dimension)
MINIMUM_PNG_PICTURE_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAEElEQVQImWNgYGD4z8DAAAQYAAH7u8WFAAAAAElFTkSuQmCC"
def _execute_server_warmup(
server_args: ServerArgs,
pipe_finish_writer: Optional[multiprocessing.connection.Connection],
@@ -1460,8 +1466,16 @@ def _execute_server_warmup(
model_info = res.json()
is_vlm = bool(model_info.get("has_image_understanding", False))
# Send a warmup request
request_name = "/generate" if model_info["is_generation"] else "/encode"
if model_info["is_generation"]:
if is_vlm and not server_args.skip_tokenizer_init:
request_name = "/v1/chat/completions"
else:
request_name = "/generate"
else:
request_name = "/encode"
max_new_tokens = 8 if model_info["is_generation"] else 1
json_data = {
"sampling_params": {
@@ -1474,6 +1488,31 @@ def _execute_server_warmup(
# TODO Workaround the bug that embedding errors for list of size 1
if server_args.dp_size == 1:
json_data["input_ids"] = json_data["input_ids"][0]
elif is_vlm and server_args.disaggregation_mode == "null":
# TODO: ChatCompletionRequest does not have bootstrap info required by disaggregation mode, disable image-warmup for now
json_data = {
"model": _global_state.tokenizer_manager.served_model_name,
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": f"data:image/png;base64,{MINIMUM_PNG_PICTURE_BASE64}"
},
},
{
"type": "text",
"text": "Describe the image.",
},
],
}
],
"max_tokens": max_new_tokens,
"stream": False,
"temperature": 0.0,
}
else:
json_data["text"] = ["The capital city of France is"] * server_args.dp_size
# TODO Workaround the bug that embedding errors for list of size 1