Skip to content

Commit e73792e

Browse files
Merge pull request #67 from AI-Hypercomputer/shangkun-fix-jaxbench
fix: update the adapted jaxbench dataset for 19 KernelBench baselines zero-init weights -> random
2 parents 46432ef + c6e66f4 commit e73792e

39 files changed

Lines changed: 163 additions & 87 deletions

File tree

JAXBench/benchmark/15p_RetNet_Retention/baseline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def workload(query, key, value):
6161
causal_mask = (distance >= 0).astype(jnp.float32)
6262
# γ^distance: (H, S, S)
6363
log_gamma = jnp.log(gammas) # (H,)
64-
decay = jnp.exp(log_gamma[:, None, None] * distance[None, :, :]) # (H, S, S)
64+
decay = jnp.exp(log_gamma[:, None, None] * jnp.maximum(distance, 0.0)[None, :, :]) # (H, S, S)
6565
decay = decay * causal_mask[None, :, :] # apply causal mask
6666

6767
# Retention: (Q K^T ⊙ D) V

MaxKernel/evaluation/jaxbench_adapted_dataset/18k_Conv2D_ReLU_BiasAdd/kernel_task.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ input_gen_code: |-
1212
height = width = 128
1313
1414
key = jax.random.key(0)
15+
rand_key = jax.random.key(0xBADC0DE)
16+
ka, kb, kc = jax.random.split(rand_key, 3)
1517
k1, k2 = jax.random.split(key)
1618
x = jax.random.uniform(k1, (batch_size, in_channels, height, width), dtype=dtype)
17-
weight = jnp.zeros((out_channels, in_channels, kernel_size, kernel_size), dtype=dtype)
18-
conv_bias = jnp.zeros(out_channels, dtype=dtype)
19-
bias = jnp.zeros((out_channels, 1, 1), dtype=dtype)
19+
weight = jax.random.normal(ka, (out_channels, in_channels, kernel_size, kernel_size), dtype=dtype) * 0.02
20+
conv_bias = jax.random.normal(kb, out_channels, dtype=dtype) * 0.02
21+
bias = jax.random.normal(kc, (out_channels, 1, 1), dtype=dtype) * 0.02
2022
2123
dynamic_args = [x, weight, conv_bias, bias]
2224
static_args = []

MaxKernel/evaluation/jaxbench_adapted_dataset/18k_Conv2D_ReLU_BiasAdd/reference.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ def get_inputs(dtype=jnp.float32):
1111
height = width = 128
1212

1313
key = jax.random.key(0)
14+
rand_key = jax.random.key(0xBADC0DE)
15+
ka, kb, kc = jax.random.split(rand_key, 3)
1416
k1, k2 = jax.random.split(key)
1517
x = jax.random.uniform(k1, (batch_size, in_channels, height, width), dtype=dtype)
16-
weight = jnp.zeros((out_channels, in_channels, kernel_size, kernel_size), dtype=dtype)
17-
conv_bias = jnp.zeros(out_channels, dtype=dtype)
18-
bias = jnp.zeros((out_channels, 1, 1), dtype=dtype)
18+
weight = jax.random.normal(ka, (out_channels, in_channels, kernel_size, kernel_size), dtype=dtype) * 0.02
19+
conv_bias = jax.random.normal(kb, out_channels, dtype=dtype) * 0.02
20+
bias = jax.random.normal(kc, (out_channels, 1, 1), dtype=dtype) * 0.02
1921

2022
dynamic_args = [x, weight, conv_bias, bias]
2123
static_args = []

MaxKernel/evaluation/jaxbench_adapted_dataset/19k_Matmul_Subtract_Multiply_ReLU/kernel_task.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ input_gen_code: |-
1212
multiply_value = 1.5
1313
1414
key = jax.random.key(0)
15+
rand_key = jax.random.key(0xBADC0DE)
16+
ka, kb = jax.random.split(rand_key, 2)
1517
x = jax.random.uniform(key, (batch_size, in_features), dtype=dtype)
16-
weight = jnp.zeros((in_features, out_features), dtype=dtype)
17-
bias = jnp.zeros(out_features, dtype=dtype)
18+
weight = jax.random.normal(ka, (in_features, out_features), dtype=dtype) * 0.02
19+
bias = jax.random.normal(kb, out_features, dtype=dtype) * 0.02
1820
1921
dynamic_args = [x, weight, bias]
2022
static_args = [subtract_value, multiply_value]

MaxKernel/evaluation/jaxbench_adapted_dataset/19k_Matmul_Subtract_Multiply_ReLU/reference.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ def get_inputs(dtype=jnp.float32):
1111
multiply_value = 1.5
1212

1313
key = jax.random.key(0)
14+
rand_key = jax.random.key(0xBADC0DE)
15+
ka, kb = jax.random.split(rand_key, 2)
1416
x = jax.random.uniform(key, (batch_size, in_features), dtype=dtype)
15-
weight = jnp.zeros((in_features, out_features), dtype=dtype)
16-
bias = jnp.zeros(out_features, dtype=dtype)
17+
weight = jax.random.normal(ka, (in_features, out_features), dtype=dtype) * 0.02
18+
bias = jax.random.normal(kb, out_features, dtype=dtype) * 0.02
1719

