[BugFix] fix bench_serving error when multimodal image is testing (#13254)
This commit is contained in:
@@ -1462,7 +1462,11 @@ def sample_image_requests(
|
|||||||
total_image_bytes = 0
|
total_image_bytes = 0
|
||||||
for i in range(num_requests):
|
for i in range(num_requests):
|
||||||
# Generate text prompt
|
# Generate text prompt
|
||||||
text_prompt = gen_prompt(processor.tokenizer, int(input_lens[i]))
|
text_prompt = gen_mm_prompt(
|
||||||
|
processor.tokenizer,
|
||||||
|
processor.image_token_id if hasattr(processor, "image_token_id") else None,
|
||||||
|
int(input_lens[i]),
|
||||||
|
)
|
||||||
|
|
||||||
# Generate image list
|
# Generate image list
|
||||||
images, images_base64, images_bytes = zip(
|
images, images_base64, images_bytes = zip(
|
||||||
@@ -1502,6 +1506,15 @@ def gen_prompt(tokenizer, token_num):
|
|||||||
return tokenizer.decode(selected_tokens)
|
return tokenizer.decode(selected_tokens)
|
||||||
|
|
||||||
|
|
||||||
|
def gen_mm_prompt(tokenizer, image_pad_id, token_num):
|
||||||
|
"""Generate a random prompt of specified token length using tokenizer vocabulary."""
|
||||||
|
all_available_tokens = list(tokenizer.get_vocab().values())
|
||||||
|
if image_pad_id:
|
||||||
|
all_available_tokens.remove(image_pad_id)
|
||||||
|
selected_tokens = random.choices(all_available_tokens, k=token_num)
|
||||||
|
return tokenizer.decode(selected_tokens)
|
||||||
|
|
||||||
|
|
||||||
def get_gen_prefix_cache_path(args, tokenizer):
|
def get_gen_prefix_cache_path(args, tokenizer):
|
||||||
"""Create cache directory under ~/.cache/sglang/benchmark"""
|
"""Create cache directory under ~/.cache/sglang/benchmark"""
|
||||||
cache_dir = Path.home() / ".cache" / "sglang" / "benchmark"
|
cache_dir = Path.home() / ".cache" / "sglang" / "benchmark"
|
||||||
|
|||||||
Reference in New Issue
Block a user