family stringclasses 6
values | bug_class stringclasses 6
values | correct_name stringclasses 6
values | buggy_name stringlengths 12 22 | correct_source stringclasses 6
values | buggy_source stringlengths 566 1.47k | why_standard_misses stringlengths 44 205 | witness_inputs stringlengths 0 45.2k | witness_dims stringlengths 0 30 | numerically_observable bool 2
classes |
|---|---|---|---|---|---|---|---|---|---|
elementwise | mask_leak | gelu | elementwise_nomask | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*N
# litmus: buffer out_ptr = M*N
# litmus: grid = M
@triton.jit
def gelu(x_ptr, out_ptr, M, N, BLOCK: tl.constexpr):
row = tl.program_id(0)
for start in range(0, N, BLOCK):
cols = start + tl.arange(0, ... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*N
# litmus: buffer w_ptr = N
# litmus: buffer b_ptr = N
# litmus: buffer out_ptr = M*N
# litmus: grid = M
@triton.jit
def elementwise_scale_bias(x_ptr, w_ptr, b_ptr, out_ptr, M, N, BLOCK: tl.constexpr):
row = tl.p... | N=512 is a multiple of BLOCK=32 so no tail exists -- and even at a ragged shape the spilled write lands in a neighbouring allocation, so the kernel's own output is unchanged and no allclose test can see it | false | ||
reduction | mask_leak | row_max | row_sum_nomask | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_max(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.full... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_reduce(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.z... | N=512 is a multiple of BLOCK=32, so no tail tile exists | {"x": {"shape": [3, 33], "truncated": false, "values": [[0.9323224351204542, -0.13484240850688187, -1.0977711087115172, 1.2093136358526926, -1.5200609774258935, -0.3659055784186133, 0.08753656217963342, -0.673525657000616, -0.31220063548687593, 0.6517512317274256, 0.10188336399475949, 2.1183280668541165, -0.17471049088... | {"M": 3, "N": 33} | true |
softmax | mask_leak | softmax | softmax_nomask | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*N
# litmus: buffer out_ptr = M*N
# litmus: grid = M
@triton.jit
def softmax(x_ptr, out_ptr, M, N, BLOCK: tl.constexpr):
row = tl.program_id(0)
mx = float('-inf')
for start in range(0, N, BLOCK):
co... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*N
# litmus: buffer out_ptr = M*N
# litmus: grid = M
@triton.jit
def softmax(x_ptr, out_ptr, M, N, BLOCK: tl.constexpr):
row = tl.program_id(0)
mx = float('-inf')
for start in range(0, N, BLOCK):
co... | N=512 is a multiple of BLOCK=32, so no tail tile exists | {"x": {"shape": [3, 33], "truncated": false, "values": [[0.9323224351204542, -0.13484240850688187, -1.0977711087115172, 1.2093136358526926, -1.5200609774258935, -0.3659055784186133, 0.08753656217963342, -0.673525657000616, -0.31220063548687593, 0.6517512317274256, 0.10188336399475949, 2.1183280668541165, -0.17471049088... | {"M": 3, "N": 33} | true |
matmul | mask_leak | matmul_fp16 | matmul_no_k_mask | import triton
import triton.language as tl
# litmus: constexpr BLOCK_M = 32
# litmus: constexpr BLOCK_N = 32
# litmus: constexpr BLOCK_K = 32
# litmus: buffer a_ptr = M*K
# litmus: buffer b_ptr = K*N
# litmus: buffer c_ptr = M*N
# litmus: grid = cdiv(M, BLOCK_M), cdiv(N, BLOCK_N)
@triton.jit
def matmul(a_ptr, b_ptr, ... | import triton
import triton.language as tl
# litmus: constexpr BLOCK_M = 32
# litmus: constexpr BLOCK_N = 32
# litmus: constexpr BLOCK_K = 32
# litmus: buffer a_ptr = M*K
# litmus: buffer b_ptr = K*N
# litmus: buffer c_ptr = M*N
# litmus: grid = cdiv(M, BLOCK_M), cdiv(N, BLOCK_N)
@triton.jit
def matmul(a_ptr, b_ptr, ... | M, N and K are all multiples of the block sizes | {"a": {"shape": [33, 33], "truncated": false, "values": [[-1.0748366301390833, -1.2726386174365862, 0.1279170812576446, 0.8101496187256504, 0.532242471968371, 0.2531135831967665, -1.2944793771672414, 1.3746620788661008, -1.9738913399051794, -0.6994014763584023, -0.5944289753341545, 1.975460784799716, 0.5942356035795224... | {"M": 33, "N": 33, "K": 33} | true |
reduction | reduction_init | row_max | row_sum_init_one | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_max(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.full... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_reduce(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.f... | a constant offset of 1.0 on a sum of ~256 uniform values is a 0.4% relative error, inside rtol=1e-2 | {"x": {"shape": [2, 32], "truncated": false, "values": [[1.3640195228050165e-05, -6.271425885369812e-05, 0.0002491574809406205, 4.958468028771155e-05, 0.001182665742342288, 0.0014049343623371935, 5.121767282302068e-06, -0.00027448581677559354, 0.00045090785195024214, -0.0010611754068181793, 0.0002702059525341101, -0.00... | {"M": 2, "N": 32} | true |
reduction | reduction_init | row_max | row_max_init_zero | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_max(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.full... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_max(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.full... | torch.rand() is non-negative, so max(0, row) == max(row) always -- the identity is never exercised | {"x": {"shape": [2, 32], "truncated": false, "values": [[-2.0217323059579484, -1.1205637636917152, -2.4247685045640193, -1.3973503794981748, -1.0511792194528577, -2.486817219473164, -2.486142150540828, -1.566083548064621, -1.5546883794496305, -1.303046759826813, -1.4304403953391798, -1.2822758667527667, -2.129170614427... | {"M": 2, "N": 32} | true |
matmul | reduction_init | matmul_fp16 | matmul_acc_init_one | import triton
import triton.language as tl
# litmus: constexpr BLOCK_M = 32
# litmus: constexpr BLOCK_N = 32
# litmus: constexpr BLOCK_K = 32
# litmus: buffer a_ptr = M*K
# litmus: buffer b_ptr = K*N
# litmus: buffer c_ptr = M*N
# litmus: grid = cdiv(M, BLOCK_M), cdiv(N, BLOCK_N)
@triton.jit
def matmul(a_ptr, b_ptr, ... | import triton
import triton.language as tl
# litmus: constexpr BLOCK_M = 32
# litmus: constexpr BLOCK_N = 32
# litmus: constexpr BLOCK_K = 32
# litmus: buffer a_ptr = M*K
# litmus: buffer b_ptr = K*N
# litmus: buffer c_ptr = M*N
# litmus: grid = cdiv(M, BLOCK_M), cdiv(N, BLOCK_N)
@triton.jit
def matmul(a_ptr, b_ptr, ... | K=512 with uniform inputs gives entries of order 128, so a +1.0 offset is under the 1e-2 relative tolerance | {"a": {"shape": [4, 4], "truncated": false, "values": [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]}, "b": {"shape": [4, 4], "truncated": false, "values": [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]}} | {"M": 4, "N": 4, "K": 4} | true |
softmax | no_max_subtract | softmax | softmax_nomaxsub | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*N
# litmus: buffer out_ptr = M*N
# litmus: grid = M
@triton.jit
def softmax(x_ptr, out_ptr, M, N, BLOCK: tl.constexpr):
row = tl.program_id(0)
mx = float('-inf')
for start in range(0, N, BLOCK):
co... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*N
# litmus: buffer out_ptr = M*N
# litmus: grid = M
@triton.jit
def softmax(x_ptr, out_ptr, M, N, BLOCK: tl.constexpr):
row = tl.program_id(0)
mx = float('-inf')
for start in range(0, N, BLOCK):
co... | torch.rand() lives in [0,1), where exp(x) never approaches the fp32 range limit | {"x": {"shape": [2, 32], "truncated": false, "values": [[200.0, -1.6317065930677275, 1.3217959639836427, 0.08268651793293419, -1.176789075556173, 1.15634948500117, 0.9812034560390803, -1.450232629943399, 1.1097434560609962, -0.6118264608379209, -0.9788509639537006, 0.7335103590365222, -0.7359528732349158, -1.4723083533... | {"M": 2, "N": 32} | true |
attention | no_max_subtract | attention | attention_nomaxsub | import triton
import triton.language as tl
# litmus: constexpr BLOCK_D = 32
# litmus: buffer q_ptr = M*D
# litmus: buffer k_ptr = L*D
# litmus: buffer v_ptr = L*D
# litmus: buffer out_ptr = M*D
# litmus: grid = M
@triton.jit
def attention(q_ptr, k_ptr, v_ptr, out_ptr, M, L, D, BLOCK_D: tl.constexpr):
i = tl.progr... | import triton
import triton.language as tl
# litmus: constexpr BLOCK_D = 32
# litmus: buffer q_ptr = M*D
# litmus: buffer k_ptr = L*D
# litmus: buffer v_ptr = L*D
# litmus: buffer out_ptr = M*D
# litmus: grid = M
@triton.jit
def attention(q_ptr, k_ptr, v_ptr, out_ptr, M, L, D, BLOCK_D: tl.constexpr):
i = tl.progr... | unit-scale q and k keep the scores near zero | {"q": {"shape": [4, 32], "truncated": false, "values": [[-24.986394524353937, -58.8677056935254, 136.8091412817628, 98.4846584556703, -141.90936613026366, 57.92291122033178, -26.18228618310603, -18.036587790902377, 16.136338992120105, -92.00511661049477, -84.77698096431314, -47.58644104490596, -55.3344933411368, -110.7... | {"M": 4, "L": 8, "D": 32} | true |
reduction | race | row_max | row_sum_race | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_max(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.full... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = 1
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_sum_race(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl... | on real hardware the lost update is intermittent; a single allclose run sees it only sometimes | {"x": {"shape": [4, 32], "truncated": false, "values": [[0.9323224351204542, -0.13484240850688187, -1.0977711087115172, 1.2093136358526926, -1.5200609774258935, -0.3659055784186133, 0.08753656217963342, -0.673525657000616, -0.31220063548687593, 0.6517512317274256, 0.10188336399475949, 2.1183280668541165, -0.17471049088... | {"M": 4, "N": 32} | true |
layernorm | race | layernorm | layernorm_race_stats | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer w_ptr = N
# litmus: buffer b_ptr = N
# litmus: buffer out_ptr = M*N
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def layernorm(x_ptr, w_ptr, b_ptr, out_ptr, M, ... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer w_ptr = N
# litmus: buffer b_ptr = N
# litmus: buffer out_ptr = M*N
# litmus: buffer stats_ptr = 2
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def layernorm_ra... | rows of i.i.d. noise have near-identical statistics, so reading another row's mean and variance barely changes the output | {"x": {"shape": [4, 32], "truncated": false, "values": [[-0.7111066620607831, -0.18152747526685256, -0.5776135416552802, -0.1570444641441432, 1.023144014263097, -0.6279538720442022, -0.5224700162677491, 1.964888119715187, -2.007477339053849, -0.6355140596028792, 0.8284850190307785, -0.5158542499703735, -0.4910477281868... | {"M": 4, "N": 32, "S": 32} | true |
reduction | race | row_max | row_sum_barrier | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_max(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.full... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_sum_barrier(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc =... | divergent barriers produce no numerical error at all until the schedule changes -- they are invisible to any output comparison | false | ||
matmul | dtype_promotion | matmul_fp16 | matmul_fp16_acc16 | import triton
import triton.language as tl
# litmus: constexpr BLOCK_M = 32
# litmus: constexpr BLOCK_N = 32
# litmus: constexpr BLOCK_K = 32
# litmus: buffer a_ptr = M*K
# litmus: buffer b_ptr = K*N
# litmus: buffer c_ptr = M*N
# litmus: grid = cdiv(M, BLOCK_M), cdiv(N, BLOCK_N)
@triton.jit
def matmul(a_ptr, b_ptr, ... | import triton
import triton.language as tl
# litmus: constexpr BLOCK_M = 32
# litmus: constexpr BLOCK_N = 32
# litmus: constexpr BLOCK_K = 32
# litmus: buffer a_ptr = M*K
# litmus: buffer b_ptr = K*N
# litmus: buffer c_ptr = M*N
# litmus: grid = cdiv(M, BLOCK_M), cdiv(N, BLOCK_N)
@triton.jit
def matmul(a_ptr, b_ptr, ... | at K=512 with values in [0,1) the fp16 accumulator has not yet stagnated; the error stays under rtol=1e-2 | {"a": {"shape": [32, 2048], "truncated": true, "values": [3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.... | {"M": 32, "N": 32, "K": 2048} | true |
reduction | dtype_promotion | row_max | row_sum_fp16_acc | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_max(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.full... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_reduce(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.z... | an fp16 accumulator stagnates above ~2048 and overflows above 65504; with N=512 and values in [0,1) the running total only reaches about 256 | {"x": {"shape": [2, 1024], "truncated": false, "values": [[100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 10... | {"M": 2, "N": 1024, "S": 1024} | true |
reduction | stride | row_max | row_sum_wrong_stride | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_max(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.full... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer out_ptr = M
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def row_reduce(x_ptr, out_ptr, M, N, S, BLOCK: tl.constexpr):
row = tl.program_id(0)
acc = tl.z... | benchmarks always pass contiguous tensors, where the row stride equals the row width and the bug is a no-op | {"x": {"shape": [3, 40], "truncated": false, "values": [[-0.7111066620607831, -0.18152747526685256, -0.5776135416552802, -0.1570444641441432, 1.023144014263097, -0.6279538720442022, -0.5224700162677491, 1.964888119715187, -2.007477339053849, -0.6355140596028792, 0.8284850190307785, -0.5158542499703735, -0.4910477281868... | {"M": 3, "N": 32, "S": 40} | true |
layernorm | stride | layernorm | layernorm_wrong_stride | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer w_ptr = N
# litmus: buffer b_ptr = N
# litmus: buffer out_ptr = M*N
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def layernorm(x_ptr, w_ptr, b_ptr, out_ptr, M, ... | import triton
import triton.language as tl
# litmus: constexpr BLOCK = 32
# litmus: buffer x_ptr = M*S
# litmus: buffer w_ptr = N
# litmus: buffer b_ptr = N
# litmus: buffer out_ptr = M*N
# litmus: grid = M
# litmus: subst S = N + P
# litmus: sym P in [0, 8]
@triton.jit
def layernorm(x_ptr, w_ptr, b_ptr, out_ptr, M, ... | benchmarks always pass contiguous tensors, where the row stride equals the row width and the bug is a no-op | {"x": {"shape": [3, 40], "truncated": false, "values": [[-0.7111066620607831, -0.18152747526685256, -0.5776135416552802, -0.1570444641441432, 1.023144014263097, -0.6279538720442022, -0.5224700162677491, 1.964888119715187, -2.007477339053849, -0.6355140596028792, 0.8284850190307785, -0.5158542499703735, -0.4910477281868... | {"M": 3, "N": 32, "S": 40} | true |
Litmus Kernel Verification Corpus
Correct and deliberately-broken Triton kernels, each broken one shipped with the input that exposes it.
The corpus exists to measure one thing: how much of what a fixed-shape
torch.rand() allclose test calls "correct" actually is. On this corpus the
answer is that 88% of the planted bugs pass that test.
Columns
| column | meaning |
|---|---|
name |
kernel identifier |
family |
elementwise / reduction / softmax / layernorm / matmul / attention |
bug_class |
none for correct kernels, otherwise one of six planted defect families |
triton_source |
the kernel, annotated with its buffer contract |
correct |
ground-truth label |
numerically_observable |
false when the defect has no numerical signature at any shape |
why_standard_misses |
why the fixed-shape allclose test lets this bug through |
witness_inputs |
JSON arrays: the exposing input (buggy kernels only) |
witness_dims |
the shape the witness uses |
witness_max_abs_error |
deviation from the float64 oracle on the witness |
standard_test_detects |
did allclose(rtol=1e-2) on the fixed shape catch it? |
litmus_verdict |
accept / reject / unknown at build time |
Bug families
dtype_promotion— 2 kernelsmask_leak— 4 kernelsno_max_subtract— 2 kernelsrace— 3 kernelsreduction_init— 3 kernelsstride— 2 kernels
Caveat
The corpus is deliberately bug-heavy (16 buggy, 9 correct), so the absolute "fraction correct" is a property of this corpus, not of kernels in general. The finding is the gap between the standard test's pass rate and the truth.
Reproduce
git clone https://github.com/NagaYu/litmus && cd litmus
pip install -e ".[dev]"
python benchmarks/run.py # regenerates the numbers above
Built by Litmus -- error bounds, symbolic GPU safety checks and targeted falsification for Triton kernels. Interactive demo: Space.
- Downloads last month
- 31