Skip to content
KernelIndex
Search⌘K

submission 874653

Praneeth Veligeti · 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.

submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-eigh-874653?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
50.5ms
#177 of 286
2026-07-14

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:07a1a3199378f44f6707e12789c966834eed2edaee7e4f272993d055085fade7
license declaredunknown
license concludedunknown
authorsPraneeth Veligeti
imported2026-08-26

Kernel source

submission.py31 lines
#!POPCORN leaderboard eigh
#!POPCORN gpu B200

import torch
from task import input_t, output_t


def _diagonal_eigh(data: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
    # For a diagonal matrix the answer is free:
    #   eigenvalues  = the diagonal entries (sorted ascending)
    #   eigenvectors = the standard basis vectors e_i, reordered the same way
    diag = data.diagonal(dim1=-2, dim2=-1)          # batch x n
    values, order = torch.sort(diag, dim=-1)        # ascending, per matrix

    # Column k of Q must be the basis vector for the k-th smallest eigenvalue.
    # one_hot(order) puts a 1 at [b, k, order[b, k]]; transposing makes it column k.
    vectors = torch.nn.functional.one_hot(order, num_classes=data.shape[-1])
    vectors = vectors.transpose(-2, -1).to(data.dtype)
    return vectors, values


def custom_kernel(data: input_t) -> output_t:
    # Fast path: if every off-diagonal entry is exactly zero, skip the solver.
    off_diag = data - torch.diag_embed(data.diagonal(dim1=-2, dim2=-1))
    if off_diag.abs().amax().item() == 0.0:
        return _diagonal_eigh(data)

    # General case: same solver as the baseline.
    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