Skip to content
KernelIndex
Search⌘K

submission 839293

vinu0163 · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

No package. Vendor the mirrored source: 31 lines, June 9 Researcher Reciprocity License v1.0.

2026-06-27-15-18-45-eigh_b200-worker-3-951b2066593c.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-eigh-839293?include=source"
interfacepython
Compatibility
measured onNVIDIA B200
declared hardwareNVIDIA B200
architecturessm_100
dtypesfp32

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
NVIDIA B200
54.1ms
#232 of 286
2026-06-27

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:3fd8e54ac0d46db635922864be725f78b77612e2743e84ce0953ac8bdec4f4bb
license declaredunknown
license concludedunknown
authorsvinu0163
imported2026-08-26

Kernel source

2026-06-27-15-18-45-eigh_b200-worker-3-951b2066593c.py31 lines
import torch

from task import input_t, output_t


def _identity(batch: int, n: int, data: torch.Tensor) -> torch.Tensor:
    return torch.eye(n, device=data.device, dtype=torch.float32).expand(batch, n, n)


def _diagonal_eigh(data: torch.Tensor) -> output_t | None:
    batch, n, _ = data.shape
    if batch > 2:
        return None
    if n > 1 and bool(data[..., 0, 1].abs().amax() != 0):
        return None
    diag = torch.diagonal(data, dim1=-2, dim2=-1)
    offdiag_l1 = data.abs().sum(dim=(-2, -1)) - diag.abs().sum(dim=-1)
    if bool(offdiag_l1.amax() != 0):
        return None
    values, order = torch.sort(diag, dim=-1)
    vectors = _identity(batch, n, data).gather(2, order.unsqueeze(1).expand(batch, n, n))
    return vectors.contiguous(), values.contiguous()


def custom_kernel(data: input_t) -> output_t:
    diagonal = _diagonal_eigh(data)
    if diagonal is not None:
        return diagonal
    values, vectors = torch.linalg.eigh(data)
    return vectors, values
scrolls · 31 lines total

Source code from GPU Mode and the KernelBot dataset · June 9 Researcher Reciprocity License v1.0

Best evidence level for this revision: reported

JSON