vllm.model_executor.layers.quantization.utils.w8a8_utils
CUTLASS_BLOCK_FP8_SUPPORTED module-attribute
¶
CUTLASS_BLOCK_FP8_SUPPORTED = cutlass_block_fp8_supported()
USE_ROWWISE_TORCH_SCALED_MM module-attribute
¶
USE_ROWWISE_TORCH_SCALED_MM = (
is_rocm()
and parse(__version__) >= parse("2.7")
and has_device_capability(94)
)
Fp8LinearOp ¶
This class executes a FP8 linear layer using cutlass if supported and torch.scaled_mm otherwise. It needs to be a class instead of a method so that config can be read in the init method, as reading config is not allowed inside forward.
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
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 |
|
quant_fp8 instance-attribute
¶
quant_fp8 = QuantFP8(
static=act_quant_static,
group_shape=act_quant_group_shape,
num_token_padding=output_padding,
)
__init__ ¶
__init__(
act_quant_static: bool,
act_quant_group_shape: GroupShape = PER_TENSOR,
pad_output: Optional[bool] = None,
force_fp8_e4m3fnuz: bool = False,
)
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
apply ¶
apply(
input: Tensor,
weight: Tensor,
weight_scale: Tensor,
out_dtype: Optional[dtype] = None,
input_scale: Optional[Tensor] = None,
input_scale_ub: Optional[Tensor] = None,
bias: Optional[Tensor] = None,
) -> Tensor
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
all_close_1d ¶
convert_to_channelwise ¶
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
cutlass_block_fp8_supported ¶
cutlass_block_fp8_supported() -> bool
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
cutlass_fp8_supported ¶
cutlass_fp8_supported() -> bool
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
cutlass_group_gemm_supported ¶
cutlass_group_gemm_supported() -> bool
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
cutlass_w8a8_scaled_mm ¶
cutlass_w8a8_scaled_mm(
*,
qinput: Tensor,
weight: Tensor,
out_dtype: dtype,
scale_a: Tensor,
scale_b: Tensor,
bias: Tensor,
output_shape: list,
**kwargs,
) -> Tensor
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
dispatch_w8a8_scaled_mm ¶
dispatch_w8a8_scaled_mm(
preferred_backend: str,
per_tensor_weights: bool,
per_tensor_activations: bool,
) -> Callable[..., Tensor]
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
flashinfer_w8a8_scaled_mm ¶
flashinfer_w8a8_scaled_mm(
*,
qinput: Tensor,
weight: Tensor,
out_dtype: dtype,
scale_a: Tensor,
scale_b: Tensor,
bias: Tensor,
output_shape: list,
**kwargs,
) -> Tensor
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
maybe_create_device_identity ¶
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
normalize_e4m3fn_to_e4m3fnuz ¶
normalize_e4m3fn_to_e4m3fnuz(
weight: Tensor,
weight_scale: Tensor,
input_scale: Optional[Tensor] = None,
) -> tuple[Tensor, Tensor, Optional[Tensor]]
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
per_tensor_dequantize ¶
requantize_with_max_scale ¶
requantize_with_max_scale(
weight: Tensor,
weight_scale: Tensor,
logical_widths: list[int],
) -> tuple[Tensor, Tensor]
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
rocm_per_tensor_w8a8_scaled_mm ¶
rocm_per_tensor_w8a8_scaled_mm(
*,
qinput: Tensor,
weight: Tensor,
out_dtype: dtype,
scale_a: Tensor,
scale_b: Tensor,
bias: Tensor,
input_2d: Tensor,
output_shape: list,
) -> Tensor
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
rocm_per_tensor_w8a8_scaled_mm_fake ¶
rocm_per_tensor_w8a8_scaled_mm_fake(
qinput: Tensor,
weight: Tensor,
out_dtype: dtype,
scale_a: Tensor,
scale_b: Tensor,
bias: Tensor,
input_2d: Tensor,
) -> Tensor
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
rocm_per_tensor_w8a8_scaled_mm_impl ¶
rocm_per_tensor_w8a8_scaled_mm_impl(
qinput: Tensor,
weight: Tensor,
out_dtype: dtype,
scale_a: Tensor,
scale_b: Tensor,
bias: Tensor,
input_2d: Tensor,
) -> Tensor
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
sparse_cutlass_supported ¶
sparse_cutlass_supported() -> bool
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
torch_channelwise_w8a8_scaled_mm ¶
torch_channelwise_w8a8_scaled_mm(
*,
qinput: Tensor,
weight: Tensor,
out_dtype: dtype,
scale_a: Tensor,
scale_b: Tensor,
bias: Tensor,
input_2d: Tensor,
output_shape: list,
**kwargs,
) -> Tensor
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
torch_per_tensor_w8a8_scaled_mm ¶
torch_per_tensor_w8a8_scaled_mm(
*,
qinput: Tensor,
weight: Tensor,
out_dtype: dtype,
scale_a: Tensor,
scale_b: Tensor,
bias: Tensor,
input_2d: Tensor,
output_shape: list,
) -> Tensor
Source code in vllm/model_executor/layers/quantization/utils/w8a8_utils.py
torch_per_token_w8a8_scaled_mm ¶
torch_per_token_w8a8_scaled_mm(
*,
qinput: Tensor,
weight: Tensor,
out_dtype: dtype,
scale_a: Tensor,
scale_b: Tensor,
bias: Tensor,
input_2d: Tensor,
output_shape: list,
**kwargs,
) -> Tensor