1820
dynamic_args = [x, weight, bias]
1921
static_args = [subtract_value, multiply_value]

MaxKernel/evaluation/jaxbench_adapted_dataset/20k_Gemm_Multiply_LeakyReLU/kernel_task.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ input_gen_code: |-
1010
out_features = 8192
1111
1212
key = jax.random.key(0)
13+
rand_key = jax.random.key(0xBADC0DE)
14+
ka, kb = jax.random.split(rand_key, 2)
1315
x = jax.random.uniform(key, (batch_size, in_features), dtype=dtype)
14-
weight = jnp.zeros((in_features, out_features), dtype=dtype)
15-
bias = jnp.zeros(out_features, dtype=dtype)
16+
weight = jax.random.normal(ka, (in_features, out_features), dtype=dtype) * 0.02
17+
bias = jax.random.normal(kb, out_features, dtype=dtype) * 0.02
1618
1719
dynamic_args = [x, weight, bias]
1820
static_args = []

MaxKernel/evaluation/jaxbench_adapted_dataset/20k_Gemm_Multiply_LeakyReLU/reference.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ def get_inputs(dtype=jnp.float32):
99
out_features = 8192
1010

1111
key = jax.random.key(0)
12+
rand_key = jax.random.key(0xBADC0DE)
13+
ka, kb = jax.random.split(rand_key, 2)
1214
x = jax.random.uniform(key, (batch_size, in_features), dtype=dtype)
13-
weight = jnp.zeros((in_features, out_features), dtype=dtype)
14-
bias = jnp.zeros(out_features, dtype=dtype)
15+
weight = jax.random.normal(ka, (in_features, out_features), dtype=dtype) * 0.02
16+
bias = jax.random.normal(kb, out_features, dtype=dtype) * 0.02
1517

1618
dynamic_args = [x, weight, bias]
1719
static_args = []

MaxKernel/evaluation/jaxbench_adapted_dataset/22k_Conv2d_InstanceNorm_Divide/kernel_task.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ input_gen_code: |-
1313
1414
dtype = jnp.float32
1515
key = jax.random.key(0)
16+
rand_key = jax.random.key(0xBADC0DE)
17+
ka, kb = jax.random.split(rand_key, 2)
1618
height = width = 128
1719
x = jax.random.uniform(key, (batch_size, in_channels, height, width), dtype=dtype)
18-
weight = jnp.zeros((out_channels, in_channels, kernel_size, kernel_size), dtype=dtype)
19-
conv_bias = jnp.zeros(out_channels, dtype=dtype)
20+
weight = jax.random.normal(ka, (out_channels, in_channels, kernel_size, kernel_size), dtype=dtype) * 0.02
21+
conv_bias = jax.random.normal(kb, out_channels, dtype=dtype) * 0.02
2022
in_weight = jnp.ones(out_channels, dtype=dtype)
2123
in_bias = jnp.zeros(out_channels, dtype=dtype)
2224

MaxKernel/evaluation/jaxbench_adapted_dataset/22k_Conv2d_InstanceNorm_Divide/reference.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ def get_inputs():
1212

1313
dtype = jnp.float32
1414
key = jax.random.key(0)
15+
rand_key = jax.random.key(0xBADC0DE)
16+
ka, kb = jax.random.split(rand_key, 2)
1517
height = width = 128
1618
x = jax.random.uniform(key, (batch_size, in_channels, height, width), dtype=dtype)
17-
weight = jnp.zeros((out_channels, in_channels, kernel_size, kernel_size), dtype=dtype)
18-
conv_bias = jnp.zeros(out_channels, dtype=dtype)
19+
weight = jax.random.normal(ka, (out_channels, in_channels, kernel_size, kernel_size), dtype=dtype) * 0.02
20+
conv_bias = jax.random.normal(kb, out_channels, dtype=dtype) * 0.02
1921
in_weight = jnp.ones(out_channels, dtype=dtype)
2022
in_bias = jnp.zeros(out_channels, dtype=dtype)
2123

MaxKernel/evaluation/jaxbench_adapted_dataset/23k_Matmul_Sum_Max_AvgPool_LogSumExp_LogSumExp/kernel_task.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ input_gen_code: |-
99
in_features = 8192
1010
out_features = 8192
1111
key = jax.random.key(0)
12+
rand_key = jax.random.key(0xBADC0DE)
13+
ka, kb = jax.random.split(rand_key, 2)
1214
x = jax.random.uniform(key, (batch_size, in_features), dtype=dtype)
13-
weight = jnp.zeros((in_features, out_features), dtype=dtype)
14-
bias = jnp.zeros(out_features, dtype=dtype)
15+
weight = jax.random.normal(ka, (in_features, out_features), dtype=dtype) * 0.02
16+
bias = jax.random.normal(kb, out_features, dtype=dtype) * 0.02
1517
dynamic_args = [x, weight, bias]
1618
static_args = []
1719
return dynamic_args, static_args

0 commit comments

Comments
 (0)