"vscode:/vscode.git/clone" did not exist on "fe2016de2d2d68bb967e9c43ee168db01322b0f1"
Unverified Commit e9ba99f2 authored by Shanshan Shen's avatar Shanshan Shen Committed by GitHub
Browse files

[V1][Structured Output] Add `supports_structured_output()` method to Platform (#16148)


Signed-off-by: default avatarshen-shanshan <467638484@qq.com>
parent 7c803687
......@@ -180,3 +180,7 @@ class CpuPlatform(Platform):
Get device specific communicator class for distributed communication.
"""
return "vllm.distributed.device_communicators.cpu_communicator.CpuCommunicator" # noqa
@classmethod
def supports_structured_output(cls) -> bool:
return True
......@@ -308,6 +308,10 @@ class CudaPlatformBase(Platform):
def supports_v1(cls, model_config: ModelConfig) -> bool:
return True
@classmethod
def supports_structured_output(cls) -> bool:
return True
@classmethod
def use_custom_allreduce(cls) -> bool:
return True
......
......@@ -92,3 +92,7 @@ class HpuPlatform(Platform):
@classmethod
def get_device_communicator_cls(cls) -> str:
return "vllm.distributed.device_communicators.hpu_communicator.HpuCommunicator" # noqa
@classmethod
def supports_structured_output(cls) -> bool:
return True
......@@ -379,6 +379,13 @@ class Platform:
"""
return False
@classmethod
def supports_structured_output(cls) -> bool:
"""
Returns whether the current platform can support structured output.
"""
return False
@classmethod
def use_custom_allreduce(cls) -> bool:
"""
......
......@@ -67,3 +67,7 @@ class NeuronPlatform(Platform):
@classmethod
def use_all_gather(cls) -> bool:
return True
@classmethod
def supports_structured_output(cls) -> bool:
return True
......@@ -303,6 +303,10 @@ class RocmPlatform(Platform):
# V1 support on AMD gpus is experimental
return True
@classmethod
def supports_structured_output(cls) -> bool:
return True
@classmethod
def use_custom_allreduce(cls) -> bool:
# We only enable custom allreduce for MI300 series
......
......@@ -133,3 +133,8 @@ class TpuPlatform(Platform):
def supports_v1(cls, model_config: ModelConfig) -> bool:
# V1 support on TPU is experimental
return True
@classmethod
def supports_structured_output(cls) -> bool:
# Structured output is not supported on TPU.
return False
......@@ -140,3 +140,7 @@ class XPUPlatform(Platform):
@classmethod
def get_device_communicator_cls(cls) -> str:
return "vllm.distributed.device_communicators.xpu_communicator.XpuCommunicator" # noqa
@classmethod
def supports_structured_output(cls) -> bool:
return True
......@@ -136,9 +136,11 @@ class Processor:
f" != {engine_level_backend}")
else:
params.guided_decoding.backend = engine_level_backend
import vllm.platforms
if vllm.platforms.current_platform.is_tpu():
raise ValueError("Structured output is not supported on TPU.")
from vllm.platforms import current_platform
if not current_platform.supports_structured_output():
raise ValueError("Structured output is not supported on "
f"{current_platform.device_name}.")
# Request content validation
if engine_level_backend.startswith("xgrammar"):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment