vllm.model_executor.determinism.batch_invariant ¶
Functions:
-
bmm_kernel–Batched GEMM: (B, M, K) x (B, K, N) -> (B, M, N)
-
log_softmax–Compute log_softmax using Triton kernel.
-
matmul_descriptor_persistent–Persistent matmul using tensor descriptors (Intel XPU fast path).
-
matmul_kernel_descriptor_persistent–Persistent matmul using tensor descriptors for 2D block I/O.
-
mean_dim–Triton implementation of torch.mean with single dimension reduction.
-
mean_kernel–Kernel for computing mean along a single dimension.
-
rms_norm_batch_invariant–Compute RMS normalization using Triton kernel.
_log_softmax_kernel(input_ptr, output_ptr, input_row_stride, output_row_stride, n_cols, BLOCK_SIZE) ¶
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/determinism/batch_invariant.py
_rms_norm_kernel(input_ptr, weight_ptr, output_ptr, input_row_stride, output_row_stride, n_cols, eps, BLOCK_SIZE, HAS_WEIGHT) ¶
Compute RMS normalization along the last dimension of a 2D tensor. RMS Norm: y = x / sqrt(mean(x^2) + eps) * weight Each block handles one row of the input tensor.
Source code in vllm/model_executor/determinism/batch_invariant.py
bmm_kernel(a_ptr, b_ptr, c_ptr, B, M, N, K, stride_ab, stride_am, stride_ak, stride_bb, stride_bk, stride_bn, stride_cb, stride_cm, stride_cn, BLOCK_SIZE_M, BLOCK_SIZE_N, BLOCK_SIZE_K, A_LARGE, B_LARGE, C_LARGE) ¶
Batched GEMM: (B, M, K) x (B, K, N) -> (B, M, N)
Each program computes one (batch_idx, tile_m, tile_n) tile, accumulating along K in a fixed order to preserve batch invariance.
Source code in vllm/model_executor/determinism/batch_invariant.py
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 | |
log_softmax(input, dim=-1) ¶
Compute log_softmax using Triton kernel.
Parameters:
-
(input¶Tensor) –Input tensor
-
(dim¶int, default:-1) –Dimension along which to compute log_softmax (only -1 or last dim supported)
Returns:
-
Tensor–Tensor with log_softmax applied along the specified dimension
Source code in vllm/model_executor/determinism/batch_invariant.py
matmul_descriptor_persistent(a, b, bias=None) ¶
Persistent matmul using tensor descriptors (Intel XPU fast path).
Parameters:
-
(a¶Tensor) –Input matrix [M, K], must be contiguous.
-
(b¶Tensor) –Weight matrix [K, N] (standard layout — transposed internally).
-
(bias¶Tensor | None, default:None) –Optional 1D bias vector [N].
Returns:
-
Tensor–Output matrix [M, N] with dtype matching the inputs.
Source code in vllm/model_executor/determinism/batch_invariant.py
matmul_kernel_descriptor_persistent(a_ptr, b_ptr, c_ptr, bias_ptr, M, N, K, BLOCK_SIZE_M, BLOCK_SIZE_N, BLOCK_SIZE_K, GROUP_SIZE_M, NUM_SMS, HAS_BIAS) ¶
Persistent matmul using tensor descriptors for 2D block I/O.
Expects b_ptr to point to a transposed B matrix of shape [N, K] with row-major (K-contiguous) layout. The dot product transposes each loaded B-tile back: dot(A_tile, B_tile.T).
~3x faster than the pointer-based persistent kernel on Intel XPU because tensor descriptors leverage hardware 2D block load/store with automatic bounds checking (no explicit masks needed).
Source code in vllm/model_executor/determinism/batch_invariant.py
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 | |
mean_dim(input, dim, keepdim=False, dtype=None) ¶
Triton implementation of torch.mean with single dimension reduction.
Parameters:
-
(input¶Tensor) –Input tensor
-
(dim¶int) –Single dimension along which to compute mean
-
(keepdim¶bool, default:False) –Whether to keep the reduced dimension
-
(dtype¶dtype | None, default:None) –Output dtype. If None, uses input dtype (or float32 for integer inputs)
Returns:
-
Tensor–Tensor with mean values along specified dimension
Source code in vllm/model_executor/determinism/batch_invariant.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | |
mean_kernel(input_ptr, output_ptr, input_stride0, input_stride1, input_stride2, output_stride0, output_stride1, M, N, K, BLOCK_SIZE) ¶
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/determinism/batch_invariant.py
rms_norm_batch_invariant(input, weight, eps=1e-06, residual=None) ¶
Compute RMS normalization using Triton kernel.
Parameters:
-
(input¶Tensor) –Input tensor of shape (..., hidden_size)
-
(weight¶Tensor | None) –Weight tensor of shape (hidden_size,), or None to skip the per-channel multiply (
RMSNorm(has_weight=False)) -
(eps¶float, default:1e-06) –Small constant for numerical stability
-
(residual¶Tensor | None, default:None) –Optional residual tensor fused into the normalization path
Returns:
-
Tensor | tuple[Tensor, Tensor]–RMS normalized tensor, or
(output, residual_out)whenresidual -
Tensor | tuple[Tensor, Tensor]–is provided