vllm.platforms
Modules:
Name | Description |
---|---|
cpu |
|
cuda |
Code inside this file can safely assume cuda platform, e.g. importing |
hpu |
|
interface |
|
neuron |
|
rocm |
|
tpu |
|
xpu |
|
__all__
module-attribute
¶
builtin_platform_plugins
module-attribute
¶
builtin_platform_plugins = {
"tpu": tpu_platform_plugin,
"cuda": cuda_platform_plugin,
"rocm": rocm_platform_plugin,
"hpu": hpu_platform_plugin,
"xpu": xpu_platform_plugin,
"cpu": cpu_platform_plugin,
"neuron": neuron_platform_plugin,
}
Platform
¶
Source code in vllm/platforms/interface.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
|
device_control_env_var
class-attribute
instance-attribute
¶
device_control_env_var: str = (
"VLLM_DEVICE_CONTROL_ENV_VAR_PLACEHOLDER"
)
simple_compile_backend
class-attribute
instance-attribute
¶
simple_compile_backend: str = 'inductor'
supported_dtypes
property
¶
Returns the supported dtypes for the current platform.
check_and_update_config
classmethod
¶
check_and_update_config(vllm_config: VllmConfig) -> None
Check and update the configuration for the current platform.
It can raise an exception if the configuration is not compatible with the current platform, or it can update the configuration to make it compatible with the current platform.
The config is passed by reference, so it can be modified in place.
Source code in vllm/platforms/interface.py
default_v1
classmethod
¶
default_v1(model_config: ModelConfig) -> bool
Returns whether the current platform supports v1 by default.
device_id_to_physical_device_id
classmethod
¶
device_id_to_physical_device_id(device_id: int)
Source code in vllm/platforms/interface.py
fp8_dtype
classmethod
¶
fp8_dtype() -> dtype
Returns the preferred FP8 type on the current platform.
See the documentation for is_fp8_fnuz for details.
get_attn_backend_cls
classmethod
¶
get_attn_backend_cls(
selected_backend: _Backend,
head_size: int,
dtype: dtype,
kv_cache_dtype: Optional[str],
block_size: int,
use_v1: bool,
use_mla: bool,
) -> str
Get the attention backend class of a device.
Source code in vllm/platforms/interface.py
get_cpu_architecture
classmethod
¶
get_cpu_architecture() -> CpuArchEnum
Determine the CPU architecture of the current system. Returns CpuArchEnum indicating the architecture type.
Source code in vllm/platforms/interface.py
get_cu_count
classmethod
¶
get_current_memory_usage
classmethod
¶
get_device_capability
classmethod
¶
get_device_capability(
device_id: int = 0,
) -> Optional[DeviceCapability]
get_device_communicator_cls
classmethod
¶
get_device_communicator_cls() -> str
Get device specific communicator class for distributed communication.
Source code in vllm/platforms/interface.py
get_device_name
classmethod
¶
get_device_total_memory
classmethod
¶
get_device_uuid
classmethod
¶
get_infinity_values
classmethod
¶
get_piecewise_backend_cls
classmethod
¶
get_piecewise_backend_cls() -> str
Get piecewise backend class for piecewise graph.
has_device_capability
classmethod
¶
Test whether this platform is compatible with a device capability.
The capability
argument can either be:
- A tuple
(major, minor)
. - An integer
<major><minor>
. (SeeDeviceCapability.to_int
)
Source code in vllm/platforms/interface.py
inference_mode
classmethod
¶
A device-specific wrapper of torch.inference_mode
.
This wrapper is recommended because some hardware backends such as TPU
do not support torch.inference_mode
. In such a case, they will fall
back to torch.no_grad
by overriding this method.
Source code in vllm/platforms/interface.py
is_async_output_supported
classmethod
¶
is_device_capability
classmethod
¶
Test whether this platform has exactly the specified device capability.
The capability
argument can either be:
- A tuple
(major, minor)
. - An integer
<major><minor>
. (SeeDeviceCapability.to_int
)
Source code in vllm/platforms/interface.py
is_fp8_fnuz
classmethod
¶
is_fp8_fnuz() -> bool
Returns whether the preferred FP8 type is FNUZ on the current platform.
There are two representations of FP8, OCP FP8 and FNUZ FP8. The OCP specification can be found at https://tinyurl.com/b7jvwpft. The FNUZ specification can be found at https://tinyurl.com/5n6hwwu5.
AMD's MI300 and MI325 have native hardware support for FNUZ. All other hardware has converged on the OCP FP8 standard.
Source code in vllm/platforms/interface.py
is_pin_memory_available
classmethod
¶
is_pin_memory_available() -> bool
Checks whether pin memory is available on the current platform.
Source code in vllm/platforms/interface.py
pre_register_and_update
classmethod
¶
pre_register_and_update(
parser: Optional[FlexibleArgumentParser] = None,
) -> None
Do some pre-registration or update action for the current platform.
This function is called before global VllmConfig is initialized or cli arguments are parsed. It's used for out-of-tree platforms to register or update the configuration.
For example, the out-of-tree quantization config can be imported and registered here dynamically.
Source code in vllm/platforms/interface.py
seed_everything
classmethod
¶
Set the seed of each random module.
torch.manual_seed
will set seed on all devices.
Loosely based on: https://github.com/Lightning-AI/pytorch-lightning/blob/2.4.0/src/lightning/fabric/utilities/seed.py#L20
Source code in vllm/platforms/interface.py
stateless_init_device_torch_dist_pg
classmethod
¶
stateless_init_device_torch_dist_pg(
backend: str,
prefix_store: PrefixStore,
group_rank: int,
group_size: int,
timeout: timedelta,
) -> ProcessGroup
Init platform-specific torch distributed process group.
Source code in vllm/platforms/interface.py
supports_v1
classmethod
¶
supports_v1(model_config: ModelConfig) -> bool
Returns whether the current platform can support v1 for the supplied model configuration.
use_all_gather
classmethod
¶
use_all_gather() -> bool
Whether to use allgather in LogitsProcessor to gather the logits.
Source code in vllm/platforms/interface.py
validate_request
classmethod
¶
validate_request(
prompt: PromptType,
params: Union[SamplingParams, PoolingParams],
processed_inputs: ProcessorInputs,
) -> None
Raises if this request is unsupported on this platform
verify_model_arch
classmethod
¶
verify_model_arch(model_arch: str) -> None
Verify whether the current platform supports the specified model architecture.
- This will raise an Error or Warning based on the model support on the current platform.
- By default all models are considered supported.
Source code in vllm/platforms/interface.py
verify_quantization
classmethod
¶
verify_quantization(quant: str) -> None
Verify whether the quantization is supported by the current platform.
Source code in vllm/platforms/interface.py
__getattr__
¶
__getattr__(name: str)
Source code in vllm/platforms/__init__.py
cpu_platform_plugin
¶
Source code in vllm/platforms/__init__.py
cuda_platform_plugin
¶
Source code in vllm/platforms/__init__.py
hpu_platform_plugin
¶
Source code in vllm/platforms/__init__.py
neuron_platform_plugin
¶
Source code in vllm/platforms/__init__.py
resolve_current_platform_cls_qualname
¶
resolve_current_platform_cls_qualname() -> str
Source code in vllm/platforms/__init__.py
rocm_platform_plugin
¶
Source code in vllm/platforms/__init__.py
tpu_platform_plugin
¶
Source code in vllm/platforms/__init__.py
vllm_version_matches_substr
¶
Check to see if the vLLM version matches a substring.