torch.compile (inductor)
PyTorch · python · MIT
Kernel source · 46 lines ↓holds 2 records
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 46 lines, MIT.
36_RMSNorm_.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-36-rmsnorm-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.
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:ab1dc55d7a84626121d5f71aad7b6bcefc983ef5c440349367820ac2ea9e667e
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
36_RMSNorm_.py46 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs RMS Normalization.
"""
def __init__(self, num_features: int, eps: float = 1e-5):
"""
Initializes the RMSNorm layer.
Args:
num_features (int): Number of features in the input tensor.
eps (float, optional): A small value added to the denominator to avoid division by zero. Defaults to 1e-5.
"""
super(Model, self).__init__()
self.num_features = num_features
self.eps = eps
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""
Applies RMS Normalization to the input tensor.
Args:
x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).
Returns:
torch.Tensor: Output tensor with RMS Normalization applied, same shape as input.
"""
# Calculate the RMS along the feature dimension
rms = torch.sqrt(torch.mean(x ** 2, dim=1, keepdim=True) + self.eps)
# Normalize the input by dividing by the RMS
return x / rms
batch_size = 112
features = 64
dim1 = 512
dim2 = 512
def get_inputs():
x = torch.rand(batch_size, features, dim1, dim2)
return [x]
def get_init_inputs():
return [features]scrolls · 46 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