From 46e0f5007d460efdc0420ec7654d3ee847f02405 Mon Sep 17 00:00:00 2001 From: Bishwo Adhikari Date: Sun, 17 May 2026 09:12:03 +0300 Subject: [PATCH] Fix image (random multimodal) dataset token statistics (#22371) --- python/sglang/benchmark/datasets/image.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/python/sglang/benchmark/datasets/image.py b/python/sglang/benchmark/datasets/image.py index 5efeb98b7..284127620 100644 --- a/python/sglang/benchmark/datasets/image.py +++ b/python/sglang/benchmark/datasets/image.py @@ -293,6 +293,20 @@ def sample_image_requests( else: print(f"#Images per request: {image_count} (fixed)") + # Detailed token breakdown (derived from dataset + input_lens) + text_prompt_lens = np.array([r.text_prompt_len for r in dataset]) + vision_prompt_lens = np.array([r.vision_prompt_len for r in dataset]) + text_prompt_overheads = text_prompt_lens - input_lens + stat_fields = [ + ("Raw text prompt tokens (without overhead)", input_lens), + ("Text prompt tokens (with chat template)", text_prompt_lens), + ("Text prompt overhead", text_prompt_overheads), + ("Vision tokens", vision_prompt_lens), + ] + print("\n=== Token Breakdown (per request avg / total) ===") + for label, vals in stat_fields: + print(f" {label}: avg={np.mean(vals):.1f}, total={np.sum(vals)}") + print( f"\nCreated {len(dataset)} {image_content} {image_format} images with average {total_image_bytes // num_requests} bytes per request" )