Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions python/sglang/test/simple_eval_mmmu_vlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,20 @@ def _key(idx):
options = None

# Build final textual prompt; include choices if MC
prompt_text = f"Question: {question}\n\n"
prompt_text = f"{question}\n"
if options:
letters = [chr(ord("A") + i) for i in range(len(options))]
for letter, opt in zip(letters, options):
prompt_text += f"{letter}) {opt}\n"
prompt_text += "\nAnswer: "
prompt_text += f"{letter}. {opt}\n"
prompt_text += (
"\nAnswer the following multiple-choice question. "
"The last line of your response should be of the "
"following format: 'Answer: $LETTER' (without quotes) "
"where LETTER is one of the options. "
"Think step by step before answering."
)
else:
prompt_text += "\nAnswer: "

samples.append(
{
Expand Down Expand Up @@ -330,6 +338,14 @@ def _parse_multi_choice_response(
response: str, all_choices: List[str], index2ans: dict
) -> str:
# loosely adapted from benchmark mmmu eval

# First, look for explicit "Answer: X" pattern (last occurrence)
answer_matches = re.findall(r"[Aa]nswer\s*:\s*\*?\*?\s*\(?([A-Z])\)?", response)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The regex is currently case-sensitive for the answer letter ([A-Z]). While the prompt instructs the model to use a specific format, models may occasionally output lowercase letters (e.g., Answer: a). Making this check case-insensitive would improve the robustness of the parser.

Suggested change
answer_matches = re.findall(r"[Aa]nswer\s*:\s*\*?\*?\s*\(?([A-Z])\)?", response)
answer_matches = re.findall(r"(?i)answer\s*:\s*\*?\*?\s*\(?([A-Z])\)?", response)
if answer_matches:
candidate = answer_matches[-1].upper()

if answer_matches:
candidate = answer_matches[-1]
if candidate in all_choices:
return candidate

for char in [",", ".", "!", "?", ";", ":", "'"]:
response = response.strip(char)
response = " " + response + " "
Expand Down
82 changes: 82 additions & 0 deletions test/registered/vlm/test_vlm_tp4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"""
VLM TP=4 per-commit test using Qwen3.5-27B with MMMU evaluation.
"""

import unittest
from types import SimpleNamespace

from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
DEFAULT_URL_FOR_TEST,
CustomTestCase,
popen_launch_server,
)

register_cuda_ci(est_time=200, suite="stage-c-test-4-gpu-h100")

QWEN35_27B_MODEL = "Qwen/Qwen3.5-27B"
MMMU_ACCURACY_THRESHOLD = 0.65
MMMU_NUM_EXAMPLES = 32


class TestVLMTP4(CustomTestCase):
@classmethod
def setUpClass(cls):
cls.model = QWEN35_27B_MODEL
cls.base_url = DEFAULT_URL_FOR_TEST
cls.process = popen_launch_server(
cls.model,
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
other_args=[
"--tp-size",
"4",
"--cuda-graph-max-bs",
"32",
"--mem-fraction-static",
"0.8",
"--trust-remote-code",
"--mamba-scheduler-strategy",
"extra_buffer",
"--mamba-track-interval",
"128",
"--mamba-ssm-dtype",
"bfloat16",
Comment on lines +42 to +47
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These arguments (--mamba-*) are specific to Mamba/SSM architecture models. Since Qwen3.5 is a Transformer-based model, these flags are irrelevant and should be removed to avoid confusion and ensure the configuration is clean.

Suggested change
"--mamba-scheduler-strategy",
"extra_buffer",
"--mamba-track-interval",
"128",
"--mamba-ssm-dtype",
"bfloat16",
"--trust-remote-code",
"--chunked-prefill-size",

"--chunked-prefill-size",
"2048",
"--max-running-requests",
"128",
],
)

@classmethod
def tearDownClass(cls):
if hasattr(cls, "process") and cls.process:
kill_process_tree(cls.process.pid)

def test_mmmu_accuracy(self):
args = SimpleNamespace(
model=self.model,
eval_name="mmmu",
num_examples=MMMU_NUM_EXAMPLES,
num_threads=16,
max_tokens=2048,
chat_template_kwargs={"enable_thinking": False},
base_url=self.base_url,
host="http://127.0.0.1",
port=int(self.base_url.split(":")[-1]),
)
metrics = run_eval(args)
print(f"MMMU score: {metrics['score']}")
self.assertGreaterEqual(
metrics["score"],
MMMU_ACCURACY_THRESHOLD,
f"MMMU accuracy {metrics['score']:.4f} below threshold {MMMU_ACCURACY_THRESHOLD}",
)


if __name__ == "__main__":
unittest.main()
Loading