Commit cdb2234
committed
Fix no-op exploit in 19 KernelBench baselines: zero-init weights -> random
18k-50k KernelBench-derived baselines initialized their weight/bias tensors to
jnp.zeros in create_inputs. With zero weights, `x @ W (+ b)` is identically
zero and independent of the input, so the reference output is a trivial
constant (all-zero, or a fixed activation thereof). Any kernel returning that
constant -- including a no-op that skips the matmul/conv entirely -- passes
np.allclose, so these benchmarks could report large meaningless speedups
without computing the operator.
This replaces the zero-init weights/biases with small-normal random values
(~0.02 scale: input-dependent, bf16-representable, no overflow). Only
create_inputs is changed; the workload/op is untouched. After the fix a no-op
(all-zero output) fails correctness on all 19.
Scope: 19 of the affected baselines are fully fixed by non-zero weights. Five
others whose *output* is intrinsically small regardless of weights -- the
softmax-terminated 38k/43k/50k (row outputs ~1/N) and the structurally
degenerate 25k (GroupNorm->Mean) and 42k (Max-Subtract-GELU) -- are NOT
addressed here; they need a tolerance or operator change and are left to a
follow-up. Megablox (11p) has a distinct input-underflow variant fixed
separately.1 parent d43d848 commit cdb2234
19 files changed
Lines changed: 81 additions & 43 deletions
File tree
- JAXBench/benchmark
- 18k_Conv2D_ReLU_BiasAdd
- 19k_Matmul_Subtract_Multiply_ReLU
- 20k_Gemm_Multiply_LeakyReLU
- 22k_Conv2d_InstanceNorm_Divide
- 23k_Matmul_Sum_Max_AvgPool_LogSumExp_LogSumExp
- 27k_Matmul_Mish_Mish
- 29k_Matmul_Swish_Sum_GroupNorm
- 30k_Matmul_Scaling_ResidualAdd
- 33k_Conv3d_Mish_Tanh
- 35k_Gemm_Scaling_Hardtanh_GELU
- 37k_Matmul_Swish_Scaling
- 39k_Conv2d_GELU_GlobalAvgPool
- 40k_Gemm_GroupNorm_Min_BiasAdd
- 41k_Gemm_Add_ReLU
- 44k_Matmul_Divide_GELU
- 45k_Gemm_GroupNorm_Swish_Multiply_Swish
- 47k_Matmul_Add_Swish_Tanh_GELU_Hardtanh
- 48k_Matmul_BatchNorm_BiasAdd_Divide_Swish
- 49k_Matmul_AvgPool_GELU_Scale_Max
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | | - | |
22 | | - | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | | - | |
20 | | - | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | | - | |
20 | | - | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | | - | |
22 | | - | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | | - | |
18 | | - | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | | - | |
18 | | - | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | | - | |
20 | | - | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | | - | |
19 | | - | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
21 | | - | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | | - | |
21 | | - | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
0 commit comments