|
46 | 46 | from vllm.v1.worker.gpu_input_batch import CachedRequestState |
47 | 47 | from vllm.distributed.parallel_state import get_pp_group |
48 | 48 |
|
| 49 | +from vllm.model_executor.models.interfaces import supports_transcription |
| 50 | +from vllm.model_executor.models.interfaces_base import ( |
| 51 | + is_pooling_model, is_text_generation_model) |
| 52 | +from vllm.tasks import GenerationTask, PoolingTask, SupportedTask |
| 53 | + |
49 | 54 | if TYPE_CHECKING: |
50 | 55 | from vllm.v1.core.scheduler import SchedulerOutput |
51 | 56 |
|
@@ -2349,3 +2354,35 @@ def initialize_kv_cache(self, kv_cache_config: KVCacheConfig) -> None: |
2349 | 2354 | self._PAD_SLOT_ID = num_blocks * self.block_size |
2350 | 2355 |
|
2351 | 2356 | htorch.hpu.synchronize() |
| 2357 | + |
| 2358 | + def get_supported_generation_tasks(self) -> list[GenerationTask]: |
| 2359 | + model = self.get_model() |
| 2360 | + supported_tasks = list[GenerationTask]() |
| 2361 | + |
| 2362 | + if is_text_generation_model(model): |
| 2363 | + supported_tasks.append("generate") |
| 2364 | + |
| 2365 | + if supports_transcription(model): |
| 2366 | + if model.supports_transcription_only: |
| 2367 | + return ["transcription"] |
| 2368 | + |
| 2369 | + supported_tasks.append("transcription") |
| 2370 | + |
| 2371 | + return supported_tasks |
| 2372 | + |
| 2373 | + def get_supported_pooling_tasks(self) -> list[PoolingTask]: |
| 2374 | + model = self.get_model() |
| 2375 | + if not is_pooling_model(model): |
| 2376 | + return [] |
| 2377 | + |
| 2378 | + return list(model.pooler.get_supported_tasks()) |
| 2379 | + |
| 2380 | + def get_supported_tasks(self) -> tuple[SupportedTask, ...]: |
| 2381 | + tasks = list[SupportedTask]() |
| 2382 | + |
| 2383 | + if self.model_config.runner_type == "generate": |
| 2384 | + tasks.extend(self.get_supported_generation_tasks()) |
| 2385 | + if self.model_config.runner_type == "pooling": |
| 2386 | + tasks.extend(self.get_supported_pooling_tasks()) |
| 2387 | + |
| 2388 | + return tuple(tasks) |
0 commit comments