Skip to content

[Core] Support multiple tasks per model #20771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 13, 2025
Merged
49 changes: 46 additions & 3 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_get_field():
("jason9693/Qwen2.5-1.5B-apeach", "pooling", "classify"),
("cross-encoder/ms-marco-MiniLM-L-6-v2", "pooling", "classify"),
("Qwen/Qwen2.5-Math-RM-72B", "pooling", "reward"),
("openai/whisper-small", "transcription", "transcription"),
("openai/whisper-small", "generate", "transcription"),
],
)
def test_auto_task(model_id, expected_runner_type, expected_task):
Expand All @@ -69,7 +69,11 @@ def test_auto_task(model_id, expected_runner_type, expected_task):
)

assert config.runner_type == expected_runner_type
assert config.task == expected_task

if config.runner_type == "pooling":
assert config.task == expected_task
else:
assert expected_task in config.supported_tasks


@pytest.mark.parametrize(
Expand Down Expand Up @@ -98,11 +102,50 @@ def test_score_task(model_id, expected_runner_type, expected_task):
assert config.task == expected_task


@pytest.mark.parametrize(("model_id", "expected_runner_type", "expected_task"),
[
("Qwen/Qwen2.5-1.5B-Instruct", "draft", "auto"),
])
def test_draft_task(model_id, expected_runner_type, expected_task):
config = ModelConfig(
model_id,
runner="draft",
tokenizer=model_id,
seed=0,
dtype="float16",
)

assert config.runner_type == expected_runner_type
assert config.task == expected_task


@pytest.mark.parametrize(
("model_id", "expected_runner_type", "expected_task"),
[
("openai/whisper-small", "generate", "transcription"),
],
)
def test_transcription_task(model_id, expected_runner_type, expected_task):
config = ModelConfig(
model_id,
task="transcription",
tokenizer=model_id,
tokenizer_mode="auto",
trust_remote_code=False,
seed=0,
dtype="float16",
)

assert config.runner_type == expected_runner_type
assert config.task == expected_task


@pytest.mark.parametrize(("model_id", "bad_task"), [
("Qwen/Qwen2.5-Math-RM-72B", "generate"),
("Qwen/Qwen3-0.6B", "transcription"),
])
def test_incorrect_task(model_id, bad_task):
with pytest.raises(ValueError, match=r"does not support the .* task"):
with pytest.raises(ValueError, match=r"does not support task=.*"):
ModelConfig(
model_id,
task=bad_task,
Expand Down
Loading