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: 39 lines, MIT.

70_Gemm_Sigmoid_Scaling_ResidualAdd.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-70-gemm-sigmoid-scaling-residualadd-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
NVIDIA H100
2.77ms±0.01
#1= of 2
2026-03-05
NVIDIA H100
5.00ms±0.02
#2 of 2
2026-03-05

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:d576cbb6e95a597fdf988f9033786cb878021635fc15afed7c0e255ba3dcc9c9
license declaredMIT
license concludedMIT
imported2026-08-26

Kernel source

70_Gemm_Sigmoid_Scaling_ResidualAdd.py39 lines
import torch
import torch.nn as nn

class Model(nn.Module):
    """
    Model implementing the pattern "Gemm_Sigmoid_Scaling_ResidualAdd".
    """
    def __init__(self, input_size, hidden_size, scaling_factor):
        super(Model, self).__init__()
        self.gemm = nn.Linear(input_size, hidden_size)
        self.scaling_factor = scaling_factor

    def forward(self, x):
        """
        Forward pass of the model.

        Args:
            x (torch.Tensor): Input tensor of shape (batch_size, input_size).

        Returns:
            torch.Tensor: Output tensor of shape (batch_size, hidden_size).
        """
        x = self.gemm(x)
        original_x = x
        x = torch.sigmoid(x)
        x = x * self.scaling_factor
        x = x + original_x
        return x

batch_size = 1024
input_size = 8192
hidden_size = 8192
scaling_factor = 2.0

def get_inputs():
    return [torch.rand(batch_size, input_size)]

def get_init_inputs():
    return [input_size, hidden_size, scaling_factor]
scrolls · 39 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