Skip to content
KernelIndex
Search⌘K

torch.compile (inductor)

PyTorch · python · MIT

Use it

Vendorable · source mirrored · MITView source →

No package. Vendor the mirrored source: 35 lines, MIT.

3_Batched_matrix_multiplication.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-3-batched-matrix-multiplication-torch-compile-inductor?include=source"
interfacepython · torch_compile_inductor
symbolModel.forward
Compatibility
measured onNVIDIA H100
declared hardwaredeclared only
architectures—
dtypes

Benchmark evidence

2 measurements across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
Batched matrix multiplicationfp32 · [128, 512, 1024]
NVIDIA H100
5.35ms±0.01
#2 of 2
2026-03-05
Batched matrix multiplicationfp32 · [128, 512, 1024]
NVIDIA H100
8.47ms±0.05
#2 of 2
2026-03-05

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:5bfb6daf056ea03a3a35999853789235889a7f8909c720ee849b948179396c37
license declaredMIT
license concludedMIT
imported2026-08-26

Kernel source

3_Batched_matrix_multiplication.py35 lines
import torch
import torch.nn as nn

class Model(nn.Module):
    """
    Performs batched matrix multiplication (C = A * B) where A, B, and C have the same batch dimension.
    """
    def __init__(self):
        super(Model, self).__init__()
    
    def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:
        """
        Performs batched matrix multiplication.

        Args:
            A: Input tensor of shape (batch_size, m, k).
            B: Input tensor of shape (batch_size, k, n).

        Returns:
            C: Output tensor of shape (batch_size, m, n).
        """
        return torch.bmm(A, B)

batch_size = 128
m = 128 * 4
k = 256 * 4
n = 512 * 4

def get_inputs():
    A = torch.rand(batch_size, m, k)
    B = torch.rand(batch_size, k, n)
    return [A, B]

def get_init_inputs():
    return []  # No special initialization inputs needed
scrolls · 35 lines total

Source code from KernelBench, © 2023 Anne Ouyang, Simon Guo, Azalia Mirhoseini (Scaling Intelligence Lab, Stanford University), MIT License · MIT

Best evidence level for this revision: reported

JSON