[Frontend][Benchmark] Add judger and accuracy metrics for OmniInterac… (#7317)

Co-authored-by: Gao Han <hgaoaf@connect.ust.hk>
This commit is contained in:
ZacheryAUandGao Han authored and GitHub committed 2026-09-24 08:34:23 +00:00
1 parent 1d77e96d4d
commit 926ba72793
13 files changed
+4165 -30

No files matched your search

+291
View File
@@ -249,6 +249,252 @@ def test_dataset_discovers_official_layouts_and_total_selection(tmp_path: Path):
assert [case.subset for case in selected] == ["1q1a", "1q1a_math"]
def _write_scenario_dataset(root: Path) -> Path:
data_root = root / "data"
one_q1a = data_root / "1q1a"
(one_q1a / "videos").mkdir(parents=True)
(one_q1a / "annotations").mkdir()
entries = []
specs = [
("realtime", "multi_turn", [{"question_time": 0.0, "answer_time": 1.0, "question_type": "realtime"}]),
("proactive", "multi_turn", [{"question_time": 0.0, "answer_time": 1.0, "question_type": "proactive"}]),
(
"nested",
"nested",
[
{
"question_time": 0.0,
"answer_time": 4.0,
"question_type": "proactive",
"question_text": "outer",
"answer_text": "outer",
},
{
"question_time": 1.0,
"answer_time": 2.0,
"question_type": "realtime",
"question_text": "inner",
"answer_text": "inner",
},
],
),
(
"interrupted",
"multi_turn",
[
{
"question_time": 0.0,
"answer_time": 1.0,
"question_type": "realtime",
"is_interrupted": True,
}
],
),
]
for name, scene, annotation in specs:
video = one_q1a / "videos" / f"{name}.mp4"
ann = one_q1a / "annotations" / f"{name}.json"
video.touch()
ann.write_text(json.dumps(annotation))
entries.append(
{
"video": f"videos/{name}.mp4",
"annotation": f"annotations/{name}.json",
"scene_type": scene,
}
)
(one_q1a / "video_json_map.json").write_text(json.dumps({"entries": entries}))
one_qna = data_root / "1qna"
(one_qna / "videos_bench").mkdir(parents=True)
(one_qna / "annotations").mkdir(parents=True)
(one_qna / "videos_bench" / "guide.mp4").touch()
(one_qna / "annotations" / "guide.json").write_text(
json.dumps(
{
"question_time": 0.0,
"question_text": "q",
"answers": [{"answer_time": 1.0, "answer_text": "a", "label": "step"}],
}
)
)
math_root = data_root / "1q1a_math"
(math_root / "videos").mkdir(parents=True)
(math_root / "annotations").mkdir()
(math_root / "videos" / "math.mp4").touch()
(math_root / "annotations" / "math.json").write_text(
json.dumps([{"question_time": 0.0, "answer_time": 1.0, "question_type": "realtime"}])
)
(math_root / "video_json_map.json").write_text(
json.dumps(
{
"entries": [
{
"video": "videos/math.mp4",
"annotation": "annotations/math.json",
"scene_type": "multi_turn",
}
]
}
)
)
return data_root
def test_scenario_cover_and_focus_sampling(tmp_path: Path) -> None:
root = _write_scenario_dataset(tmp_path)
covered = data.discover_omniinteract_cases(
root,
("1q1a", "1q1a_math", "1qna"),
num_prompts=5,
disable_shuffle=True,
scenario_tags=("realtime", "proactive", "nested", "interrupted", "1qna"),
)
assert len(covered) == 5
covered_tags = set().union(*(data.case_scenario_tags(case) for case in covered))
assert {"realtime", "proactive", "nested", "interrupted", "1qna"} <= covered_tags
focused = data.discover_omniinteract_cases(
root,
("1q1a", "1q1a_math", "1qna"),
num_prompts=0,
disable_shuffle=True,
scenario_tags=("nested", "1qna"),
scenario_focus=True,
)
assert {case.scene_type for case in focused} == {"nested", "1qna"}
def test_load_cases_from_video_list_preserves_order_and_caps(tmp_path: Path) -> None:
root = _write_dataset(tmp_path)
all_cases = data.discover_omniinteract_cases(root, data.OMNIINTERACT_SUBSETS, num_prompts=0, disable_shuffle=True)
ordered = list(reversed(all_cases))
video_list = tmp_path / "sampled_cases.jsonl"
video_list.write_text("".join(json.dumps(data.sampled_case_row(case)) + "\n" for case in ordered))
capped = data.load_omniinteract_cases_from_video_list(video_list, num_prompts=2)
assert [case.video_path for case in capped] == [case.video_path for case in ordered[:2]]
full = data.load_omniinteract_cases_from_video_list(video_list, num_prompts=0)
assert [case.video_path for case in full] == [case.video_path for case in ordered]
oversized = data.load_omniinteract_cases_from_video_list(video_list, num_prompts=99)
assert [case.video_path for case in oversized] == [case.video_path for case in ordered]
def test_load_cases_from_video_list_requires_existing_video(tmp_path: Path) -> None:
root = _write_dataset(tmp_path)
case = data.discover_omniinteract_cases(root, ("1q1a",), num_prompts=1, disable_shuffle=True)[0]
row = data.sampled_case_row(case)
row["video_path"] = str(tmp_path / "missing.mp4")
video_list = tmp_path / "bad.jsonl"
video_list.write_text(json.dumps(row) + "\n")
with pytest.raises(FileNotFoundError, match="video missing"):
data.load_omniinteract_cases_from_video_list(video_list, num_prompts=0)
def test_get_samples_from_video_list_without_dataset_path(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
root = _write_dataset(tmp_path)
cases = data.discover_omniinteract_cases(root, data.OMNIINTERACT_SUBSETS, num_prompts=0, disable_shuffle=True)
video_list = tmp_path / "sampled_cases.jsonl"
video_list.write_text("".join(json.dumps(data.sampled_case_row(case)) + "\n" for case in cases))
ref = tmp_path / "ref.wav"
ref.touch()
parser = TrackingArgumentParser()
OmniBenchmarkServingSubcommand.add_cli_args(parser)
args = parser.parse_args(
[
"--backend",
"openai-realtime-duplex",
"--dataset-name",
"omniinteract",
"--model",
MODEL,
"--endpoint",
"/v1/realtime",
"--num-prompts",
"2",
"--omniinteract-ref-audio",
str(ref),
"--omniinteract-video-list",
str(video_list),
]
)
preprocess_serve_args(args)
monkeypatch.setattr(
"vllm_omni.clients.duplex.reference_audio_data_url",
lambda _: "data:audio/wav;base64,ref",
)
monkeypatch.setattr(benchmark_patch, "prepare_media", lambda *a, **k: (1.0, b"pcm", ["frame"]))
samples = benchmark_patch.get_samples(args, None)
assert len(samples) == 2
assert [sample.omniinteract_case.video_path for sample in samples] == [case.video_path for case in cases[:2]]
def _write_overlapping_cover_dataset(root: Path) -> Path:
data_root = root / "data"
one_q1a = data_root / "1q1a"
(one_q1a / "videos").mkdir(parents=True)
(one_q1a / "annotations").mkdir()
entries = []
specs = [
(
"pair_a",
[
{
"question_time": 0.0,
"answer_time": 1.0,
"question_type": "realtime",
"is_interrupted": True,
}
],
),
(
"pair_b",
[
{
"question_time": 0.0,
"answer_time": 1.0,
"question_type": "realtime",
"is_interrupted": True,
}
],
),
(
"proactive_only",
[{"question_time": 0.0, "answer_time": 1.0, "question_type": "proactive"}],
),
]
for name, annotation in specs:
video = one_q1a / "videos" / f"{name}.mp4"
ann = one_q1a / "annotations" / f"{name}.json"
video.touch()
ann.write_text(json.dumps(annotation))
entries.append(
{
"video": f"videos/{name}.mp4",
"annotation": f"annotations/{name}.json",
"scene_type": "multi_turn",
}
)
(one_q1a / "video_json_map.json").write_text(json.dumps({"entries": entries}))
return data_root
def test_cover_sampling_skips_tags_already_covered(tmp_path: Path) -> None:
root = _write_overlapping_cover_dataset(tmp_path)
selected = data.discover_omniinteract_cases(
root,
("1q1a",),
num_prompts=2,
disable_shuffle=True,
scenario_tags=("realtime", "interrupted", "proactive"),
)
names = [case.video_path.stem for case in selected]
assert names == ["pair_a", "proactive_only"]
selected_tags = set().union(*(data.case_scenario_tags(case) for case in selected))
assert {"realtime", "interrupted", "proactive"} <= selected_tags
def _archive(path: Path, member: str) -> None:
with tarfile.open(path, "w") as archive:
content = b"{}"
@@ -542,6 +788,51 @@ def test_ineligible_outputs_are_excluded_from_manifest(tmp_path: Path, audio_tim
assert reason in result.official_eval_ineligible_reasons
oi.write_batch_artifacts(tmp_path / "out", [case], [result])
assert (tmp_path / "out" / "official_eval_manifest.jsonl").read_text() == ""
sampled = [
json.loads(line) for line in (tmp_path / "out" / "sampled_cases.jsonl").read_text().splitlines() if line.strip()
]
assert sampled == [
{
"video_path": str(case.video_path.resolve()),
"output_name": data.official_output_name(case),
"subset": case.subset,
}
]
def test_official_output_name_matches_minicpmo_batch_layout(tmp_path: Path):
one_q1a = _case(tmp_path, subset="1q1a", name="videos/clip_a.mp4")
one_qna = _case(tmp_path, subset="1qna", name="videos_bench/nested/guide.mp4")
assert data.official_output_name(one_q1a) == "1q1a/videos__clip_a"
assert data.official_output_name(one_qna) == "1qna/nested__guide"
row = data.sampled_case_row(one_q1a)
assert row["video_path"] == str(one_q1a.video_path.resolve())
assert row["output_name"] == "1q1a/videos__clip_a"
assert row["subset"] == "1q1a"
def test_sampled_cases_jsonl_lists_every_case_including_failures(tmp_path: Path):
ok_case = _case(tmp_path, name="videos/ok.mp4")
bad_case = _case(tmp_path, name="videos/bad.mp4")
ok_result = oi.OmniInteractCaseResult(
ok_case.subset, str(ok_case.video_path), str(oi._output_dir(tmp_path / "out", ok_case)), success=True
)
ok_result.eligible_for_official_eval = True
bad_result = oi.OmniInteractCaseResult(
bad_case.subset, str(bad_case.video_path), str(oi._output_dir(tmp_path / "out", bad_case)), success=False
)
oi.write_batch_artifacts(tmp_path / "out", [ok_case, bad_case], [ok_result, bad_result])
sampled = [
json.loads(line) for line in (tmp_path / "out" / "sampled_cases.jsonl").read_text().splitlines() if line.strip()
]
assert [row["output_name"] for row in sampled] == ["1q1a/videos__ok", "1q1a/videos__bad"]
manifest = [
json.loads(line)
for line in (tmp_path / "out" / "official_eval_manifest.jsonl").read_text().splitlines()
if line.strip()
]
assert len(manifest) == 1
assert manifest[0]["sample_id"].startswith("1q1a__")
def test_artifacts_require_complete_audio_and_transcript_response(tmp_path: Path):