vllm.model_executor.layers.batch_invariant ¶
AttentionBlockSize module-attribute
¶
AttentionBlockSize = namedtuple(
"AttentionBlockSize", ["block_m", "block_n"]
)
_compute_pid ¶
Source code in vllm/model_executor/layers/batch_invariant.py
_log_softmax_batch_invariant ¶
_log_softmax_kernel ¶
_log_softmax_kernel(
input_ptr,
output_ptr,
input_row_stride,
output_row_stride,
n_cols,
BLOCK_SIZE: constexpr,
)
Compute log_softmax along the last dimension of a 2D tensor. Each block handles one row of the input tensor.
Source code in vllm/model_executor/layers/batch_invariant.py
_matmul_launch_metadata ¶
_matmul_launch_metadata(
grid: Callable[..., Any],
kernel: Any,
args: dict[str, Any],
) -> dict[str, Any]
Source code in vllm/model_executor/layers/batch_invariant.py
addmm_batch_invariant ¶
disable_batch_invariant_mode ¶
enable_batch_invariant_mode ¶
Source code in vllm/model_executor/layers/batch_invariant.py
get_batch_invariant_attention_block_size ¶
get_batch_invariant_attention_block_size() -> (
AttentionBlockSize
)
init_batch_invariance ¶
is_batch_invariant_mode_enabled ¶
log_softmax ¶
Compute log_softmax using Triton kernel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input | Tensor | Input tensor | required |
dim | int | Dimension along which to compute log_softmax (only -1 or last dim supported) | -1 |
Stashed changes Returns: Tensor with log_softmax applied along the specified dimension
Source code in vllm/model_executor/layers/batch_invariant.py
matmul_kernel_persistent ¶
matmul_kernel_persistent(
a_ptr,
b_ptr,
c_ptr,
bias_ptr,
M,
N,
K,
stride_am,
stride_ak,
stride_bk,
stride_bn,
stride_cm,
stride_cn,
BLOCK_SIZE_M: constexpr,
BLOCK_SIZE_N: constexpr,
BLOCK_SIZE_K: constexpr,
GROUP_SIZE_M: constexpr,
NUM_SMS: constexpr,
A_LARGE: constexpr,
B_LARGE: constexpr,
C_LARGE: constexpr,
HAS_BIAS: constexpr,
)
Source code in vllm/model_executor/layers/batch_invariant.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 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 |
|
matmul_persistent ¶
Source code in vllm/model_executor/layers/batch_invariant.py
mean_batch_invariant ¶
Source code in vllm/model_executor/layers/batch_invariant.py
mean_dim ¶
mean_dim(
input: Tensor,
dim: int,
keepdim: bool = False,
dtype: Union[dtype, None] = None,
) -> Tensor
Triton implementation of torch.mean with single dimension reduction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input | Tensor | Input tensor | required |
dim | int | Single dimension along which to compute mean | required |
keepdim | bool | Whether to keep the reduced dimension | False |
dtype | Union[dtype, None] | Output dtype. If None, uses input dtype (or float32 for integer inputs) | None |
Returns:
Type | Description |
---|---|
Tensor | Tensor with mean values along specified dimension |
Source code in vllm/model_executor/layers/batch_invariant.py
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 |
|
mean_kernel ¶
mean_kernel(
input_ptr,
output_ptr,
input_stride0,
input_stride1,
input_stride2,
output_stride0,
output_stride1,
M,
N,
K,
BLOCK_SIZE: constexpr,
)
Kernel for computing mean along a single dimension. Input is viewed as (M, N, K) where N is the dimension being reduced.
Source code in vllm/model_executor/layers/batch_invariant.py
mm_batch_invariant ¶
set_batch_invariant_mode ¶
set_batch_invariant_mode(enabled: bool = True)