diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d2007880932d26f0658fe0b243c58921cada2fee --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +--- +license: apache-2.0 +task_categories: + - text-generation +language: + - en +tags: + - triton + - cuda + - gpu-kernels + - kernelbench + - rlvr + - post-training +configs: + - config_name: problems + data_files: + - split: train + path: train_problems.jsonl + - config_name: teacher_traces + data_files: + - split: train + path: teacher_traces_v2_clean.jsonl +--- + +# kernel-train-problems + +Training problems and Verifier-v2-verified Triton teacher traces for [`alithekazakh/kernel-pipeline`](https://github.com/alithekazakh/kernel-pipeline). + +## Contents + +- `problems/*.py` & `train_problems.jsonl`: **140** training problems derived from the **KernelBench Level-1** split (`80` base PyTorch ops across `matmul`, `activation`, `normalization`, `reduction_scan`, `pooling`, `convolution`, and `loss_attention` + `60` dtype/shape variants such as `__fp16`, `__bf16`, `__shape_wide`, `__shape_tall`, `__shape_nonpow2`). +- `teacher_traces_v2_clean.jsonl`: **140** clean Triton teacher traces covering all 140 training problems (`80/80` base ops). +- `manifest_train.json`: Train-only problem manifest (`140` train / `0` eval). + +## How Traces Were Generated and Verified + +Every teacher kernel in `teacher_traces_v2_clean.jsonl` was authored cleanly as a `@triton.jit` kernel wrapped in `ModelNew(nn.Module)` (matching the reference PyTorch `Model` signature and parameters) and verified end to end on GPU using **`verifier.py` v2** from [`alithekazakh/kernel-pipeline`](https://github.com/alithekazakh/kernel-pipeline): + +- **Static + runtime genuine-launch check**: wraps `triton.runtime.jit.JITFunction.run` at runtime to verify that candidate-defined Triton kernels actually launch during `ModelNew.forward()` (`0/140` dead-kernel PyTorch fallbacks). +- **Candidate-before-reference trial execution**: eliminates stale output-buffer reuse exploits. +- **Full-device all-stream CUDA synchronization**: prevents asynchronous side-stream timing cheats. +- **140 / 140 traces PASS** under Verifier v2 (`status == "PASS"` and `triton_launched == True`). + +## Held-Out Eval Set Policy (Important) + +The **20-problem held-out evaluation split** (strictly disjoint from these 140 training problems by upstream KernelBench `source_kb_id`) is **deliberately withheld** from this public dataset and from the public GitHub repository so that benchmark measurements stay honest and uncontaminated. + +## Source & License + +- **Upstream source**: [ScalingIntelligence/KernelBench](https://github.com/ScalingIntelligence/KernelBench) (Level-1 problems, MIT license). +- **Dataset & traces license**: Apache-2.0. diff --git a/manifest_train.json b/manifest_train.json new file mode 100644 index 0000000000000000000000000000000000000000..68b479eeb2a9c97a07f173e497ff23b387bce658 --- /dev/null +++ b/manifest_train.json @@ -0,0 +1,1977 @@ +{ + "train": [ + { + "problem_id": "kb1_002_standard_matrix_multiplication", + "source_kb_id": 2, + "source_file": "2_Standard_matrix_multiplication_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_002_standard_matrix_multiplication.py", + "verified": true, + "ref_ms": 1.093632, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_004_matrix_vector_multiplication", + "source_kb_id": 4, + "source_file": "4_Matrix_vector_multiplication_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_004_matrix_vector_multiplication.py", + "verified": true, + "ref_ms": 0.377856, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_005_matrix_scalar_multiplication", + "source_kb_id": 5, + "source_file": "5_Matrix_scalar_multiplication.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_005_matrix_scalar_multiplication.py", + "verified": true, + "ref_ms": 0.751616, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_006_matmul_with_large_k_dimension", + "source_kb_id": 6, + "source_file": "6_Matmul_with_large_K_dimension_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_006_matmul_with_large_k_dimension.py", + "verified": true, + "ref_ms": 1.041408, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_007_matmul_with_small_k_dimension", + "source_kb_id": 7, + "source_file": "7_Matmul_with_small_K_dimension_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_007_matmul_with_small_k_dimension.py", + "verified": true, + "ref_ms": 0.578048, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_008_matmul_with_irregular_shapes", + "source_kb_id": 8, + "source_file": "8_Matmul_with_irregular_shapes_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_008_matmul_with_irregular_shapes.py", + "verified": true, + "ref_ms": 2.94144, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_009_tall_skinny_matrix_multiplication", + "source_kb_id": 9, + "source_file": "9_Tall_skinny_matrix_multiplication_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_009_tall_skinny_matrix_multiplication.py", + "verified": true, + "ref_ms": 2.2016, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_010_3d_tensor_matrix_multiplication", + "source_kb_id": 10, + "source_file": "10_3D_tensor_matrix_multiplication.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_010_3d_tensor_matrix_multiplication.py", + "verified": true, + "ref_ms": 1.820672, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_011_4d_tensor_matrix_multiplication", + "source_kb_id": 11, + "source_file": "11_4D_tensor_matrix_multiplication.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_011_4d_tensor_matrix_multiplication.py", + "verified": true, + "ref_ms": 1.94816, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_012_matmul_with_diagonal_matrices", + "source_kb_id": 12, + "source_file": "12_Matmul_with_diagonal_matrices_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_012_matmul_with_diagonal_matrices.py", + "verified": true, + "ref_ms": 0.191488, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_013_matmul_for_symmetric_matrices", + "source_kb_id": 13, + "source_file": "13_Matmul_for_symmetric_matrices.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_013_matmul_for_symmetric_matrices.py", + "verified": true, + "ref_ms": 0.478208, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_014_matmul_for_upper_triangular_matrices", + "source_kb_id": 14, + "source_file": "14_Matmul_for_upper_triangular_matrices.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_014_matmul_for_upper_triangular_matrices.py", + "verified": true, + "ref_ms": 0.564224, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_015_matmul_for_lower_triangular_matrices", + "source_kb_id": 15, + "source_file": "15_Matmul_for_lower_triangular_matrices.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_015_matmul_for_lower_triangular_matrices.py", + "verified": true, + "ref_ms": 0.51712, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_016_matmul_with_transposed_a", + "source_kb_id": 16, + "source_file": "16_Matmul_with_transposed_A.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_016_matmul_with_transposed_a.py", + "verified": true, + "ref_ms": 0.989696, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_018_matmul_with_transposed_both", + "source_kb_id": 18, + "source_file": "18_Matmul_with_transposed_both.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_018_matmul_with_transposed_both.py", + "verified": true, + "ref_ms": 1.020928, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_020_leakyrelu", + "source_kb_id": 20, + "source_file": "20_LeakyReLU.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_020_leakyrelu.py", + "verified": true, + "ref_ms": 0.379904, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_021_sigmoid", + "source_kb_id": 21, + "source_file": "21_Sigmoid.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_021_sigmoid.py", + "verified": true, + "ref_ms": 0.379904, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_022_tanh", + "source_kb_id": 22, + "source_file": "22_Tanh.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_022_tanh.py", + "verified": true, + "ref_ms": 0.380928, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_024_logsoftmax", + "source_kb_id": 24, + "source_file": "24_LogSoftmax.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_024_logsoftmax.py", + "verified": true, + "ref_ms": 0.384512, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_027_selu", + "source_kb_id": 27, + "source_file": "27_SELU_.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_027_selu.py", + "verified": true, + "ref_ms": 0.37888, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_028_hardsigmoid", + "source_kb_id": 28, + "source_file": "28_HardSigmoid.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_028_hardsigmoid.py", + "verified": true, + "ref_ms": 0.37888, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_029_softplus", + "source_kb_id": 29, + "source_file": "29_Softplus.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_029_softplus.py", + "verified": true, + "ref_ms": 0.380928, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_030_softsign", + "source_kb_id": 30, + "source_file": "30_Softsign.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_030_softsign.py", + "verified": true, + "ref_ms": 1.358336, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_031_elu", + "source_kb_id": 31, + "source_file": "31_ELU.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_031_elu.py", + "verified": true, + "ref_ms": 0.379904, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_032_hardtanh", + "source_kb_id": 32, + "source_file": "32_HardTanh.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_032_hardtanh.py", + "verified": true, + "ref_ms": 0.37888, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_033_batchnorm", + "source_kb_id": 33, + "source_file": "33_BatchNorm.py", + "category": "normalization", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_033_batchnorm.py", + "verified": true, + "ref_ms": 0.857088, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_034_instancenorm", + "source_kb_id": 34, + "source_file": "34_InstanceNorm.py", + "category": "normalization", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_034_instancenorm.py", + "verified": true, + "ref_ms": 1.153536, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_035_groupnorm", + "source_kb_id": 35, + "source_file": "35_GroupNorm_.py", + "category": "normalization", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_035_groupnorm.py", + "verified": true, + "ref_ms": 1.200128, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_037_frobeniusnorm", + "source_kb_id": 37, + "source_file": "37_FrobeniusNorm_.py", + "category": "normalization", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_037_frobeniusnorm.py", + "verified": true, + "ref_ms": 1.112064, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_038_l1norm", + "source_kb_id": 38, + "source_file": "38_L1Norm_.py", + "category": "normalization", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_038_l1norm.py", + "verified": true, + "ref_ms": 0.940544, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_039_l2norm", + "source_kb_id": 39, + "source_file": "39_L2Norm_.py", + "category": "normalization", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_039_l2norm.py", + "verified": true, + "ref_ms": 0.562176, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_041_max_pooling_1d", + "source_kb_id": 41, + "source_file": "41_Max_Pooling_1D.py", + "category": "pooling", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_041_max_pooling_1d.py", + "verified": true, + "ref_ms": 0.907264, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_043_max_pooling_3d", + "source_kb_id": 43, + "source_file": "43_Max_Pooling_3D.py", + "category": "pooling", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_043_max_pooling_3d.py", + "verified": true, + "ref_ms": 0.118784, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_044_average_pooling_1d", + "source_kb_id": 44, + "source_file": "44_Average_Pooling_1D.py", + "category": "pooling", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_044_average_pooling_1d.py", + "verified": true, + "ref_ms": 1.069056, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_045_average_pooling_2d", + "source_kb_id": 45, + "source_file": "45_Average_Pooling_2D.py", + "category": "pooling", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_045_average_pooling_2d.py", + "verified": true, + "ref_ms": 1.50528, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_046_average_pooling_3d", + "source_kb_id": 46, + "source_file": "46_Average_Pooling_3D.py", + "category": "pooling", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_046_average_pooling_3d.py", + "verified": true, + "ref_ms": 0.186368, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_048_mean_reduction_over_a_dimension", + "source_kb_id": 48, + "source_file": "48_Mean_reduction_over_a_dimension.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_048_mean_reduction_over_a_dimension.py", + "verified": true, + "ref_ms": 0.257536, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_049_max_reduction_over_a_dimension", + "source_kb_id": 49, + "source_file": "49_Max_reduction_over_a_dimension.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_049_max_reduction_over_a_dimension.py", + "verified": true, + "ref_ms": 0.19968, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_050_conv_standard_2d_square_input_square_kernel", + "source_kb_id": 50, + "source_file": "50_conv_standard_2D__square_input__square_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_050_conv_standard_2d_square_input_square_kernel.py", + "verified": true, + "ref_ms": 2.393088, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_052_argmin_over_a_dimension", + "source_kb_id": 52, + "source_file": "52_Argmin_over_a_dimension.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_052_argmin_over_a_dimension.py", + "verified": true, + "ref_ms": 0.198656, + "inferred_dtype": "int64", + "self_check_error": null + }, + { + "problem_id": "kb1_053_min_reduction_over_a_dimension", + "source_kb_id": 53, + "source_file": "53_Min_reduction_over_a_dimension.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_053_min_reduction_over_a_dimension.py", + "verified": true, + "ref_ms": 0.19968, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_054_conv_standard_3d_square_input_square_kernel", + "source_kb_id": 54, + "source_file": "54_conv_standard_3D__square_input__square_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_054_conv_standard_3d_square_input_square_kernel.py", + "verified": true, + "ref_ms": 1.803776, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_055_conv_standard_2d_asymmetric_input_square_kernel", + "source_kb_id": 55, + "source_file": "55_conv_standard_2D__asymmetric_input__square_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_055_conv_standard_2d_asymmetric_input_square_kernel.py", + "verified": true, + "ref_ms": 1.113088, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel", + "source_kb_id": 56, + "source_file": "56_conv_standard_2D__asymmetric_input__asymmetric_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel.py", + "verified": true, + "ref_ms": 0.787968, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_057_conv_transposed_2d_square_input_square_kernel", + "source_kb_id": 57, + "source_file": "57_conv_transposed_2D__square_input__square_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_057_conv_transposed_2d_square_input_square_kernel.py", + "verified": true, + "ref_ms": 1.178112, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel", + "source_kb_id": 58, + "source_file": "58_conv_transposed_3D__asymmetric_input__asymmetric_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel.py", + "verified": true, + "ref_ms": 1.644032, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_059_conv_standard_3d_asymmetric_input_square_kernel", + "source_kb_id": 59, + "source_file": "59_conv_standard_3D__asymmetric_input__square_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_059_conv_standard_3d_asymmetric_input_square_kernel.py", + "verified": true, + "ref_ms": 1.915392, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_060_conv_standard_3d_square_input_asymmetric_kernel", + "source_kb_id": 60, + "source_file": "60_conv_standard_3D__square_input__asymmetric_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_060_conv_standard_3d_square_input_asymmetric_kernel.py", + "verified": true, + "ref_ms": 5.71392, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_061_conv_transposed_3d_square_input_square_kernel", + "source_kb_id": 61, + "source_file": "61_conv_transposed_3D__square_input__square_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_061_conv_transposed_3d_square_input_square_kernel.py", + "verified": true, + "ref_ms": 0.308224, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_062_conv_standard_2d_square_input_asymmetric_kernel", + "source_kb_id": 62, + "source_file": "62_conv_standard_2D__square_input__asymmetric_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_062_conv_standard_2d_square_input_asymmetric_kernel.py", + "verified": true, + "ref_ms": 1.921024, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_064_conv_transposed_1d", + "source_kb_id": 64, + "source_file": "64_conv_transposed_1D.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_064_conv_transposed_1d.py", + "verified": true, + "ref_ms": 0.86016, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_065_conv_transposed_2d_square_input_asymmetric_kernel", + "source_kb_id": 65, + "source_file": "65_conv_transposed_2D__square_input__asymmetric_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_065_conv_transposed_2d_square_input_asymmetric_kernel.py", + "verified": true, + "ref_ms": 1.128448, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel", + "source_kb_id": 66, + "source_file": "66_conv_standard_3D__asymmetric_input__asymmetric_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel.py", + "verified": true, + "ref_ms": 5.300736, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_068_conv_transposed_3d_square_input_asymmetric_kernel", + "source_kb_id": 68, + "source_file": "68_conv_transposed_3D__square_input__asymmetric_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_068_conv_transposed_3d_square_input_asymmetric_kernel.py", + "verified": true, + "ref_ms": 1.260544, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel", + "source_kb_id": 69, + "source_file": "69_conv_transposed_2D__asymmetric_input__asymmetric_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel.py", + "verified": true, + "ref_ms": 1.005568, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_070_conv_transposed_3d_asymmetric_input_square_kernel", + "source_kb_id": 70, + "source_file": "70_conv_transposed_3D__asymmetric_input__square_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_070_conv_transposed_3d_asymmetric_input_square_kernel.py", + "verified": true, + "ref_ms": 0.68352, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_071_conv_transposed_2d_asymmetric_input_square_kernel", + "source_kb_id": 71, + "source_file": "71_conv_transposed_2D__asymmetric_input__square_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_071_conv_transposed_2d_asymmetric_input_square_kernel.py", + "verified": true, + "ref_ms": 0.598016, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped", + "source_kb_id": 72, + "source_file": "72_conv_transposed_3D_asymmetric_input_asymmetric_kernel___strided_padded_grouped_.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped.py", + "verified": true, + "ref_ms": 0.585216, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped", + "source_kb_id": 73, + "source_file": "73_conv_transposed_3D_asymmetric_input_square_kernel__strided_padded__grouped.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped.py", + "verified": true, + "ref_ms": 0.840704, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_074_conv_transposed_1d_dilated", + "source_kb_id": 74, + "source_file": "74_conv_transposed_1D_dilated.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_074_conv_transposed_1d_dilated.py", + "verified": true, + "ref_ms": 1.501184, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated", + "source_kb_id": 75, + "source_file": "75_conv_transposed_2D_asymmetric_input_asymmetric_kernel_strided__grouped____padded____dilated__.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated.py", + "verified": true, + "ref_ms": 1.701376, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_076_conv_standard_1d_dilated_strided", + "source_kb_id": 76, + "source_file": "76_conv_standard_1D_dilated_strided__.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_076_conv_standard_1d_dilated_strided.py", + "verified": true, + "ref_ms": 2.090496, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided", + "source_kb_id": 77, + "source_file": "77_conv_transposed_3D_square_input_square_kernel___padded____dilated____strided__.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided.py", + "verified": true, + "ref_ms": 0.278016, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded", + "source_kb_id": 78, + "source_file": "78_conv_transposed_2D_asymmetric_input_asymmetric_kernel___padded__.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded.py", + "verified": true, + "ref_ms": 2.179584, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated", + "source_kb_id": 79, + "source_file": "79_conv_transposed_1D_asymmetric_input_square_kernel___padded____strided____dilated__.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated.py", + "verified": true, + "ref_ms": 3.8016, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded", + "source_kb_id": 80, + "source_file": "80_conv_standard_2D_square_input_asymmetric_kernel___dilated____padded__.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded.py", + "verified": true, + "ref_ms": 1.821184, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided", + "source_kb_id": 81, + "source_file": "81_conv_transposed_2D_asymmetric_input_square_kernel___dilated____padded____strided__.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided.py", + "verified": true, + "ref_ms": 1.419776, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel", + "source_kb_id": 83, + "source_file": "83_conv_depthwise_2D_square_input_asymmetric_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel.py", + "verified": true, + "ref_ms": 1.822208, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel", + "source_kb_id": 84, + "source_file": "84_conv_depthwise_2D_asymmetric_input_square_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel.py", + "verified": true, + "ref_ms": 1.499136, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel", + "source_kb_id": 85, + "source_file": "85_conv_depthwise_2D_asymmetric_input_asymmetric_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel.py", + "verified": true, + "ref_ms": 1.450496, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_086_conv_depthwise_separable_2d", + "source_kb_id": 86, + "source_file": "86_conv_depthwise_separable_2D.py", + "category": "convolution", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_086_conv_depthwise_separable_2d.py", + "verified": true, + "ref_ms": 1.391104, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_088_mingptnewgelu", + "source_kb_id": 88, + "source_file": "88_MinGPTNewGelu.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_088_mingptnewgelu.py", + "verified": true, + "ref_ms": 3.449344, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_090_cumprod", + "source_kb_id": 90, + "source_file": "90_cumprod.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_090_cumprod.py", + "verified": true, + "ref_ms": 0.137728, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_091_cumsum_reverse", + "source_kb_id": 91, + "source_file": "91_cumsum_reverse.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_091_cumsum_reverse.py", + "verified": true, + "ref_ms": 0.649728, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_092_cumsum_exclusive", + "source_kb_id": 92, + "source_file": "92_cumsum_exclusive.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_092_cumsum_exclusive.py", + "verified": true, + "ref_ms": 0.667136, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_093_masked_cumsum", + "source_kb_id": 93, + "source_file": "93_masked_cumsum.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_093_masked_cumsum.py", + "verified": true, + "ref_ms": 0.480256, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_096_huberloss", + "source_kb_id": 96, + "source_file": "96_HuberLoss.py", + "category": "loss_attention", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_096_huberloss.py", + "verified": true, + "ref_ms": 0.836096, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_098_kldivloss", + "source_kb_id": 98, + "source_file": "98_KLDivLoss.py", + "category": "loss_attention", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_098_kldivloss.py", + "verified": true, + "ref_ms": 2.111488, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_099_tripletmarginloss", + "source_kb_id": 99, + "source_file": "99_TripletMarginLoss.py", + "category": "loss_attention", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_099_tripletmarginloss.py", + "verified": true, + "ref_ms": 1.158656, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_100_hingeloss", + "source_kb_id": 100, + "source_file": "100_HingeLoss.py", + "category": "loss_attention", + "split": "train", + "dtype": "fp32", + "variant": "base", + "path": "tasks/train/kb1_100_hingeloss.py", + "verified": true, + "ref_ms": 0.67584, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_002_standard_matrix_multiplication__bf16", + "source_kb_id": 2, + "source_file": "2_Standard_matrix_multiplication_.py", + "category": "matmul", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_002_standard_matrix_multiplication__bf16.py", + "verified": true, + "ref_ms": 0.36864, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_006_matmul_with_large_k_dimension__bf16", + "source_kb_id": 6, + "source_file": "6_Matmul_with_large_K_dimension_.py", + "category": "matmul", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_006_matmul_with_large_k_dimension__bf16.py", + "verified": true, + "ref_ms": 0.37376, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_016_matmul_with_transposed_a__bf16", + "source_kb_id": 16, + "source_file": "16_Matmul_with_transposed_A.py", + "category": "matmul", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_016_matmul_with_transposed_a__bf16.py", + "verified": true, + "ref_ms": 0.374784, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_018_matmul_with_transposed_both__bf16", + "source_kb_id": 18, + "source_file": "18_Matmul_with_transposed_both.py", + "category": "matmul", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_018_matmul_with_transposed_both__bf16.py", + "verified": true, + "ref_ms": 0.375808, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_020_leakyrelu__bf16", + "source_kb_id": 20, + "source_file": "20_LeakyReLU.py", + "category": "activation", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_020_leakyrelu__bf16.py", + "verified": true, + "ref_ms": 0.193536, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_021_sigmoid__bf16", + "source_kb_id": 21, + "source_file": "21_Sigmoid.py", + "category": "activation", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_021_sigmoid__bf16.py", + "verified": true, + "ref_ms": 0.193536, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_024_logsoftmax__bf16", + "source_kb_id": 24, + "source_file": "24_LogSoftmax.py", + "category": "activation", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_024_logsoftmax__bf16.py", + "verified": true, + "ref_ms": 0.317952, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_027_selu__bf16", + "source_kb_id": 27, + "source_file": "27_SELU_.py", + "category": "activation", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_027_selu__bf16.py", + "verified": true, + "ref_ms": 0.193536, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_033_batchnorm__bf16", + "source_kb_id": 33, + "source_file": "33_BatchNorm.py", + "category": "normalization", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_033_batchnorm__bf16.py", + "verified": true, + "ref_ms": 0.416256, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_035_groupnorm__bf16", + "source_kb_id": 35, + "source_file": "35_GroupNorm_.py", + "category": "normalization", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_035_groupnorm__bf16.py", + "verified": true, + "ref_ms": 0.758784, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_039_l2norm__bf16", + "source_kb_id": 39, + "source_file": "39_L2Norm_.py", + "category": "normalization", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_039_l2norm__bf16.py", + "verified": true, + "ref_ms": 0.314368, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_048_mean_reduction_over_a_dimension__bf16", + "source_kb_id": 48, + "source_file": "48_Mean_reduction_over_a_dimension.py", + "category": "reduction_scan", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_048_mean_reduction_over_a_dimension__bf16.py", + "verified": true, + "ref_ms": 0.181248, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16", + "source_kb_id": 55, + "source_file": "55_conv_standard_2D__asymmetric_input__square_kernel.py", + "category": "convolution", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16.py", + "verified": true, + "ref_ms": 0.759808, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_088_mingptnewgelu__bf16", + "source_kb_id": 88, + "source_file": "88_MinGPTNewGelu.py", + "category": "activation", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_088_mingptnewgelu__bf16.py", + "verified": true, + "ref_ms": 1.714176, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_096_huberloss__bf16", + "source_kb_id": 96, + "source_file": "96_HuberLoss.py", + "category": "loss_attention", + "split": "train", + "dtype": "bf16", + "variant": "bf16", + "path": "tasks/train/kb1_096_huberloss__bf16.py", + "verified": true, + "ref_ms": 0.410112, + "inferred_dtype": "bfloat16", + "self_check_error": null + }, + { + "problem_id": "kb1_002_standard_matrix_multiplication__fp16", + "source_kb_id": 2, + "source_file": "2_Standard_matrix_multiplication_.py", + "category": "matmul", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_002_standard_matrix_multiplication__fp16.py", + "verified": true, + "ref_ms": 0.371712, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_005_matrix_scalar_multiplication__fp16", + "source_kb_id": 5, + "source_file": "5_Matrix_scalar_multiplication.py", + "category": "matmul", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_005_matrix_scalar_multiplication__fp16.py", + "verified": true, + "ref_ms": 0.445952, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_008_matmul_with_irregular_shapes__fp16", + "source_kb_id": 8, + "source_file": "8_Matmul_with_irregular_shapes_.py", + "category": "matmul", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_008_matmul_with_irregular_shapes__fp16.py", + "verified": true, + "ref_ms": 1.062912, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_010_3d_tensor_matrix_multiplication__fp16", + "source_kb_id": 10, + "source_file": "10_3D_tensor_matrix_multiplication.py", + "category": "matmul", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_010_3d_tensor_matrix_multiplication__fp16.py", + "verified": true, + "ref_ms": 0.59904, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_022_tanh__fp16", + "source_kb_id": 22, + "source_file": "22_Tanh.py", + "category": "activation", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_022_tanh__fp16.py", + "verified": true, + "ref_ms": 0.193536, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_028_hardsigmoid__fp16", + "source_kb_id": 28, + "source_file": "28_HardSigmoid.py", + "category": "activation", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_028_hardsigmoid__fp16.py", + "verified": true, + "ref_ms": 0.193536, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_029_softplus__fp16", + "source_kb_id": 29, + "source_file": "29_Softplus.py", + "category": "activation", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_029_softplus__fp16.py", + "verified": true, + "ref_ms": 0.193536, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_031_elu__fp16", + "source_kb_id": 31, + "source_file": "31_ELU.py", + "category": "activation", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_031_elu__fp16.py", + "verified": true, + "ref_ms": 0.195584, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_034_instancenorm__fp16", + "source_kb_id": 34, + "source_file": "34_InstanceNorm.py", + "category": "normalization", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_034_instancenorm__fp16.py", + "verified": true, + "ref_ms": 0.803328, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_038_l1norm__fp16", + "source_kb_id": 38, + "source_file": "38_L1Norm_.py", + "category": "normalization", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_038_l1norm__fp16.py", + "verified": true, + "ref_ms": 0.504832, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_049_max_reduction_over_a_dimension__fp16", + "source_kb_id": 49, + "source_file": "49_Max_reduction_over_a_dimension.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_049_max_reduction_over_a_dimension__fp16.py", + "verified": true, + "ref_ms": 0.173056, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_064_conv_transposed_1d__fp16", + "source_kb_id": 64, + "source_file": "64_conv_transposed_1D.py", + "category": "convolution", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_064_conv_transposed_1d__fp16.py", + "verified": true, + "ref_ms": 0.896, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_086_conv_depthwise_separable_2d__fp16", + "source_kb_id": 86, + "source_file": "86_conv_depthwise_separable_2D.py", + "category": "convolution", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_086_conv_depthwise_separable_2d__fp16.py", + "verified": true, + "ref_ms": 0.520192, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_098_kldivloss__fp16", + "source_kb_id": 98, + "source_file": "98_KLDivLoss.py", + "category": "loss_attention", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_098_kldivloss__fp16.py", + "verified": true, + "ref_ms": 1.140736, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_100_hingeloss__fp16", + "source_kb_id": 100, + "source_file": "100_HingeLoss.py", + "category": "loss_attention", + "split": "train", + "dtype": "fp16", + "variant": "fp16", + "path": "tasks/train/kb1_100_hingeloss__fp16.py", + "verified": true, + "ref_ms": 0.36352, + "inferred_dtype": "float16", + "self_check_error": null + }, + { + "problem_id": "kb1_002_standard_matrix_multiplication__shape_nonpow2", + "source_kb_id": 2, + "source_file": "2_Standard_matrix_multiplication_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_002_standard_matrix_multiplication__shape_nonpow2.py", + "verified": true, + "ref_ms": 0.64512, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_004_matrix_vector_multiplication__shape_wide", + "source_kb_id": 4, + "source_file": "4_Matrix_vector_multiplication_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "shape_wide", + "path": "tasks/train/kb1_004_matrix_vector_multiplication__shape_wide.py", + "verified": true, + "ref_ms": 0.380416, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_005_matrix_scalar_multiplication__shape_nonpow2", + "source_kb_id": 5, + "source_file": "5_Matrix_scalar_multiplication.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_005_matrix_scalar_multiplication__shape_nonpow2.py", + "verified": true, + "ref_ms": 0.339968, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_006_matmul_with_large_k_dimension__shape_tall", + "source_kb_id": 6, + "source_file": "6_Matmul_with_large_K_dimension_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "shape_tall", + "path": "tasks/train/kb1_006_matmul_with_large_k_dimension__shape_tall.py", + "verified": true, + "ref_ms": 0.690176, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_007_matmul_with_small_k_dimension__shape_rect", + "source_kb_id": 7, + "source_file": "7_Matmul_with_small_K_dimension_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "shape_rect", + "path": "tasks/train/kb1_007_matmul_with_small_k_dimension__shape_rect.py", + "verified": true, + "ref_ms": 0.216064, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_009_tall_skinny_matrix_multiplication__shape_skinny", + "source_kb_id": 9, + "source_file": "9_Tall_skinny_matrix_multiplication_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "shape_skinny", + "path": "tasks/train/kb1_009_tall_skinny_matrix_multiplication__shape_skinny.py", + "verified": true, + "ref_ms": 0.47616, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_010_3d_tensor_matrix_multiplication__shape_large_batch", + "source_kb_id": 10, + "source_file": "10_3D_tensor_matrix_multiplication.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "shape_large_batch", + "path": "tasks/train/kb1_010_3d_tensor_matrix_multiplication__shape_large_batch.py", + "verified": true, + "ref_ms": 1.43616, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_012_matmul_with_diagonal_matrices__shape_rect", + "source_kb_id": 12, + "source_file": "12_Matmul_with_diagonal_matrices_.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "shape_rect", + "path": "tasks/train/kb1_012_matmul_with_diagonal_matrices__shape_rect.py", + "verified": true, + "ref_ms": 0.21504, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_013_matmul_for_symmetric_matrices__shape_small", + "source_kb_id": 13, + "source_file": "13_Matmul_for_symmetric_matrices.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "shape_small", + "path": "tasks/train/kb1_013_matmul_for_symmetric_matrices__shape_small.py", + "verified": true, + "ref_ms": 0.233472, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_016_matmul_with_transposed_a__shape_nonpow2", + "source_kb_id": 16, + "source_file": "16_Matmul_with_transposed_A.py", + "category": "matmul", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_016_matmul_with_transposed_a__shape_nonpow2.py", + "verified": true, + "ref_ms": 0.55808, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_020_leakyrelu__shape_wide", + "source_kb_id": 20, + "source_file": "20_LeakyReLU.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "shape_wide", + "path": "tasks/train/kb1_020_leakyrelu__shape_wide.py", + "verified": true, + "ref_ms": 0.33024, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_021_sigmoid__shape_nonpow2", + "source_kb_id": 21, + "source_file": "21_Sigmoid.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_021_sigmoid__shape_nonpow2.py", + "verified": true, + "ref_ms": 0.222208, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_022_tanh__shape_tall", + "source_kb_id": 22, + "source_file": "22_Tanh.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "shape_tall", + "path": "tasks/train/kb1_022_tanh__shape_tall.py", + "verified": true, + "ref_ms": 0.379904, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_024_logsoftmax__shape_vocab", + "source_kb_id": 24, + "source_file": "24_LogSoftmax.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "shape_vocab", + "path": "tasks/train/kb1_024_logsoftmax__shape_vocab.py", + "verified": true, + "ref_ms": 0.45312, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_027_selu__shape_nonpow2", + "source_kb_id": 27, + "source_file": "27_SELU_.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_027_selu__shape_nonpow2.py", + "verified": true, + "ref_ms": 0.287744, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_029_softplus__shape_wide", + "source_kb_id": 29, + "source_file": "29_Softplus.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "shape_wide", + "path": "tasks/train/kb1_029_softplus__shape_wide.py", + "verified": true, + "ref_ms": 0.380416, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_030_softsign__shape_nonpow2", + "source_kb_id": 30, + "source_file": "30_Softsign.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_030_softsign__shape_nonpow2.py", + "verified": true, + "ref_ms": 0.942592, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_031_elu__shape_tall", + "source_kb_id": 31, + "source_file": "31_ELU.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "shape_tall", + "path": "tasks/train/kb1_031_elu__shape_tall.py", + "verified": true, + "ref_ms": 0.380928, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_032_hardtanh__shape_nonpow2", + "source_kb_id": 32, + "source_file": "32_HardTanh.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_032_hardtanh__shape_nonpow2.py", + "verified": true, + "ref_ms": 0.34816, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_033_batchnorm__shape_spatial", + "source_kb_id": 33, + "source_file": "33_BatchNorm.py", + "category": "normalization", + "split": "train", + "dtype": "fp32", + "variant": "shape_spatial", + "path": "tasks/train/kb1_033_batchnorm__shape_spatial.py", + "verified": true, + "ref_ms": 0.196608, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_035_groupnorm__shape_groups16", + "source_kb_id": 35, + "source_file": "35_GroupNorm_.py", + "category": "normalization", + "split": "train", + "dtype": "fp32", + "variant": "shape_groups16", + "path": "tasks/train/kb1_035_groupnorm__shape_groups16.py", + "verified": true, + "ref_ms": 0.325632, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_038_l1norm__shape_nonpow2", + "source_kb_id": 38, + "source_file": "38_L1Norm_.py", + "category": "normalization", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_038_l1norm__shape_nonpow2.py", + "verified": true, + "ref_ms": 0.878592, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_039_l2norm__shape_wide", + "source_kb_id": 39, + "source_file": "39_L2Norm_.py", + "category": "normalization", + "split": "train", + "dtype": "fp32", + "variant": "shape_wide", + "path": "tasks/train/kb1_039_l2norm__shape_wide.py", + "verified": true, + "ref_ms": 0.561152, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_048_mean_reduction_over_a_dimension__shape_large_reduce", + "source_kb_id": 48, + "source_file": "48_Mean_reduction_over_a_dimension.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "shape_large_reduce", + "path": "tasks/train/kb1_048_mean_reduction_over_a_dimension__shape_large_reduce.py", + "verified": true, + "ref_ms": 0.377344, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_049_max_reduction_over_a_dimension__shape_large_reduce", + "source_kb_id": 49, + "source_file": "49_Max_reduction_over_a_dimension.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "shape_large_reduce", + "path": "tasks/train/kb1_049_max_reduction_over_a_dimension__shape_large_reduce.py", + "verified": true, + "ref_ms": 0.385024, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_053_min_reduction_over_a_dimension__shape_nonpow2", + "source_kb_id": 53, + "source_file": "53_Min_reduction_over_a_dimension.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_053_min_reduction_over_a_dimension__shape_nonpow2.py", + "verified": true, + "ref_ms": 0.329728, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_088_mingptnewgelu__shape_nonpow2", + "source_kb_id": 88, + "source_file": "88_MinGPTNewGelu.py", + "category": "activation", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_088_mingptnewgelu__shape_nonpow2.py", + "verified": true, + "ref_ms": 3.167232, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_091_cumsum_reverse__shape_wide", + "source_kb_id": 91, + "source_file": "91_cumsum_reverse.py", + "category": "reduction_scan", + "split": "train", + "dtype": "fp32", + "variant": "shape_wide", + "path": "tasks/train/kb1_091_cumsum_reverse__shape_wide.py", + "verified": true, + "ref_ms": 0.652288, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_096_huberloss__shape_nonpow2", + "source_kb_id": 96, + "source_file": "96_HuberLoss.py", + "category": "loss_attention", + "split": "train", + "dtype": "fp32", + "variant": "shape_nonpow2", + "path": "tasks/train/kb1_096_huberloss__shape_nonpow2.py", + "verified": true, + "ref_ms": 0.416768, + "inferred_dtype": "float32", + "self_check_error": null + }, + { + "problem_id": "kb1_099_tripletmarginloss__shape_wide", + "source_kb_id": 99, + "source_file": "99_TripletMarginLoss.py", + "category": "loss_attention", + "split": "train", + "dtype": "fp32", + "variant": "shape_wide", + "path": "tasks/train/kb1_099_tripletmarginloss__shape_wide.py", + "verified": true, + "ref_ms": 1.169408, + "inferred_dtype": "float32", + "self_check_error": null + } + ], + "eval": [], + "summary": { + "train_count": 140, + "train_base_count": 80, + "train_variant_count": 60, + "eval_count": 0, + "total_count": 140, + "note": "Held-out 20-problem eval split is deliberately withheld from the public repository." + }, + "verification": { + "train_passed": 140, + "train_failed": 0 + } +} diff --git a/problems/kb1_002_standard_matrix_multiplication.py b/problems/kb1_002_standard_matrix_multiplication.py new file mode 100644 index 0000000000000000000000000000000000000000..d87ca7340434c91a18244858fb565593dc476fb3 --- /dev/null +++ b/problems/kb1_002_standard_matrix_multiplication.py @@ -0,0 +1,55 @@ +"""Task kb1_002_standard_matrix_multiplication (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_002_standard_matrix_multiplication" +SOURCE_KB_ID = 2 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A, B) + +M = 1024 * 2 +K = 4096 * 2 +N = 2048 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 2048 +N = 1024 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_002_standard_matrix_multiplication__bf16.py b/problems/kb1_002_standard_matrix_multiplication__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..7355990ff1629c9d681fedccc1cc5b06f2cb062e --- /dev/null +++ b/problems/kb1_002_standard_matrix_multiplication__bf16.py @@ -0,0 +1,55 @@ +"""Task kb1_002_standard_matrix_multiplication__bf16 (KernelBench Level 1 #2, split=train, category=matmul, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_002_standard_matrix_multiplication__bf16" +SOURCE_KB_ID = 2 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A, B) + +M = 1024 * 2 +K = 4096 * 2 +N = 2048 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 2048 +N = 1024 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_002_standard_matrix_multiplication__fp16.py b/problems/kb1_002_standard_matrix_multiplication__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..742452d15e8bac8b8889e7de2daa4ecf3ccf5f96 --- /dev/null +++ b/problems/kb1_002_standard_matrix_multiplication__fp16.py @@ -0,0 +1,55 @@ +"""Task kb1_002_standard_matrix_multiplication__fp16 (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_002_standard_matrix_multiplication__fp16" +SOURCE_KB_ID = 2 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A, B) + +M = 1024 * 2 +K = 4096 * 2 +N = 2048 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 2048 +N = 1024 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_002_standard_matrix_multiplication__shape_nonpow2.py b/problems/kb1_002_standard_matrix_multiplication__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..e8a1cf64c8f5819a6faee1f02680c73163fe109f --- /dev/null +++ b/problems/kb1_002_standard_matrix_multiplication__shape_nonpow2.py @@ -0,0 +1,58 @@ +"""Task kb1_002_standard_matrix_multiplication__shape_nonpow2 (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_002_standard_matrix_multiplication__shape_nonpow2" +SOURCE_KB_ID = 2 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A, B) + +M = 1024 * 2 +K = 4096 * 2 +N = 2048 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 2048 +N = 1024 +M = 768 +K = 1536 +N = 1280 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_004_matrix_vector_multiplication.py b/problems/kb1_004_matrix_vector_multiplication.py new file mode 100644 index 0000000000000000000000000000000000000000..88adfc63a2a8a81e21a7106da861bb1d03e6a964 --- /dev/null +++ b/problems/kb1_004_matrix_vector_multiplication.py @@ -0,0 +1,53 @@ +"""Task kb1_004_matrix_vector_multiplication (KernelBench Level 1 #4, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_004_matrix_vector_multiplication" +SOURCE_KB_ID = 4 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs matrix-vector multiplication (C = A * B). + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix-vector multiplication. + + Args: + A: Input matrix of shape (M, K). + B: Input vector of shape (K, 1). + + Returns: + Output vector of shape (M, 1). + """ + return torch.matmul(A, B) + +M = 256 * 8 # 2048 +K = 131072 * 8 # 1048576 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 16384 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, 1) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_004_matrix_vector_multiplication__shape_wide.py b/problems/kb1_004_matrix_vector_multiplication__shape_wide.py new file mode 100644 index 0000000000000000000000000000000000000000..1a03e6f79d0b108f84fd496d69226ef4e0eca9d7 --- /dev/null +++ b/problems/kb1_004_matrix_vector_multiplication__shape_wide.py @@ -0,0 +1,55 @@ +"""Task kb1_004_matrix_vector_multiplication__shape_wide (KernelBench Level 1 #4, split=train, category=matmul, dtype=fp32, variant=shape_wide).""" +PROBLEM_ID = "kb1_004_matrix_vector_multiplication__shape_wide" +SOURCE_KB_ID = 4 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_wide" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs matrix-vector multiplication (C = A * B). + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix-vector multiplication. + + Args: + A: Input matrix of shape (M, K). + B: Input vector of shape (K, 1). + + Returns: + Output vector of shape (M, 1). + """ + return torch.matmul(A, B) + +M = 256 * 8 # 2048 +K = 131072 * 8 # 1048576 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 16384 +M = 512 +K = 32768 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, 1) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_005_matrix_scalar_multiplication.py b/problems/kb1_005_matrix_scalar_multiplication.py new file mode 100644 index 0000000000000000000000000000000000000000..2ce2ee732c8e1c9311c3961faebcb9321b1303cc --- /dev/null +++ b/problems/kb1_005_matrix_scalar_multiplication.py @@ -0,0 +1,53 @@ +"""Task kb1_005_matrix_scalar_multiplication (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_005_matrix_scalar_multiplication" +SOURCE_KB_ID = 5 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a matrix-scalar multiplication (C = A * s) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, s: float) -> torch.Tensor: + """ + Performs matrix-scalar multiplication. + + Args: + A: Input matrix of shape (M, N) + s: Scalar value + + Returns: + C: Resulting matrix of shape (M, N) + """ + return A * s + +M = 16384 * 4 +N = 4096 * 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 4096 +N = 4096 + +def get_inputs(): + A = torch.rand(M, N) + s = 3.14 + return [A, s] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_005_matrix_scalar_multiplication__fp16.py b/problems/kb1_005_matrix_scalar_multiplication__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..47c6bdc6ab9d3030f9d7748475a6dc2336876795 --- /dev/null +++ b/problems/kb1_005_matrix_scalar_multiplication__fp16.py @@ -0,0 +1,53 @@ +"""Task kb1_005_matrix_scalar_multiplication__fp16 (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_005_matrix_scalar_multiplication__fp16" +SOURCE_KB_ID = 5 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a matrix-scalar multiplication (C = A * s) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, s: float) -> torch.Tensor: + """ + Performs matrix-scalar multiplication. + + Args: + A: Input matrix of shape (M, N) + s: Scalar value + + Returns: + C: Resulting matrix of shape (M, N) + """ + return A * s + +M = 16384 * 4 +N = 4096 * 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 4096 +N = 4096 + +def get_inputs(): + A = torch.rand(M, N) + s = 3.14 + return [A, s] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_005_matrix_scalar_multiplication__shape_nonpow2.py b/problems/kb1_005_matrix_scalar_multiplication__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..4706c5b1c60050ce1b09a6dc62f548e3e25fe86a --- /dev/null +++ b/problems/kb1_005_matrix_scalar_multiplication__shape_nonpow2.py @@ -0,0 +1,55 @@ +"""Task kb1_005_matrix_scalar_multiplication__shape_nonpow2 (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_005_matrix_scalar_multiplication__shape_nonpow2" +SOURCE_KB_ID = 5 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a matrix-scalar multiplication (C = A * s) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, s: float) -> torch.Tensor: + """ + Performs matrix-scalar multiplication. + + Args: + A: Input matrix of shape (M, N) + s: Scalar value + + Returns: + C: Resulting matrix of shape (M, N) + """ + return A * s + +M = 16384 * 4 +N = 4096 * 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 4096 +N = 4096 +M = 3000 +N = 2500 + +def get_inputs(): + A = torch.rand(M, N) + s = 3.14 + return [A, s] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_006_matmul_with_large_k_dimension.py b/problems/kb1_006_matmul_with_large_k_dimension.py new file mode 100644 index 0000000000000000000000000000000000000000..b8de6e67ad2f19a1416b1fc5c77982bba4c0ae4c --- /dev/null +++ b/problems/kb1_006_matmul_with_large_k_dimension.py @@ -0,0 +1,55 @@ +"""Task kb1_006_matmul_with_large_k_dimension (KernelBench Level 1 #6, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_006_matmul_with_large_k_dimension" +SOURCE_KB_ID = 6 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication of A and B. + + Args: + A: Input tensor of shape (M, K) + B: Input tensor of shape (K, N) + + Returns: + Output tensor of shape (M, N) + """ + return torch.matmul(A, B) + +M = 256 +N = 256 +K = 131072 * 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 256 +N = 256 +K = 32768 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_006_matmul_with_large_k_dimension__bf16.py b/problems/kb1_006_matmul_with_large_k_dimension__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..1bd94527298ab714dd5c3ed51e9616e29fdd9349 --- /dev/null +++ b/problems/kb1_006_matmul_with_large_k_dimension__bf16.py @@ -0,0 +1,55 @@ +"""Task kb1_006_matmul_with_large_k_dimension__bf16 (KernelBench Level 1 #6, split=train, category=matmul, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_006_matmul_with_large_k_dimension__bf16" +SOURCE_KB_ID = 6 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication of A and B. + + Args: + A: Input tensor of shape (M, K) + B: Input tensor of shape (K, N) + + Returns: + Output tensor of shape (M, N) + """ + return torch.matmul(A, B) + +M = 256 +N = 256 +K = 131072 * 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 256 +N = 256 +K = 32768 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_006_matmul_with_large_k_dimension__shape_tall.py b/problems/kb1_006_matmul_with_large_k_dimension__shape_tall.py new file mode 100644 index 0000000000000000000000000000000000000000..3717753db8fefa90f65d669986c899d9d63e3529 --- /dev/null +++ b/problems/kb1_006_matmul_with_large_k_dimension__shape_tall.py @@ -0,0 +1,58 @@ +"""Task kb1_006_matmul_with_large_k_dimension__shape_tall (KernelBench Level 1 #6, split=train, category=matmul, dtype=fp32, variant=shape_tall).""" +PROBLEM_ID = "kb1_006_matmul_with_large_k_dimension__shape_tall" +SOURCE_KB_ID = 6 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_tall" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication of A and B. + + Args: + A: Input tensor of shape (M, K) + B: Input tensor of shape (K, N) + + Returns: + Output tensor of shape (M, N) + """ + return torch.matmul(A, B) + +M = 256 +N = 256 +K = 131072 * 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 256 +N = 256 +K = 32768 +M = 512 +N = 128 +K = 16384 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_007_matmul_with_small_k_dimension.py b/problems/kb1_007_matmul_with_small_k_dimension.py new file mode 100644 index 0000000000000000000000000000000000000000..f451a46c805080f6f3e15f67ff829d135bf85047 --- /dev/null +++ b/problems/kb1_007_matmul_with_small_k_dimension.py @@ -0,0 +1,55 @@ +"""Task kb1_007_matmul_with_small_k_dimension (KernelBench Level 1 #7, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_007_matmul_with_small_k_dimension" +SOURCE_KB_ID = 7 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) with a small K dimension + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A, B) + +M = 16384 * 2 +N = 16384 * 2 +K = 32 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 4096 +N = 4096 +K = 64 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_007_matmul_with_small_k_dimension__shape_rect.py b/problems/kb1_007_matmul_with_small_k_dimension__shape_rect.py new file mode 100644 index 0000000000000000000000000000000000000000..ec125ccc6779a278e09e22966cc1c5c1d0653de9 --- /dev/null +++ b/problems/kb1_007_matmul_with_small_k_dimension__shape_rect.py @@ -0,0 +1,58 @@ +"""Task kb1_007_matmul_with_small_k_dimension__shape_rect (KernelBench Level 1 #7, split=train, category=matmul, dtype=fp32, variant=shape_rect).""" +PROBLEM_ID = "kb1_007_matmul_with_small_k_dimension__shape_rect" +SOURCE_KB_ID = 7 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_rect" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) with a small K dimension + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A, B) + +M = 16384 * 2 +N = 16384 * 2 +K = 32 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 4096 +N = 4096 +K = 64 +M = 2048 +N = 3072 +K = 48 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_008_matmul_with_irregular_shapes.py b/problems/kb1_008_matmul_with_irregular_shapes.py new file mode 100644 index 0000000000000000000000000000000000000000..10e80b9df91f296842724baa507ab394ab109e75 --- /dev/null +++ b/problems/kb1_008_matmul_with_irregular_shapes.py @@ -0,0 +1,55 @@ +"""Task kb1_008_matmul_with_irregular_shapes (KernelBench Level 1 #8, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_008_matmul_with_irregular_shapes" +SOURCE_KB_ID = 8 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) with irregular shapes + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication of A and B. + + Args: + A: Input tensor with shape (M, K). + B: Input tensor with shape (K, N). + + Returns: + C: Output tensor with shape (M, N). + """ + return torch.matmul(A, B) + +M = 8205 +K = 2949 +N = 5921 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 2051 +K = 1473 +N = 1973 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_008_matmul_with_irregular_shapes__fp16.py b/problems/kb1_008_matmul_with_irregular_shapes__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..c1f448f1eba5160144e608dbbe35c038a24039f2 --- /dev/null +++ b/problems/kb1_008_matmul_with_irregular_shapes__fp16.py @@ -0,0 +1,55 @@ +"""Task kb1_008_matmul_with_irregular_shapes__fp16 (KernelBench Level 1 #8, split=train, category=matmul, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_008_matmul_with_irregular_shapes__fp16" +SOURCE_KB_ID = 8 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) with irregular shapes + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication of A and B. + + Args: + A: Input tensor with shape (M, K). + B: Input tensor with shape (K, N). + + Returns: + C: Output tensor with shape (M, N). + """ + return torch.matmul(A, B) + +M = 8205 +K = 2949 +N = 5921 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 2051 +K = 1473 +N = 1973 + +def get_inputs(): + A = torch.rand(M, K) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_009_tall_skinny_matrix_multiplication.py b/problems/kb1_009_tall_skinny_matrix_multiplication.py new file mode 100644 index 0000000000000000000000000000000000000000..c1b6afa400382377c82e6f8573bf00fcc91566ea --- /dev/null +++ b/problems/kb1_009_tall_skinny_matrix_multiplication.py @@ -0,0 +1,53 @@ +"""Task kb1_009_tall_skinny_matrix_multiplication (KernelBench Level 1 #9, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_009_tall_skinny_matrix_multiplication" +SOURCE_KB_ID = 9 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) where one of the matrices is tall and skinny (M >> N or N >> M) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs the matrix multiplication. + + Args: + A (torch.Tensor): Input matrix of shape (M, K) or (K, M) where M >> N or N >> M. + B (torch.Tensor): Input matrix of shape (K, N) or (N, K) where M >> N or N >> M. + + Returns: + torch.Tensor: Output matrix of shape (M, N) or (N, M) + """ + return torch.matmul(A, B) + +M = 16384 * 2 +N = 16 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 8192 +N = 64 + +def get_inputs(): + A = torch.rand(M, N) + B = torch.rand(N, M) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_009_tall_skinny_matrix_multiplication__shape_skinny.py b/problems/kb1_009_tall_skinny_matrix_multiplication__shape_skinny.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b040c11771adb4b96fcfee90856590c31a5e69 --- /dev/null +++ b/problems/kb1_009_tall_skinny_matrix_multiplication__shape_skinny.py @@ -0,0 +1,55 @@ +"""Task kb1_009_tall_skinny_matrix_multiplication__shape_skinny (KernelBench Level 1 #9, split=train, category=matmul, dtype=fp32, variant=shape_skinny).""" +PROBLEM_ID = "kb1_009_tall_skinny_matrix_multiplication__shape_skinny" +SOURCE_KB_ID = 9 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_skinny" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) where one of the matrices is tall and skinny (M >> N or N >> M) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs the matrix multiplication. + + Args: + A (torch.Tensor): Input matrix of shape (M, K) or (K, M) where M >> N or N >> M. + B (torch.Tensor): Input matrix of shape (K, N) or (N, K) where M >> N or N >> M. + + Returns: + torch.Tensor: Output matrix of shape (M, N) or (N, M) + """ + return torch.matmul(A, B) + +M = 16384 * 2 +N = 16 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 8192 +N = 64 +M = 4096 +N = 32 + +def get_inputs(): + A = torch.rand(M, N) + B = torch.rand(N, M) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_010_3d_tensor_matrix_multiplication.py b/problems/kb1_010_3d_tensor_matrix_multiplication.py new file mode 100644 index 0000000000000000000000000000000000000000..3f1f39f579c2f3ce97a12fbcb16fe35218af14d0 --- /dev/null +++ b/problems/kb1_010_3d_tensor_matrix_multiplication.py @@ -0,0 +1,57 @@ +"""Task kb1_010_3d_tensor_matrix_multiplication (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_010_3d_tensor_matrix_multiplication" +SOURCE_KB_ID = 10 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs 3D tensor-matrix multiplication. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs 3D tensor-matrix multiplication. + + Args: + A (torch.Tensor): Input 3D tensor of shape (N, M, K). + B (torch.Tensor): Input matrix of shape (K, L). + + Returns: + torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A. + """ + return torch.matmul(A, B) + +N = 16 +M = 1024 +K = 2048 +L = 768 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +N = 16 +M = 512 +K = 1024 +L = 512 + +def get_inputs(): + A = torch.rand(N, M, K) + B = torch.rand(K, L) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_010_3d_tensor_matrix_multiplication__fp16.py b/problems/kb1_010_3d_tensor_matrix_multiplication__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..45baf6eb51dd65971af2605b5d975a21af8bcc22 --- /dev/null +++ b/problems/kb1_010_3d_tensor_matrix_multiplication__fp16.py @@ -0,0 +1,57 @@ +"""Task kb1_010_3d_tensor_matrix_multiplication__fp16 (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_010_3d_tensor_matrix_multiplication__fp16" +SOURCE_KB_ID = 10 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs 3D tensor-matrix multiplication. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs 3D tensor-matrix multiplication. + + Args: + A (torch.Tensor): Input 3D tensor of shape (N, M, K). + B (torch.Tensor): Input matrix of shape (K, L). + + Returns: + torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A. + """ + return torch.matmul(A, B) + +N = 16 +M = 1024 +K = 2048 +L = 768 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +N = 16 +M = 512 +K = 1024 +L = 512 + +def get_inputs(): + A = torch.rand(N, M, K) + B = torch.rand(K, L) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_010_3d_tensor_matrix_multiplication__shape_large_batch.py b/problems/kb1_010_3d_tensor_matrix_multiplication__shape_large_batch.py new file mode 100644 index 0000000000000000000000000000000000000000..1899455141d12dae84681081b5360b9eefd908e9 --- /dev/null +++ b/problems/kb1_010_3d_tensor_matrix_multiplication__shape_large_batch.py @@ -0,0 +1,61 @@ +"""Task kb1_010_3d_tensor_matrix_multiplication__shape_large_batch (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp32, variant=shape_large_batch).""" +PROBLEM_ID = "kb1_010_3d_tensor_matrix_multiplication__shape_large_batch" +SOURCE_KB_ID = 10 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_large_batch" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs 3D tensor-matrix multiplication. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs 3D tensor-matrix multiplication. + + Args: + A (torch.Tensor): Input 3D tensor of shape (N, M, K). + B (torch.Tensor): Input matrix of shape (K, L). + + Returns: + torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A. + """ + return torch.matmul(A, B) + +N = 16 +M = 1024 +K = 2048 +L = 768 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +N = 16 +M = 512 +K = 1024 +L = 512 +N = 32 +M = 256 +K = 512 +L = 768 + +def get_inputs(): + A = torch.rand(N, M, K) + B = torch.rand(K, L) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_011_4d_tensor_matrix_multiplication.py b/problems/kb1_011_4d_tensor_matrix_multiplication.py new file mode 100644 index 0000000000000000000000000000000000000000..14bb0adf753589ba30de3e8848d6e5aa1b20283b --- /dev/null +++ b/problems/kb1_011_4d_tensor_matrix_multiplication.py @@ -0,0 +1,68 @@ +"""Task kb1_011_4d_tensor_matrix_multiplication (KernelBench Level 1 #11, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_011_4d_tensor_matrix_multiplication" +SOURCE_KB_ID = 11 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs 4D tensor-matrix multiplication: + C[b, i, j, k] = sum_l A[b, i, j, l] * B[l, k] + + Args: + A (torch.Tensor): Input 4D tensor of shape (b, i, j, l) + B (torch.Tensor): Input matrix of shape (l, k) + + Returns: + torch.Tensor: Output 4D tensor of shape (b, i, j, k) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs the 4D tensor-matrix multiplication. + + Args: + A (torch.Tensor): Input 4D tensor of shape (b, i, j, l) + B (torch.Tensor): Input matrix of shape (l, k) + + Returns: + torch.Tensor: Output 4D tensor of shape (b, i, j, k) + """ + return torch.einsum("bijl,lk->bijk", A, B) + +# Test code +b = 8 +i = 256 +j = 512 +l = 256 +k = 768 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +b = 4 +i = 128 +j = 256 +l = 128 +k = 256 + +def get_inputs(): + A = torch.rand(b, i, j, l) + B = torch.rand(l, k) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_012_matmul_with_diagonal_matrices.py b/problems/kb1_012_matmul_with_diagonal_matrices.py new file mode 100644 index 0000000000000000000000000000000000000000..8157df65158fa2cf03dbf3fa13b66f57aa3387cb --- /dev/null +++ b/problems/kb1_012_matmul_with_diagonal_matrices.py @@ -0,0 +1,56 @@ +"""Task kb1_012_matmul_with_diagonal_matrices (KernelBench Level 1 #12, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_012_matmul_with_diagonal_matrices" +SOURCE_KB_ID = 12 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a matrix multiplication of a diagonal matrix with another matrix. + C = diag(A) * B + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs the matrix multiplication. + + Args: + A (torch.Tensor): A 1D tensor representing the diagonal of the diagonal matrix. Shape: (N,). + B (torch.Tensor): A 2D tensor representing the second matrix. Shape: (N, M). + + Returns: + torch.Tensor: The result of the matrix multiplication. Shape: (N, M). + """ + # Logically equivalent to torch.diag(A) @ B + # more efficient as no need to materialize a full N×N matrix + return A.unsqueeze(1) * B + +M = 4096 +N = 4096 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 2048 +N = 2048 + +def get_inputs(): + A = torch.rand(N) + B = torch.rand(N, M) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_012_matmul_with_diagonal_matrices__shape_rect.py b/problems/kb1_012_matmul_with_diagonal_matrices__shape_rect.py new file mode 100644 index 0000000000000000000000000000000000000000..c377a70f41d924acd97b322bfb499ff67f606038 --- /dev/null +++ b/problems/kb1_012_matmul_with_diagonal_matrices__shape_rect.py @@ -0,0 +1,58 @@ +"""Task kb1_012_matmul_with_diagonal_matrices__shape_rect (KernelBench Level 1 #12, split=train, category=matmul, dtype=fp32, variant=shape_rect).""" +PROBLEM_ID = "kb1_012_matmul_with_diagonal_matrices__shape_rect" +SOURCE_KB_ID = 12 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_rect" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a matrix multiplication of a diagonal matrix with another matrix. + C = diag(A) * B + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs the matrix multiplication. + + Args: + A (torch.Tensor): A 1D tensor representing the diagonal of the diagonal matrix. Shape: (N,). + B (torch.Tensor): A 2D tensor representing the second matrix. Shape: (N, M). + + Returns: + torch.Tensor: The result of the matrix multiplication. Shape: (N, M). + """ + # Logically equivalent to torch.diag(A) @ B + # more efficient as no need to materialize a full N×N matrix + return A.unsqueeze(1) * B + +M = 4096 +N = 4096 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 2048 +N = 2048 +M = 1536 +N = 3072 + +def get_inputs(): + A = torch.rand(N) + B = torch.rand(N, M) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_013_matmul_for_symmetric_matrices.py b/problems/kb1_013_matmul_for_symmetric_matrices.py new file mode 100644 index 0000000000000000000000000000000000000000..af61f7c4b8a04da40c90e68766f87e18f6370b49 --- /dev/null +++ b/problems/kb1_013_matmul_for_symmetric_matrices.py @@ -0,0 +1,65 @@ +"""Task kb1_013_matmul_for_symmetric_matrices (KernelBench Level 1 #13, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_013_matmul_for_symmetric_matrices" +SOURCE_KB_ID = 13 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) with A and B being symmetric matrices. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs matrix multiplication of two symmetric matrices. + + Args: + A (torch.Tensor): Input matrix A, shape (N, N), symmetric. + B (torch.Tensor): Input matrix B, shape (N, N), symmetric. + + Returns: + torch.Tensor: Output matrix C, shape (N, N). + """ + return torch.matmul(A, B) + +N = 4096 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +N = 1024 + +def get_inputs(): + """ + Generates a pair of random symmetric matrices for testing. + + Returns: + list: List containing two symmetric tensors A and B. + """ + A = torch.rand(N, N) + A = (A + A.T) / 2 # Ensure symmetry + B = torch.rand(N, N) + B = (B + B.T) / 2 # Ensure symmetry + return [A, B] + +def get_init_inputs(): + """ + No specific initialization inputs needed for this model. + + Returns: + list: Empty list. + """ + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_013_matmul_for_symmetric_matrices__shape_small.py b/problems/kb1_013_matmul_for_symmetric_matrices__shape_small.py new file mode 100644 index 0000000000000000000000000000000000000000..9bf20e805ce6a42cbf65518e0d3330a025026755 --- /dev/null +++ b/problems/kb1_013_matmul_for_symmetric_matrices__shape_small.py @@ -0,0 +1,66 @@ +"""Task kb1_013_matmul_for_symmetric_matrices__shape_small (KernelBench Level 1 #13, split=train, category=matmul, dtype=fp32, variant=shape_small).""" +PROBLEM_ID = "kb1_013_matmul_for_symmetric_matrices__shape_small" +SOURCE_KB_ID = 13 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_small" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) with A and B being symmetric matrices. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs matrix multiplication of two symmetric matrices. + + Args: + A (torch.Tensor): Input matrix A, shape (N, N), symmetric. + B (torch.Tensor): Input matrix B, shape (N, N), symmetric. + + Returns: + torch.Tensor: Output matrix C, shape (N, N). + """ + return torch.matmul(A, B) + +N = 4096 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +N = 1024 +N = 768 + +def get_inputs(): + """ + Generates a pair of random symmetric matrices for testing. + + Returns: + list: List containing two symmetric tensors A and B. + """ + A = torch.rand(N, N) + A = (A + A.T) / 2 # Ensure symmetry + B = torch.rand(N, N) + B = (B + B.T) / 2 # Ensure symmetry + return [A, B] + +def get_init_inputs(): + """ + No specific initialization inputs needed for this model. + + Returns: + list: Empty list. + """ + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_014_matmul_for_upper_triangular_matrices.py b/problems/kb1_014_matmul_for_upper_triangular_matrices.py new file mode 100644 index 0000000000000000000000000000000000000000..89e2742a16c5f569ff9cd855417724d9132e17ac --- /dev/null +++ b/problems/kb1_014_matmul_for_upper_triangular_matrices.py @@ -0,0 +1,63 @@ +"""Task kb1_014_matmul_for_upper_triangular_matrices (KernelBench Level 1 #14, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_014_matmul_for_upper_triangular_matrices" +SOURCE_KB_ID = 14 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs matrix multiplication (C = A * B) for upper triangular matrices. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs matrix multiplication for upper triangular matrices. + + Args: + A (torch.Tensor): Upper triangular matrix of shape (N, N). + B (torch.Tensor): Upper triangular matrix of shape (N, N). + + Returns: + torch.Tensor: The product of A and B, also an upper triangular matrix of shape (N, N). + """ + return torch.triu(torch.matmul(A, B)) + +N = 4096 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +N = 1024 + +def get_inputs(): + """ + Generates upper triangular matrices for testing. + + Returns: + list: A list containing two upper triangular matrices of shape (N, N). + """ + A = torch.triu(torch.rand(N, N)) + B = torch.triu(torch.rand(N, N)) + return [A, B] + +def get_init_inputs(): + """ + No specific initialization inputs are needed for this model. + + Returns: + list: An empty list. + """ + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_015_matmul_for_lower_triangular_matrices.py b/problems/kb1_015_matmul_for_lower_triangular_matrices.py new file mode 100644 index 0000000000000000000000000000000000000000..373f083fa86e18c56de0b35e51bb0f318fd908c7 --- /dev/null +++ b/problems/kb1_015_matmul_for_lower_triangular_matrices.py @@ -0,0 +1,53 @@ +"""Task kb1_015_matmul_for_lower_triangular_matrices (KernelBench Level 1 #15, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_015_matmul_for_lower_triangular_matrices" +SOURCE_KB_ID = 15 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a matrix multiplication (C = A * B) where A and B are lower triangular matrices. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A, B): + """ + Performs matrix multiplication of lower triangular matrices A and B. + + Args: + A (torch.Tensor): Lower triangular matrix of shape (N, N). + B (torch.Tensor): Lower triangular matrix of shape (N, N). + + Returns: + torch.Tensor: The result of matrix multiplication C of shape (N, N). + """ + return torch.tril(torch.matmul(A, B)) + +M = 4096 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 + +def get_inputs(): + A = torch.rand(M, M) + B = torch.rand(M, M) + A = torch.tril(A) + B = torch.tril(B) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_016_matmul_with_transposed_a.py b/problems/kb1_016_matmul_with_transposed_a.py new file mode 100644 index 0000000000000000000000000000000000000000..7d974b29bc893e3d3af5195efad59bf3c09bcf80 --- /dev/null +++ b/problems/kb1_016_matmul_with_transposed_a.py @@ -0,0 +1,55 @@ +"""Task kb1_016_matmul_with_transposed_a (KernelBench Level 1 #16, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_016_matmul_with_transposed_a" +SOURCE_KB_ID = 16 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A.T, B) + +M = 1024 * 2 +K = 4096 * 2 +N = 2048 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 2048 +N = 1024 + +def get_inputs(): + A = torch.rand(K, M) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_016_matmul_with_transposed_a__bf16.py b/problems/kb1_016_matmul_with_transposed_a__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..91d446b6d16f45508775170c16f699abdbac322f --- /dev/null +++ b/problems/kb1_016_matmul_with_transposed_a__bf16.py @@ -0,0 +1,55 @@ +"""Task kb1_016_matmul_with_transposed_a__bf16 (KernelBench Level 1 #16, split=train, category=matmul, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_016_matmul_with_transposed_a__bf16" +SOURCE_KB_ID = 16 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A.T, B) + +M = 1024 * 2 +K = 4096 * 2 +N = 2048 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 2048 +N = 1024 + +def get_inputs(): + A = torch.rand(K, M) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_016_matmul_with_transposed_a__shape_nonpow2.py b/problems/kb1_016_matmul_with_transposed_a__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..637e12c1f5f67cc6523e51f14c8910802554b4e3 --- /dev/null +++ b/problems/kb1_016_matmul_with_transposed_a__shape_nonpow2.py @@ -0,0 +1,58 @@ +"""Task kb1_016_matmul_with_transposed_a__shape_nonpow2 (KernelBench Level 1 #16, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_016_matmul_with_transposed_a__shape_nonpow2" +SOURCE_KB_ID = 16 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A.T, B) + +M = 1024 * 2 +K = 4096 * 2 +N = 2048 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 2048 +N = 1024 +M = 1536 +K = 1024 +N = 768 + +def get_inputs(): + A = torch.rand(K, M) + B = torch.rand(K, N) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_018_matmul_with_transposed_both.py b/problems/kb1_018_matmul_with_transposed_both.py new file mode 100644 index 0000000000000000000000000000000000000000..f7a35b49650071dcb6d6d562a10f5fe58325db20 --- /dev/null +++ b/problems/kb1_018_matmul_with_transposed_both.py @@ -0,0 +1,55 @@ +"""Task kb1_018_matmul_with_transposed_both (KernelBench Level 1 #18, split=train, category=matmul, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_018_matmul_with_transposed_both" +SOURCE_KB_ID = 18 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A.T, B.T) + +M = 1024 * 2 +K = 4096 * 2 +N = 2048 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 2048 +N = 1024 + +def get_inputs(): + A = torch.rand(K, M) + B = torch.rand(N, K) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_018_matmul_with_transposed_both__bf16.py b/problems/kb1_018_matmul_with_transposed_both__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..fa4f66705bc62044d22216d445f294e06ac09962 --- /dev/null +++ b/problems/kb1_018_matmul_with_transposed_both__bf16.py @@ -0,0 +1,55 @@ +"""Task kb1_018_matmul_with_transposed_both__bf16 (KernelBench Level 1 #18, split=train, category=matmul, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_018_matmul_with_transposed_both__bf16" +SOURCE_KB_ID = 18 +CATEGORY = "matmul" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a single matrix multiplication (C = A * B) + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor: + """ + Performs matrix multiplication. + + Args: + A: Input tensor of shape (M, K). + B: Input tensor of shape (K, N). + + Returns: + Output tensor of shape (M, N). + """ + return torch.matmul(A.T, B.T) + +M = 1024 * 2 +K = 4096 * 2 +N = 2048 * 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +M = 1024 +K = 2048 +N = 1024 + +def get_inputs(): + A = torch.rand(K, M) + B = torch.rand(N, K) + return [A, B] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_020_leakyrelu.py b/problems/kb1_020_leakyrelu.py new file mode 100644 index 0000000000000000000000000000000000000000..80a0f964a880bef52b968f5125b2380a36b120d1 --- /dev/null +++ b/problems/kb1_020_leakyrelu.py @@ -0,0 +1,58 @@ +"""Task kb1_020_leakyrelu (KernelBench Level 1 #20, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_020_leakyrelu" +SOURCE_KB_ID = 20 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a LeakyReLU activation. + """ + def __init__(self, negative_slope: float = 0.01): + """ + Initializes the LeakyReLU module. + + Args: + negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01. + """ + super(Model, self).__init__() + self.negative_slope = negative_slope + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies LeakyReLU activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with LeakyReLU applied, same shape as input. + """ + return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_020_leakyrelu__bf16.py b/problems/kb1_020_leakyrelu__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..5ad9c482980a671f74b0cfafb44e6a41f3263886 --- /dev/null +++ b/problems/kb1_020_leakyrelu__bf16.py @@ -0,0 +1,58 @@ +"""Task kb1_020_leakyrelu__bf16 (KernelBench Level 1 #20, split=train, category=activation, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_020_leakyrelu__bf16" +SOURCE_KB_ID = 20 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a LeakyReLU activation. + """ + def __init__(self, negative_slope: float = 0.01): + """ + Initializes the LeakyReLU module. + + Args: + negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01. + """ + super(Model, self).__init__() + self.negative_slope = negative_slope + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies LeakyReLU activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with LeakyReLU applied, same shape as input. + """ + return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_020_leakyrelu__shape_wide.py b/problems/kb1_020_leakyrelu__shape_wide.py new file mode 100644 index 0000000000000000000000000000000000000000..3c1301a63dbdc0c096244750e2c5f51cc6a6578f --- /dev/null +++ b/problems/kb1_020_leakyrelu__shape_wide.py @@ -0,0 +1,60 @@ +"""Task kb1_020_leakyrelu__shape_wide (KernelBench Level 1 #20, split=train, category=activation, dtype=fp32, variant=shape_wide).""" +PROBLEM_ID = "kb1_020_leakyrelu__shape_wide" +SOURCE_KB_ID = 20 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_wide" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a LeakyReLU activation. + """ + def __init__(self, negative_slope: float = 0.01): + """ + Initializes the LeakyReLU module. + + Args: + negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01. + """ + super(Model, self).__init__() + self.negative_slope = negative_slope + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies LeakyReLU activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with LeakyReLU applied, same shape as input. + """ + return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 512 +dim = 12288 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_021_sigmoid.py b/problems/kb1_021_sigmoid.py new file mode 100644 index 0000000000000000000000000000000000000000..727c1a68269a862d65ea782078e233ebb26bbad6 --- /dev/null +++ b/problems/kb1_021_sigmoid.py @@ -0,0 +1,51 @@ +"""Task kb1_021_sigmoid (KernelBench Level 1 #21, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_021_sigmoid" +SOURCE_KB_ID = 21 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Sigmoid activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Sigmoid activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Sigmoid applied, same shape as input. + """ + return torch.sigmoid(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_021_sigmoid__bf16.py b/problems/kb1_021_sigmoid__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..4a03fb8e22aabb5a41fdea75442ce38eed64bca4 --- /dev/null +++ b/problems/kb1_021_sigmoid__bf16.py @@ -0,0 +1,51 @@ +"""Task kb1_021_sigmoid__bf16 (KernelBench Level 1 #21, split=train, category=activation, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_021_sigmoid__bf16" +SOURCE_KB_ID = 21 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Sigmoid activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Sigmoid activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Sigmoid applied, same shape as input. + """ + return torch.sigmoid(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_021_sigmoid__shape_nonpow2.py b/problems/kb1_021_sigmoid__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..7b7dbbec210190812214eaf7fc70874644a82599 --- /dev/null +++ b/problems/kb1_021_sigmoid__shape_nonpow2.py @@ -0,0 +1,53 @@ +"""Task kb1_021_sigmoid__shape_nonpow2 (KernelBench Level 1 #21, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_021_sigmoid__shape_nonpow2" +SOURCE_KB_ID = 21 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Sigmoid activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Sigmoid activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Sigmoid applied, same shape as input. + """ + return torch.sigmoid(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 1500 +dim = 3000 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_022_tanh.py b/problems/kb1_022_tanh.py new file mode 100644 index 0000000000000000000000000000000000000000..12195de25180713aca59124acf923678914df266 --- /dev/null +++ b/problems/kb1_022_tanh.py @@ -0,0 +1,51 @@ +"""Task kb1_022_tanh (KernelBench Level 1 #22, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_022_tanh" +SOURCE_KB_ID = 22 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Tanh activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Tanh activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Tanh applied, same shape as input. + """ + return torch.tanh(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_022_tanh__fp16.py b/problems/kb1_022_tanh__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..8d17b5247f1f374f3996ee146db2f927b8d66e2b --- /dev/null +++ b/problems/kb1_022_tanh__fp16.py @@ -0,0 +1,51 @@ +"""Task kb1_022_tanh__fp16 (KernelBench Level 1 #22, split=train, category=activation, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_022_tanh__fp16" +SOURCE_KB_ID = 22 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Tanh activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Tanh activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Tanh applied, same shape as input. + """ + return torch.tanh(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_022_tanh__shape_tall.py b/problems/kb1_022_tanh__shape_tall.py new file mode 100644 index 0000000000000000000000000000000000000000..21dc2b34aa6728c68c0eafed0f81ddfef7efa1b7 --- /dev/null +++ b/problems/kb1_022_tanh__shape_tall.py @@ -0,0 +1,53 @@ +"""Task kb1_022_tanh__shape_tall (KernelBench Level 1 #22, split=train, category=activation, dtype=fp32, variant=shape_tall).""" +PROBLEM_ID = "kb1_022_tanh__shape_tall" +SOURCE_KB_ID = 22 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_tall" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Tanh activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Tanh activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Tanh applied, same shape as input. + """ + return torch.tanh(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 8192 +dim = 1024 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_024_logsoftmax.py b/problems/kb1_024_logsoftmax.py new file mode 100644 index 0000000000000000000000000000000000000000..5cb08d50b39188564742725339dec9a6a1431b35 --- /dev/null +++ b/problems/kb1_024_logsoftmax.py @@ -0,0 +1,52 @@ +"""Task kb1_024_logsoftmax (KernelBench Level 1 #24, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_024_logsoftmax" +SOURCE_KB_ID = 24 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a LogSoftmax activation. + """ + def __init__(self, dim: int = 1): + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies LogSoftmax activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, dim). + + Returns: + torch.Tensor: Output tensor with LogSoftmax applied, same shape as input. + """ + return torch.log_softmax(x, dim=self.dim) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_024_logsoftmax__bf16.py b/problems/kb1_024_logsoftmax__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..267d869435170219d354e9461e40e433604654be --- /dev/null +++ b/problems/kb1_024_logsoftmax__bf16.py @@ -0,0 +1,52 @@ +"""Task kb1_024_logsoftmax__bf16 (KernelBench Level 1 #24, split=train, category=activation, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_024_logsoftmax__bf16" +SOURCE_KB_ID = 24 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a LogSoftmax activation. + """ + def __init__(self, dim: int = 1): + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies LogSoftmax activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, dim). + + Returns: + torch.Tensor: Output tensor with LogSoftmax applied, same shape as input. + """ + return torch.log_softmax(x, dim=self.dim) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_024_logsoftmax__shape_vocab.py b/problems/kb1_024_logsoftmax__shape_vocab.py new file mode 100644 index 0000000000000000000000000000000000000000..7c4257c253cf18f41f8f8df1a11612540a72a3d8 --- /dev/null +++ b/problems/kb1_024_logsoftmax__shape_vocab.py @@ -0,0 +1,54 @@ +"""Task kb1_024_logsoftmax__shape_vocab (KernelBench Level 1 #24, split=train, category=activation, dtype=fp32, variant=shape_vocab).""" +PROBLEM_ID = "kb1_024_logsoftmax__shape_vocab" +SOURCE_KB_ID = 24 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_vocab" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a LogSoftmax activation. + """ + def __init__(self, dim: int = 1): + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies LogSoftmax activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, dim). + + Returns: + torch.Tensor: Output tensor with LogSoftmax applied, same shape as input. + """ + return torch.log_softmax(x, dim=self.dim) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 512 +dim = 16384 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_027_selu.py b/problems/kb1_027_selu.py new file mode 100644 index 0000000000000000000000000000000000000000..1788cc89d12198117c55e5b09c85d6ed5407c9b4 --- /dev/null +++ b/problems/kb1_027_selu.py @@ -0,0 +1,51 @@ +"""Task kb1_027_selu (KernelBench Level 1 #27, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_027_selu" +SOURCE_KB_ID = 27 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a SELU activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies SELU activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with SELU applied, same shape as input. + """ + return torch.selu(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_027_selu__bf16.py b/problems/kb1_027_selu__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..ec458eeb2eb40b96fc65f8812dc8c3383ab46324 --- /dev/null +++ b/problems/kb1_027_selu__bf16.py @@ -0,0 +1,51 @@ +"""Task kb1_027_selu__bf16 (KernelBench Level 1 #27, split=train, category=activation, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_027_selu__bf16" +SOURCE_KB_ID = 27 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a SELU activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies SELU activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with SELU applied, same shape as input. + """ + return torch.selu(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_027_selu__shape_nonpow2.py b/problems/kb1_027_selu__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..198b4c27ec049afb16034822730243c7343e78f6 --- /dev/null +++ b/problems/kb1_027_selu__shape_nonpow2.py @@ -0,0 +1,53 @@ +"""Task kb1_027_selu__shape_nonpow2 (KernelBench Level 1 #27, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_027_selu__shape_nonpow2" +SOURCE_KB_ID = 27 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a SELU activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies SELU activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with SELU applied, same shape as input. + """ + return torch.selu(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 1024 +dim = 6144 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_028_hardsigmoid.py b/problems/kb1_028_hardsigmoid.py new file mode 100644 index 0000000000000000000000000000000000000000..9899d4b5e47e036a33b72769f24e027bd178f441 --- /dev/null +++ b/problems/kb1_028_hardsigmoid.py @@ -0,0 +1,51 @@ +"""Task kb1_028_hardsigmoid (KernelBench Level 1 #28, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_028_hardsigmoid" +SOURCE_KB_ID = 28 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a HardSigmoid activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies HardSigmoid activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with HardSigmoid applied, same shape as input. + """ + return torch.nn.functional.hardsigmoid(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_028_hardsigmoid__fp16.py b/problems/kb1_028_hardsigmoid__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..05f8cb843ca4b2b7667b90c32bbf989443add65c --- /dev/null +++ b/problems/kb1_028_hardsigmoid__fp16.py @@ -0,0 +1,51 @@ +"""Task kb1_028_hardsigmoid__fp16 (KernelBench Level 1 #28, split=train, category=activation, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_028_hardsigmoid__fp16" +SOURCE_KB_ID = 28 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a HardSigmoid activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies HardSigmoid activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with HardSigmoid applied, same shape as input. + """ + return torch.nn.functional.hardsigmoid(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_029_softplus.py b/problems/kb1_029_softplus.py new file mode 100644 index 0000000000000000000000000000000000000000..e75449846c46a5f6f1ad635338586a50e966d637 --- /dev/null +++ b/problems/kb1_029_softplus.py @@ -0,0 +1,51 @@ +"""Task kb1_029_softplus (KernelBench Level 1 #29, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_029_softplus" +SOURCE_KB_ID = 29 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Softplus activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Softplus activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Softplus applied, same shape as input. + """ + return torch.nn.functional.softplus(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_029_softplus__fp16.py b/problems/kb1_029_softplus__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..43ad9e62bd691c2ec61521ea9b33e01eb1dde4c5 --- /dev/null +++ b/problems/kb1_029_softplus__fp16.py @@ -0,0 +1,51 @@ +"""Task kb1_029_softplus__fp16 (KernelBench Level 1 #29, split=train, category=activation, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_029_softplus__fp16" +SOURCE_KB_ID = 29 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Softplus activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Softplus activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Softplus applied, same shape as input. + """ + return torch.nn.functional.softplus(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_029_softplus__shape_wide.py b/problems/kb1_029_softplus__shape_wide.py new file mode 100644 index 0000000000000000000000000000000000000000..692ee95039b0b8c215a575a4bf799e9c5a01cf2f --- /dev/null +++ b/problems/kb1_029_softplus__shape_wide.py @@ -0,0 +1,53 @@ +"""Task kb1_029_softplus__shape_wide (KernelBench Level 1 #29, split=train, category=activation, dtype=fp32, variant=shape_wide).""" +PROBLEM_ID = "kb1_029_softplus__shape_wide" +SOURCE_KB_ID = 29 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_wide" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Softplus activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Softplus activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Softplus applied, same shape as input. + """ + return torch.nn.functional.softplus(x) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 1024 +dim = 8192 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_030_softsign.py b/problems/kb1_030_softsign.py new file mode 100644 index 0000000000000000000000000000000000000000..42727eee33474fdf70d275e1199e8e3975065557 --- /dev/null +++ b/problems/kb1_030_softsign.py @@ -0,0 +1,51 @@ +"""Task kb1_030_softsign (KernelBench Level 1 #30, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_030_softsign" +SOURCE_KB_ID = 30 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Softsign activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Softsign activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Softsign applied, same shape as input. + """ + return x / (1 + torch.abs(x)) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_030_softsign__shape_nonpow2.py b/problems/kb1_030_softsign__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..5f0cbcede68f3907a27f99bc11311a7fd40a47f2 --- /dev/null +++ b/problems/kb1_030_softsign__shape_nonpow2.py @@ -0,0 +1,53 @@ +"""Task kb1_030_softsign__shape_nonpow2 (KernelBench Level 1 #30, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_030_softsign__shape_nonpow2" +SOURCE_KB_ID = 30 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs a Softsign activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Softsign activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with Softsign applied, same shape as input. + """ + return x / (1 + torch.abs(x)) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 3000 +dim = 2000 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_031_elu.py b/problems/kb1_031_elu.py new file mode 100644 index 0000000000000000000000000000000000000000..ddfb988a6d1e8c98fa8f3efdaf7cd13db0b16ac8 --- /dev/null +++ b/problems/kb1_031_elu.py @@ -0,0 +1,59 @@ +"""Task kb1_031_elu (KernelBench Level 1 #31, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_031_elu" +SOURCE_KB_ID = 31 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn +import torch.nn.functional as F + +class Model(nn.Module): + """ + Simple model that performs an ELU activation. + """ + def __init__(self, alpha: float = 1.0): + """ + Initializes the ELU model. + + Args: + alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0. + """ + super(Model, self).__init__() + self.alpha = alpha + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies ELU activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with ELU applied, same shape as input. + """ + return F.elu(x, alpha=self.alpha) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [1.0] # Provide alpha value for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_031_elu__fp16.py b/problems/kb1_031_elu__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..545c10334e9d76741cc1a94ea88211626381d697 --- /dev/null +++ b/problems/kb1_031_elu__fp16.py @@ -0,0 +1,59 @@ +"""Task kb1_031_elu__fp16 (KernelBench Level 1 #31, split=train, category=activation, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_031_elu__fp16" +SOURCE_KB_ID = 31 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn +import torch.nn.functional as F + +class Model(nn.Module): + """ + Simple model that performs an ELU activation. + """ + def __init__(self, alpha: float = 1.0): + """ + Initializes the ELU model. + + Args: + alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0. + """ + super(Model, self).__init__() + self.alpha = alpha + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies ELU activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with ELU applied, same shape as input. + """ + return F.elu(x, alpha=self.alpha) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [1.0] # Provide alpha value for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_031_elu__shape_tall.py b/problems/kb1_031_elu__shape_tall.py new file mode 100644 index 0000000000000000000000000000000000000000..6124cd76b6c51996efcca0f93c35e6ae88d0a4c6 --- /dev/null +++ b/problems/kb1_031_elu__shape_tall.py @@ -0,0 +1,61 @@ +"""Task kb1_031_elu__shape_tall (KernelBench Level 1 #31, split=train, category=activation, dtype=fp32, variant=shape_tall).""" +PROBLEM_ID = "kb1_031_elu__shape_tall" +SOURCE_KB_ID = 31 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_tall" + +import torch +import torch.nn as nn +import torch.nn.functional as F + +class Model(nn.Module): + """ + Simple model that performs an ELU activation. + """ + def __init__(self, alpha: float = 1.0): + """ + Initializes the ELU model. + + Args: + alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0. + """ + super(Model, self).__init__() + self.alpha = alpha + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies ELU activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with ELU applied, same shape as input. + """ + return F.elu(x, alpha=self.alpha) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 4096 +dim = 2048 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [1.0] # Provide alpha value for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_032_hardtanh.py b/problems/kb1_032_hardtanh.py new file mode 100644 index 0000000000000000000000000000000000000000..0ef35eae16fe286d87e96a1806bcd65a871e3c62 --- /dev/null +++ b/problems/kb1_032_hardtanh.py @@ -0,0 +1,52 @@ +"""Task kb1_032_hardtanh (KernelBench Level 1 #32, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_032_hardtanh" +SOURCE_KB_ID = 32 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn +import torch.nn.functional as F + +class Model(nn.Module): + """ + Simple model that performs a HardTanh activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies HardTanh activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with HardTanh applied, same shape as input. + """ + return F.hardtanh(x, min_val=-1., max_val=1.) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_032_hardtanh__shape_nonpow2.py b/problems/kb1_032_hardtanh__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..03d3405845c3d4ca680f575d1804e7b10bff0735 --- /dev/null +++ b/problems/kb1_032_hardtanh__shape_nonpow2.py @@ -0,0 +1,54 @@ +"""Task kb1_032_hardtanh__shape_nonpow2 (KernelBench Level 1 #32, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_032_hardtanh__shape_nonpow2" +SOURCE_KB_ID = 32 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn +import torch.nn.functional as F + +class Model(nn.Module): + """ + Simple model that performs a HardTanh activation. + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies HardTanh activation to the input tensor. + + Args: + x (torch.Tensor): Input tensor of any shape. + + Returns: + torch.Tensor: Output tensor with HardTanh applied, same shape as input. + """ + return F.hardtanh(x, min_val=-1., max_val=1.) + +batch_size = 4096 +dim = 393216 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 2500 +dim = 3072 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] # No special initialization inputs needed +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_033_batchnorm.py b/problems/kb1_033_batchnorm.py new file mode 100644 index 0000000000000000000000000000000000000000..5a8787ed4a6a9e7a463b73c70f59b7c131e260a0 --- /dev/null +++ b/problems/kb1_033_batchnorm.py @@ -0,0 +1,62 @@ +"""Task kb1_033_batchnorm (KernelBench Level 1 #33, split=train, category=normalization, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_033_batchnorm" +SOURCE_KB_ID = 33 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Batch Normalization. + """ + def __init__(self, num_features: int): + """ + Initializes the BatchNorm layer. + + Args: + num_features (int): Number of features in the input tensor. + """ + super(Model, self).__init__() + self.bn = nn.BatchNorm2d(num_features=num_features) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Batch Normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, num_features, *). + + Returns: + torch.Tensor: Output tensor with Batch Normalization applied, same shape as input. + """ + return self.bn(x) + +batch_size = 64 +features = 64 +dim1 = 512 +dim2 = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +features = 64 +dim1 = 128 +dim2 = 128 + +def get_inputs(): + x = torch.randn(batch_size, features, dim1, dim2) + return [x] + +def get_init_inputs(): + return [features] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_033_batchnorm__bf16.py b/problems/kb1_033_batchnorm__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..c3c58c4d143849d0305e49a2e1af322f4196f0b9 --- /dev/null +++ b/problems/kb1_033_batchnorm__bf16.py @@ -0,0 +1,62 @@ +"""Task kb1_033_batchnorm__bf16 (KernelBench Level 1 #33, split=train, category=normalization, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_033_batchnorm__bf16" +SOURCE_KB_ID = 33 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Batch Normalization. + """ + def __init__(self, num_features: int): + """ + Initializes the BatchNorm layer. + + Args: + num_features (int): Number of features in the input tensor. + """ + super(Model, self).__init__() + self.bn = nn.BatchNorm2d(num_features=num_features) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Batch Normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, num_features, *). + + Returns: + torch.Tensor: Output tensor with Batch Normalization applied, same shape as input. + """ + return self.bn(x) + +batch_size = 64 +features = 64 +dim1 = 512 +dim2 = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +features = 64 +dim1 = 128 +dim2 = 128 + +def get_inputs(): + x = torch.randn(batch_size, features, dim1, dim2) + return [x] + +def get_init_inputs(): + return [features] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_033_batchnorm__shape_spatial.py b/problems/kb1_033_batchnorm__shape_spatial.py new file mode 100644 index 0000000000000000000000000000000000000000..cf3a268a09094a04713217cfe63b9ee50a0fe178 --- /dev/null +++ b/problems/kb1_033_batchnorm__shape_spatial.py @@ -0,0 +1,66 @@ +"""Task kb1_033_batchnorm__shape_spatial (KernelBench Level 1 #33, split=train, category=normalization, dtype=fp32, variant=shape_spatial).""" +PROBLEM_ID = "kb1_033_batchnorm__shape_spatial" +SOURCE_KB_ID = 33 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_spatial" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Batch Normalization. + """ + def __init__(self, num_features: int): + """ + Initializes the BatchNorm layer. + + Args: + num_features (int): Number of features in the input tensor. + """ + super(Model, self).__init__() + self.bn = nn.BatchNorm2d(num_features=num_features) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Batch Normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, num_features, *). + + Returns: + torch.Tensor: Output tensor with Batch Normalization applied, same shape as input. + """ + return self.bn(x) + +batch_size = 64 +features = 64 +dim1 = 512 +dim2 = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +features = 64 +dim1 = 128 +dim2 = 128 +batch_size = 8 +features = 128 +dim1 = 64 +dim2 = 64 + +def get_inputs(): + x = torch.randn(batch_size, features, dim1, dim2) + return [x] + +def get_init_inputs(): + return [features] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_034_instancenorm.py b/problems/kb1_034_instancenorm.py new file mode 100644 index 0000000000000000000000000000000000000000..e539522fdea61744f55a09d947d263fe5ee2ea94 --- /dev/null +++ b/problems/kb1_034_instancenorm.py @@ -0,0 +1,62 @@ +"""Task kb1_034_instancenorm (KernelBench Level 1 #34, split=train, category=normalization, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_034_instancenorm" +SOURCE_KB_ID = 34 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Instance Normalization. + """ + def __init__(self, num_features: int): + """ + Initializes the InstanceNorm layer. + + Args: + num_features (int): Number of features in the input tensor. + """ + super(Model, self).__init__() + self.inorm = nn.InstanceNorm2d(num_features=num_features) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Instance Normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, num_features, height, width). + + Returns: + torch.Tensor: Output tensor with Instance Normalization applied, same shape as input. + """ + return self.inorm(x) + +batch_size = 112 # heavier workload +features = 64 +dim1 = 512 +dim2 = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +features = 64 +dim1 = 128 +dim2 = 128 + +def get_inputs(): + x = torch.randn(batch_size, features, dim1, dim2) + return [x] + +def get_init_inputs(): + return [features] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_034_instancenorm__fp16.py b/problems/kb1_034_instancenorm__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..413b25697ec4bd33f7f2d1990372fab187c414dd --- /dev/null +++ b/problems/kb1_034_instancenorm__fp16.py @@ -0,0 +1,62 @@ +"""Task kb1_034_instancenorm__fp16 (KernelBench Level 1 #34, split=train, category=normalization, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_034_instancenorm__fp16" +SOURCE_KB_ID = 34 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Instance Normalization. + """ + def __init__(self, num_features: int): + """ + Initializes the InstanceNorm layer. + + Args: + num_features (int): Number of features in the input tensor. + """ + super(Model, self).__init__() + self.inorm = nn.InstanceNorm2d(num_features=num_features) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Instance Normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, num_features, height, width). + + Returns: + torch.Tensor: Output tensor with Instance Normalization applied, same shape as input. + """ + return self.inorm(x) + +batch_size = 112 # heavier workload +features = 64 +dim1 = 512 +dim2 = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +features = 64 +dim1 = 128 +dim2 = 128 + +def get_inputs(): + x = torch.randn(batch_size, features, dim1, dim2) + return [x] + +def get_init_inputs(): + return [features] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_035_groupnorm.py b/problems/kb1_035_groupnorm.py new file mode 100644 index 0000000000000000000000000000000000000000..55981f7d45cbfa69eab17af2f4aed95a3e0af3f7 --- /dev/null +++ b/problems/kb1_035_groupnorm.py @@ -0,0 +1,65 @@ +"""Task kb1_035_groupnorm (KernelBench Level 1 #35, split=train, category=normalization, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_035_groupnorm" +SOURCE_KB_ID = 35 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Group Normalization. + """ + def __init__(self, num_features: int, num_groups: int): + """ + Initializes the GroupNorm layer. + + Args: + num_features (int): Number of features in the input tensor. + num_groups (int): Number of groups to divide the channels into. + """ + super(Model, self).__init__() + self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Group Normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, num_features, *). + + Returns: + torch.Tensor: Output tensor with Group Normalization applied, same shape as input. + """ + return self.gn(x) + +batch_size = 112 # scaled up +features = 64 +num_groups = 8 +dim1 = 512 +dim2 = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +features = 64 +num_groups = 8 +dim1 = 128 +dim2 = 128 + +def get_inputs(): + x = torch.randn(batch_size, features, dim1, dim2) + return [x] + +def get_init_inputs(): + return [features, num_groups] # num_features +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_035_groupnorm__bf16.py b/problems/kb1_035_groupnorm__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..583b8dec7b347b438aa5a11b3913fc40ee902e14 --- /dev/null +++ b/problems/kb1_035_groupnorm__bf16.py @@ -0,0 +1,65 @@ +"""Task kb1_035_groupnorm__bf16 (KernelBench Level 1 #35, split=train, category=normalization, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_035_groupnorm__bf16" +SOURCE_KB_ID = 35 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Group Normalization. + """ + def __init__(self, num_features: int, num_groups: int): + """ + Initializes the GroupNorm layer. + + Args: + num_features (int): Number of features in the input tensor. + num_groups (int): Number of groups to divide the channels into. + """ + super(Model, self).__init__() + self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Group Normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, num_features, *). + + Returns: + torch.Tensor: Output tensor with Group Normalization applied, same shape as input. + """ + return self.gn(x) + +batch_size = 112 # scaled up +features = 64 +num_groups = 8 +dim1 = 512 +dim2 = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +features = 64 +num_groups = 8 +dim1 = 128 +dim2 = 128 + +def get_inputs(): + x = torch.randn(batch_size, features, dim1, dim2) + return [x] + +def get_init_inputs(): + return [features, num_groups] # num_features +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_035_groupnorm__shape_groups16.py b/problems/kb1_035_groupnorm__shape_groups16.py new file mode 100644 index 0000000000000000000000000000000000000000..68648f89fbe65b8116d331d7f3a27db215468b44 --- /dev/null +++ b/problems/kb1_035_groupnorm__shape_groups16.py @@ -0,0 +1,70 @@ +"""Task kb1_035_groupnorm__shape_groups16 (KernelBench Level 1 #35, split=train, category=normalization, dtype=fp32, variant=shape_groups16).""" +PROBLEM_ID = "kb1_035_groupnorm__shape_groups16" +SOURCE_KB_ID = 35 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_groups16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Group Normalization. + """ + def __init__(self, num_features: int, num_groups: int): + """ + Initializes the GroupNorm layer. + + Args: + num_features (int): Number of features in the input tensor. + num_groups (int): Number of groups to divide the channels into. + """ + super(Model, self).__init__() + self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Group Normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, num_features, *). + + Returns: + torch.Tensor: Output tensor with Group Normalization applied, same shape as input. + """ + return self.gn(x) + +batch_size = 112 # scaled up +features = 64 +num_groups = 8 +dim1 = 512 +dim2 = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +features = 64 +num_groups = 8 +dim1 = 128 +dim2 = 128 +batch_size = 8 +features = 128 +num_groups = 16 +dim1 = 64 +dim2 = 64 + +def get_inputs(): + x = torch.randn(batch_size, features, dim1, dim2) + return [x] + +def get_init_inputs(): + return [features, num_groups] # num_features +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_037_frobeniusnorm.py b/problems/kb1_037_frobeniusnorm.py new file mode 100644 index 0000000000000000000000000000000000000000..6d808ac2da156c5fc9110a4753a2e08ddcfa0769 --- /dev/null +++ b/problems/kb1_037_frobeniusnorm.py @@ -0,0 +1,59 @@ +"""Task kb1_037_frobeniusnorm (KernelBench Level 1 #37, split=train, category=normalization, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_037_frobeniusnorm" +SOURCE_KB_ID = 37 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Frobenius norm normalization. + """ + def __init__(self): + """ + Initializes the Frobenius norm normalization layer. + """ + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Frobenius norm normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of arbitrary shape. + + Returns: + torch.Tensor: Output tensor with Frobenius norm normalization applied, same shape as input. + """ + norm = torch.norm(x, p='fro') + return x / norm + +batch_size = 112 +features = 64 +dim1 = 512 +dim2 = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +features = 64 +dim1 = 128 +dim2 = 128 + +def get_inputs(): + x = torch.randn(batch_size, features, dim1, dim2) + return [x] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_038_l1norm.py b/problems/kb1_038_l1norm.py new file mode 100644 index 0000000000000000000000000000000000000000..82ab4fcfcc9a00ed61f72c08a9a4767b221697da --- /dev/null +++ b/problems/kb1_038_l1norm.py @@ -0,0 +1,55 @@ +"""Task kb1_038_l1norm (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_038_l1norm" +SOURCE_KB_ID = 38 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs L1 normalization. + """ + def __init__(self): + """ + Initializes the L1 normalization layer. + """ + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies L1 normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (..., dim, ...). + + Returns: + torch.Tensor: Output tensor with L1 normalization applied, same shape as input. + """ + return x / torch.mean(torch.abs(x), dim=1, keepdim=True) + +batch_size = 32768 +# choose dim so total <2^31 +dim = 65535 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_038_l1norm__fp16.py b/problems/kb1_038_l1norm__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..290dd71dbb12cc2c01b3483989586df8eb8cd1c8 --- /dev/null +++ b/problems/kb1_038_l1norm__fp16.py @@ -0,0 +1,55 @@ +"""Task kb1_038_l1norm__fp16 (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_038_l1norm__fp16" +SOURCE_KB_ID = 38 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs L1 normalization. + """ + def __init__(self): + """ + Initializes the L1 normalization layer. + """ + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies L1 normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (..., dim, ...). + + Returns: + torch.Tensor: Output tensor with L1 normalization applied, same shape as input. + """ + return x / torch.mean(torch.abs(x), dim=1, keepdim=True) + +batch_size = 32768 +# choose dim so total <2^31 +dim = 65535 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_038_l1norm__shape_nonpow2.py b/problems/kb1_038_l1norm__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..483e89f874bbf3599b33388bd6254e8f81462b1f --- /dev/null +++ b/problems/kb1_038_l1norm__shape_nonpow2.py @@ -0,0 +1,57 @@ +"""Task kb1_038_l1norm__shape_nonpow2 (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_038_l1norm__shape_nonpow2" +SOURCE_KB_ID = 38 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs L1 normalization. + """ + def __init__(self): + """ + Initializes the L1 normalization layer. + """ + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies L1 normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (..., dim, ...). + + Returns: + torch.Tensor: Output tensor with L1 normalization applied, same shape as input. + """ + return x / torch.mean(torch.abs(x), dim=1, keepdim=True) + +batch_size = 32768 +# choose dim so total <2^31 +dim = 65535 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 1536 +dim = 5120 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_039_l2norm.py b/problems/kb1_039_l2norm.py new file mode 100644 index 0000000000000000000000000000000000000000..c3ab030f38859b8053f20e520feb3bcad02f7b93 --- /dev/null +++ b/problems/kb1_039_l2norm.py @@ -0,0 +1,58 @@ +"""Task kb1_039_l2norm (KernelBench Level 1 #39, split=train, category=normalization, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_039_l2norm" +SOURCE_KB_ID = 39 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs L2 normalization. + """ + def __init__(self): + """ + Initializes the L2Norm layer. + + Args: + dim (int): Dimension along which to normalize. + """ + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies L2 normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (*, dim, *). + + Returns: + torch.Tensor: Output tensor with L2 normalization applied, same shape as input. + """ + return x / torch.norm(x, p=2, dim=1, keepdim=True) + +batch_size = 32768 +# choose dim so total <2^31 +dim = 65535 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_039_l2norm__bf16.py b/problems/kb1_039_l2norm__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..e1c949ef616a24e212fb7550a31a566fc8ac9f10 --- /dev/null +++ b/problems/kb1_039_l2norm__bf16.py @@ -0,0 +1,58 @@ +"""Task kb1_039_l2norm__bf16 (KernelBench Level 1 #39, split=train, category=normalization, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_039_l2norm__bf16" +SOURCE_KB_ID = 39 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs L2 normalization. + """ + def __init__(self): + """ + Initializes the L2Norm layer. + + Args: + dim (int): Dimension along which to normalize. + """ + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies L2 normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (*, dim, *). + + Returns: + torch.Tensor: Output tensor with L2 normalization applied, same shape as input. + """ + return x / torch.norm(x, p=2, dim=1, keepdim=True) + +batch_size = 32768 +# choose dim so total <2^31 +dim = 65535 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_039_l2norm__shape_wide.py b/problems/kb1_039_l2norm__shape_wide.py new file mode 100644 index 0000000000000000000000000000000000000000..a23ef047ec21a7f5d4cf4b9263fd654bbbcaf974 --- /dev/null +++ b/problems/kb1_039_l2norm__shape_wide.py @@ -0,0 +1,60 @@ +"""Task kb1_039_l2norm__shape_wide (KernelBench Level 1 #39, split=train, category=normalization, dtype=fp32, variant=shape_wide).""" +PROBLEM_ID = "kb1_039_l2norm__shape_wide" +SOURCE_KB_ID = 39 +CATEGORY = "normalization" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_wide" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs L2 normalization. + """ + def __init__(self): + """ + Initializes the L2Norm layer. + + Args: + dim (int): Dimension along which to normalize. + """ + super(Model, self).__init__() + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies L2 normalization to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (*, dim, *). + + Returns: + torch.Tensor: Output tensor with L2 normalization applied, same shape as input. + """ + return x / torch.norm(x, p=2, dim=1, keepdim=True) + +batch_size = 32768 +# choose dim so total <2^31 +dim = 65535 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 1024 +dim = 8192 + +def get_inputs(): + x = torch.randn(batch_size, dim) + return [x] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_041_max_pooling_1d.py b/problems/kb1_041_max_pooling_1d.py new file mode 100644 index 0000000000000000000000000000000000000000..30f01fe91fe241d2982b2c703d0bc6a96a2404ed --- /dev/null +++ b/problems/kb1_041_max_pooling_1d.py @@ -0,0 +1,71 @@ +"""Task kb1_041_max_pooling_1d (KernelBench Level 1 #41, split=train, category=pooling, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_041_max_pooling_1d" +SOURCE_KB_ID = 41 +CATEGORY = "pooling" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Max Pooling 1D. + """ + def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False): + """ + Initializes the Max Pooling 1D layer. + + Args: + kernel_size (int): Size of the window to take a max over. + stride (int, optional): Stride of the window. Defaults to None (same as kernel_size). + padding (int, optional): Implicit zero padding to be added on both sides. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + return_indices (bool, optional): Whether to return the indices of the maximum values. Defaults to False. + """ + super(Model, self).__init__() + self.maxpool = nn.MaxPool1d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Max Pooling 1D to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, num_features, sequence_length). + + Returns: + torch.Tensor: Output tensor with Max Pooling 1D applied, shape (batch_size, num_features, output_sequence_length). + """ + return self.maxpool(x) + +batch_size = 64 +features = 192 +sequence_length = 65536 + +kernel_size = 8 +stride = 1 +padding = 4 +dilation = 3 + +return_indices = False + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +features = 64 +sequence_length = 8192 + +def get_inputs(): + x = torch.rand(batch_size, features, sequence_length) + return [x] + +def get_init_inputs(): + return [kernel_size, stride, padding, dilation, return_indices] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_043_max_pooling_3d.py b/problems/kb1_043_max_pooling_3d.py new file mode 100644 index 0000000000000000000000000000000000000000..471bbca93f5ddf53a0590341484688ad6d5717df --- /dev/null +++ b/problems/kb1_043_max_pooling_3d.py @@ -0,0 +1,73 @@ +"""Task kb1_043_max_pooling_3d (KernelBench Level 1 #43, split=train, category=pooling, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_043_max_pooling_3d" +SOURCE_KB_ID = 43 +CATEGORY = "pooling" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Max Pooling 3D. + """ + def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False, ceil_mode: bool = False): + """ + Initializes the Max Pooling 3D layer. + + Args: + kernel_size (int): Size of the kernel for the max pooling operation. + stride (int, optional): Stride of the pooling operation. Defaults to None, which means stride is equal to kernel_size. + padding (int, optional): Padding applied to the input tensor. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + return_indices (bool, optional): Whether to return indices of the maximum values. Defaults to False. + ceil_mode (bool, optional): When True, the output size is ceil(input_size / stride) instead of floor. Defaults to False. + """ + super(Model, self).__init__() + self.maxpool = nn.MaxPool3d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices, ceil_mode=ceil_mode) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Max Pooling 3D to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, channels, dim1, dim2, dim3). + + Returns: + torch.Tensor: Output tensor with Max Pooling 3D applied. + """ + return self.maxpool(x) + +batch_size = 16 +channels = 32 +dim1 = 128 +dim2 = 128 +dim3 = 128 +kernel_size = 3 +stride = 2 +padding = 1 +dilation = 3 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +channels = 16 +dim1 = 32 +dim2 = 32 +dim3 = 32 + +def get_inputs(): + x = torch.rand(batch_size, channels, dim1, dim2, dim3) + return [x] + +def get_init_inputs(): + return [kernel_size, stride, padding, dilation] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_044_average_pooling_1d.py b/problems/kb1_044_average_pooling_1d.py new file mode 100644 index 0000000000000000000000000000000000000000..256784c1c4878c0df5a3eb4c218a8c36144ca742 --- /dev/null +++ b/problems/kb1_044_average_pooling_1d.py @@ -0,0 +1,65 @@ +"""Task kb1_044_average_pooling_1d (KernelBench Level 1 #44, split=train, category=pooling, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_044_average_pooling_1d" +SOURCE_KB_ID = 44 +CATEGORY = "pooling" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs 1D Average Pooling. + """ + def __init__(self, kernel_size: int, stride: int = 1, padding: int = 0): + """ + Initializes the 1D Average Pooling layer. + + Args: + kernel_size (int): Size of the pooling window. + stride (int, optional): Stride of the pooling operation. Defaults to 1. + padding (int, optional): Padding applied to the input tensor. Defaults to 0. + """ + super(Model, self).__init__() + self.avg_pool = nn.AvgPool1d(kernel_size=kernel_size, stride=stride, padding=padding) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies 1D Average Pooling to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, input_length). + + Returns: + torch.Tensor: Output tensor with 1D Average Pooling applied, shape (batch_size, in_channels, output_length). + """ + return self.avg_pool(x) + +batch_size = 64 +in_channels = 128 +input_length = 65536 +kernel_size = 8 +stride = 1 +padding = 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +in_channels = 64 +input_length = 8192 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, input_length) + return [x] + +def get_init_inputs(): + return [kernel_size, stride, padding] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_045_average_pooling_2d.py b/problems/kb1_045_average_pooling_2d.py new file mode 100644 index 0000000000000000000000000000000000000000..01cdffdafabfdd24b3243926b5db3777be93bd10 --- /dev/null +++ b/problems/kb1_045_average_pooling_2d.py @@ -0,0 +1,65 @@ +"""Task kb1_045_average_pooling_2d (KernelBench Level 1 #45, split=train, category=pooling, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_045_average_pooling_2d" +SOURCE_KB_ID = 45 +CATEGORY = "pooling" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs 2D Average Pooling. + """ + def __init__(self, kernel_size: int, stride: int = None, padding: int = 0): + """ + Initializes the Average Pooling layer. + + Args: + kernel_size (int): Size of the pooling window. + stride (int, optional): Stride of the pooling operation. Defaults to None (same as kernel_size). + padding (int, optional): Padding applied to the input tensor. Defaults to 0. + """ + super(Model, self).__init__() + self.avg_pool = nn.AvgPool2d(kernel_size=kernel_size, stride=stride, padding=padding) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies 2D Average Pooling to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, channels, height, width). + + Returns: + torch.Tensor: Output tensor with Average Pooling applied. + """ + return self.avg_pool(x) + +batch_size = 16 +channels = 64 +height = 2048 +width = 2048 +kernel_size = 11 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +channels = 64 +height = 256 +width = 256 + +def get_inputs(): + x = torch.rand(batch_size, channels, height, width) + return [x] + +def get_init_inputs(): + return [kernel_size] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_046_average_pooling_3d.py b/problems/kb1_046_average_pooling_3d.py new file mode 100644 index 0000000000000000000000000000000000000000..cd447bef9a5abc641e6f19df13ae6944d6e2f0de --- /dev/null +++ b/problems/kb1_046_average_pooling_3d.py @@ -0,0 +1,69 @@ +"""Task kb1_046_average_pooling_3d (KernelBench Level 1 #46, split=train, category=pooling, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_046_average_pooling_3d" +SOURCE_KB_ID = 46 +CATEGORY = "pooling" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs 3D Average Pooling. + """ + def __init__(self, kernel_size: int, stride: int = None, padding: int = 0): + """ + Initializes the Average Pooling layer. + + Args: + kernel_size (int): Size of the kernel to apply pooling. + stride (int, optional): Stride of the pooling operation. Defaults to None, which uses the kernel size. + padding (int, optional): Padding to apply before pooling. Defaults to 0. + """ + super(Model, self).__init__() + self.avg_pool = nn.AvgPool3d(kernel_size=kernel_size, stride=stride, padding=padding) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Average Pooling to the input tensor. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, channels, depth, height, width). + + Returns: + torch.Tensor: Output tensor with Average Pooling applied, shape depends on kernel_size, stride and padding. + """ + return self.avg_pool(x) + +batch_size = 16 +channels = 32 +depth = 128 +height = 128 +width = 256 +kernel_size = 3 +stride = 2 +padding = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +channels = 16 +depth = 32 +height = 32 +width = 64 + +def get_inputs(): + x = torch.rand(batch_size, channels, depth, height, width) + return [x] + +def get_init_inputs(): + return [kernel_size, stride, padding] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_048_mean_reduction_over_a_dimension.py b/problems/kb1_048_mean_reduction_over_a_dimension.py new file mode 100644 index 0000000000000000000000000000000000000000..8cb76b7dc03d884694e3e01cfa228c738410fc12 --- /dev/null +++ b/problems/kb1_048_mean_reduction_over_a_dimension.py @@ -0,0 +1,60 @@ +"""Task kb1_048_mean_reduction_over_a_dimension (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_048_mean_reduction_over_a_dimension" +SOURCE_KB_ID = 48 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs mean reduction over a specific dimension. + """ + def __init__(self, dim: int): + """ + Initializes the model with the dimension to reduce over. + + Args: + dim (int): The dimension to reduce over. + """ + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Reduces the input tensor along the specified dimension by taking the mean. + + Args: + x (torch.Tensor): Input tensor of arbitrary shape. + + Returns: + torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed. + """ + return torch.mean(x, dim=self.dim) + +batch_size = 128 +dim1 = 4096 +dim2 = 4095 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 32 +dim1 = 512 +dim2 = 511 + +def get_inputs(): + x = torch.randn(batch_size, dim1, dim2) + return [x] + +def get_init_inputs(): + return [1] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_048_mean_reduction_over_a_dimension__bf16.py b/problems/kb1_048_mean_reduction_over_a_dimension__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..d938eea5b1f6b01e278ed4f2df68f963fc1b53aa --- /dev/null +++ b/problems/kb1_048_mean_reduction_over_a_dimension__bf16.py @@ -0,0 +1,60 @@ +"""Task kb1_048_mean_reduction_over_a_dimension__bf16 (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_048_mean_reduction_over_a_dimension__bf16" +SOURCE_KB_ID = 48 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs mean reduction over a specific dimension. + """ + def __init__(self, dim: int): + """ + Initializes the model with the dimension to reduce over. + + Args: + dim (int): The dimension to reduce over. + """ + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Reduces the input tensor along the specified dimension by taking the mean. + + Args: + x (torch.Tensor): Input tensor of arbitrary shape. + + Returns: + torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed. + """ + return torch.mean(x, dim=self.dim) + +batch_size = 128 +dim1 = 4096 +dim2 = 4095 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 32 +dim1 = 512 +dim2 = 511 + +def get_inputs(): + x = torch.randn(batch_size, dim1, dim2) + return [x] + +def get_init_inputs(): + return [1] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_048_mean_reduction_over_a_dimension__shape_large_reduce.py b/problems/kb1_048_mean_reduction_over_a_dimension__shape_large_reduce.py new file mode 100644 index 0000000000000000000000000000000000000000..a2d248170ac34a35e33ae0384aedf2310946d4dc --- /dev/null +++ b/problems/kb1_048_mean_reduction_over_a_dimension__shape_large_reduce.py @@ -0,0 +1,63 @@ +"""Task kb1_048_mean_reduction_over_a_dimension__shape_large_reduce (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=fp32, variant=shape_large_reduce).""" +PROBLEM_ID = "kb1_048_mean_reduction_over_a_dimension__shape_large_reduce" +SOURCE_KB_ID = 48 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_large_reduce" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs mean reduction over a specific dimension. + """ + def __init__(self, dim: int): + """ + Initializes the model with the dimension to reduce over. + + Args: + dim (int): The dimension to reduce over. + """ + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Reduces the input tensor along the specified dimension by taking the mean. + + Args: + x (torch.Tensor): Input tensor of arbitrary shape. + + Returns: + torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed. + """ + return torch.mean(x, dim=self.dim) + +batch_size = 128 +dim1 = 4096 +dim2 = 4095 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 32 +dim1 = 512 +dim2 = 511 +batch_size = 64 +dim1 = 256 +dim2 = 1023 + +def get_inputs(): + x = torch.randn(batch_size, dim1, dim2) + return [x] + +def get_init_inputs(): + return [1] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_049_max_reduction_over_a_dimension.py b/problems/kb1_049_max_reduction_over_a_dimension.py new file mode 100644 index 0000000000000000000000000000000000000000..27e4ae23e4e8d49f07c87e68f6f6b23f09bb5904 --- /dev/null +++ b/problems/kb1_049_max_reduction_over_a_dimension.py @@ -0,0 +1,60 @@ +"""Task kb1_049_max_reduction_over_a_dimension (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_049_max_reduction_over_a_dimension" +SOURCE_KB_ID = 49 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Max reduction over a specific dimension. + """ + def __init__(self, dim: int): + """ + Initializes the model with the dimension to reduce over. + + Args: + dim (int): The dimension to reduce over. + """ + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Max reduction over the specified dimension to the input tensor. + + Args: + x (torch.Tensor): Input tensor. + + Returns: + torch.Tensor: Output tensor after Max reduction over the specified dimension. + """ + return torch.max(x, dim=self.dim)[0] + +batch_size = 128 +dim1 = 4096 +dim2 = 4095 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 32 +dim1 = 512 +dim2 = 511 + +def get_inputs(): + x = torch.randn(batch_size, dim1, dim2) + return [x] + +def get_init_inputs(): + return [1] # Example, change to desired dimension +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_049_max_reduction_over_a_dimension__fp16.py b/problems/kb1_049_max_reduction_over_a_dimension__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..d460459d48444c5d628f170d52104d405a091c02 --- /dev/null +++ b/problems/kb1_049_max_reduction_over_a_dimension__fp16.py @@ -0,0 +1,60 @@ +"""Task kb1_049_max_reduction_over_a_dimension__fp16 (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_049_max_reduction_over_a_dimension__fp16" +SOURCE_KB_ID = 49 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Max reduction over a specific dimension. + """ + def __init__(self, dim: int): + """ + Initializes the model with the dimension to reduce over. + + Args: + dim (int): The dimension to reduce over. + """ + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Max reduction over the specified dimension to the input tensor. + + Args: + x (torch.Tensor): Input tensor. + + Returns: + torch.Tensor: Output tensor after Max reduction over the specified dimension. + """ + return torch.max(x, dim=self.dim)[0] + +batch_size = 128 +dim1 = 4096 +dim2 = 4095 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 32 +dim1 = 512 +dim2 = 511 + +def get_inputs(): + x = torch.randn(batch_size, dim1, dim2) + return [x] + +def get_init_inputs(): + return [1] # Example, change to desired dimension +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_049_max_reduction_over_a_dimension__shape_large_reduce.py b/problems/kb1_049_max_reduction_over_a_dimension__shape_large_reduce.py new file mode 100644 index 0000000000000000000000000000000000000000..79cb4d9fa2cf4ef495f236d5b5339b6b8efc4e93 --- /dev/null +++ b/problems/kb1_049_max_reduction_over_a_dimension__shape_large_reduce.py @@ -0,0 +1,63 @@ +"""Task kb1_049_max_reduction_over_a_dimension__shape_large_reduce (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp32, variant=shape_large_reduce).""" +PROBLEM_ID = "kb1_049_max_reduction_over_a_dimension__shape_large_reduce" +SOURCE_KB_ID = 49 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_large_reduce" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs Max reduction over a specific dimension. + """ + def __init__(self, dim: int): + """ + Initializes the model with the dimension to reduce over. + + Args: + dim (int): The dimension to reduce over. + """ + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies Max reduction over the specified dimension to the input tensor. + + Args: + x (torch.Tensor): Input tensor. + + Returns: + torch.Tensor: Output tensor after Max reduction over the specified dimension. + """ + return torch.max(x, dim=self.dim)[0] + +batch_size = 128 +dim1 = 4096 +dim2 = 4095 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 32 +dim1 = 512 +dim2 = 511 +batch_size = 64 +dim1 = 256 +dim2 = 1023 + +def get_inputs(): + x = torch.randn(batch_size, dim1, dim2) + return [x] + +def get_init_inputs(): + return [1] # Example, change to desired dimension +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_050_conv_standard_2d_square_input_square_kernel.py b/problems/kb1_050_conv_standard_2d_square_input_square_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..7aa8c3410f092419aeaf735c37e16de7326ff596 --- /dev/null +++ b/problems/kb1_050_conv_standard_2d_square_input_square_kernel.py @@ -0,0 +1,41 @@ +"""Task kb1_050_conv_standard_2d_square_input_square_kernel (KernelBench Level 1 #50, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_050_conv_standard_2d_square_input_square_kernel" +SOURCE_KB_ID = 50 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn +import torch.nn.functional as F + +class Model(nn.Module): + def __init__(self, num_classes=1000): + super(Model, self).__init__() + self.conv1 = nn.Conv2d(in_channels=3, out_channels=96, kernel_size=11, stride=4, padding=2) + + def forward(self, x): + x = self.conv1(x) + return x + +# Test code +batch_size = 256 +num_classes = 1000 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 32 + +def get_inputs(): + return [torch.rand(batch_size, 3, 224, 224)] + +def get_init_inputs(): + return [num_classes] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_052_argmin_over_a_dimension.py b/problems/kb1_052_argmin_over_a_dimension.py new file mode 100644 index 0000000000000000000000000000000000000000..4aea5006eafaa1f201bb9d8b92888026ef398078 --- /dev/null +++ b/problems/kb1_052_argmin_over_a_dimension.py @@ -0,0 +1,61 @@ +"""Task kb1_052_argmin_over_a_dimension (KernelBench Level 1 #52, split=train, category=reduction_scan, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_052_argmin_over_a_dimension" +SOURCE_KB_ID = 52 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that finds the index of the minimum value along a specified dimension. + """ + def __init__(self, dim: int): + """ + Initializes the model with the dimension to perform argmin on. + + Args: + dim (int): Dimension along which to find the minimum value. + """ + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Finds the index of the minimum value along the specified dimension. + + Args: + x (torch.Tensor): Input tensor. + + Returns: + torch.Tensor: Tensor containing the indices of the minimum values along the specified dimension. + """ + return torch.argmin(x, dim=self.dim) + +batch_size = 128 +dim1 = 4096 +dim2 = 4095 +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 32 +dim1 = 512 +dim2 = 511 + +def get_inputs(): + x = torch.randn(batch_size, dim1, dim2) + return [x] + +def get_init_inputs(): + return [dim] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_053_min_reduction_over_a_dimension.py b/problems/kb1_053_min_reduction_over_a_dimension.py new file mode 100644 index 0000000000000000000000000000000000000000..c219bf8348313955de1447b6f4f7d69466e36b8a --- /dev/null +++ b/problems/kb1_053_min_reduction_over_a_dimension.py @@ -0,0 +1,60 @@ +"""Task kb1_053_min_reduction_over_a_dimension (KernelBench Level 1 #53, split=train, category=reduction_scan, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_053_min_reduction_over_a_dimension" +SOURCE_KB_ID = 53 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs min reduction over a specific dimension. + """ + def __init__(self, dim: int): + """ + Initializes the model with the dimension to reduce over. + + Args: + dim (int): The dimension to reduce over. + """ + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies min reduction over the specified dimension to the input tensor. + + Args: + x (torch.Tensor): Input tensor. + + Returns: + torch.Tensor: Output tensor after min reduction over the specified dimension. + """ + return torch.min(x, dim=self.dim)[0] + +batch_size = 128 +dim1 = 4096 +dim2 = 4095 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 32 +dim1 = 512 +dim2 = 511 + +def get_inputs(): + x = torch.randn(batch_size, dim1, dim2) + return [x] + +def get_init_inputs(): + return [1] # Example, change to desired dimension +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_053_min_reduction_over_a_dimension__shape_nonpow2.py b/problems/kb1_053_min_reduction_over_a_dimension__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..0e5eb6b18fe1cae4837221dbf2eee8d1bef3ec4f --- /dev/null +++ b/problems/kb1_053_min_reduction_over_a_dimension__shape_nonpow2.py @@ -0,0 +1,63 @@ +"""Task kb1_053_min_reduction_over_a_dimension__shape_nonpow2 (KernelBench Level 1 #53, split=train, category=reduction_scan, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_053_min_reduction_over_a_dimension__shape_nonpow2" +SOURCE_KB_ID = 53 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Simple model that performs min reduction over a specific dimension. + """ + def __init__(self, dim: int): + """ + Initializes the model with the dimension to reduce over. + + Args: + dim (int): The dimension to reduce over. + """ + super(Model, self).__init__() + self.dim = dim + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Applies min reduction over the specified dimension to the input tensor. + + Args: + x (torch.Tensor): Input tensor. + + Returns: + torch.Tensor: Output tensor after min reduction over the specified dimension. + """ + return torch.min(x, dim=self.dim)[0] + +batch_size = 128 +dim1 = 4096 +dim2 = 4095 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 32 +dim1 = 512 +dim2 = 511 +batch_size = 48 +dim1 = 384 +dim2 = 768 + +def get_inputs(): + x = torch.randn(batch_size, dim1, dim2) + return [x] + +def get_init_inputs(): + return [1] # Example, change to desired dimension +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_054_conv_standard_3d_square_input_square_kernel.py b/problems/kb1_054_conv_standard_3d_square_input_square_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..81f797eebe036239527f5f238669b7b3a0c685a8 --- /dev/null +++ b/problems/kb1_054_conv_standard_3d_square_input_square_kernel.py @@ -0,0 +1,70 @@ +"""Task kb1_054_conv_standard_3d_square_input_square_kernel (KernelBench Level 1 #54, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_054_conv_standard_3d_square_input_square_kernel" +SOURCE_KB_ID = 54 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a standard 3D convolution operation with square input and square kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv3d = nn.Conv3d(in_channels, out_channels, (kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 3D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, width, height). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, width_out, height_out). + """ + return self.conv3d(x) + +# Test code +batch_size = 16 +in_channels = 3 +out_channels = 64 +kernel_size = 3 +depth = 64 +width = 64 +height = 64 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +depth = 32 +width = 32 +height = 32 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, depth, width, height) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_055_conv_standard_2d_asymmetric_input_square_kernel.py b/problems/kb1_055_conv_standard_2d_asymmetric_input_square_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..3551165539f389c7676f35d46f9ace42f83319cf --- /dev/null +++ b/problems/kb1_055_conv_standard_2d_asymmetric_input_square_kernel.py @@ -0,0 +1,72 @@ +"""Task kb1_055_conv_standard_2d_asymmetric_input_square_kernel (KernelBench Level 1 #55, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_055_conv_standard_2d_asymmetric_input_square_kernel" +SOURCE_KB_ID = 55 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a standard 2D convolution operation with an asymmetric input and a square kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv2d(x) + +# Test code +batch_size = 8 +# smaller spatial dims +height = 512 +width = 1024 +in_channels = 64 # increased channels +out_channels = 128 +kernel_size = 3 +# asymmetric input: make width considerably larger than height + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +height = 128 +width = 256 +in_channels = 32 +out_channels = 64 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16.py b/problems/kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..06167d64f187d46d14e4ea8252d7b131fcd69152 --- /dev/null +++ b/problems/kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16.py @@ -0,0 +1,72 @@ +"""Task kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16 (KernelBench Level 1 #55, split=train, category=convolution, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16" +SOURCE_KB_ID = 55 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a standard 2D convolution operation with an asymmetric input and a square kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv2d(x) + +# Test code +batch_size = 8 +# smaller spatial dims +height = 512 +width = 1024 +in_channels = 64 # increased channels +out_channels = 128 +kernel_size = 3 +# asymmetric input: make width considerably larger than height + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +height = 128 +width = 256 +in_channels = 32 +out_channels = 64 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel.py b/problems/kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..079bff57081c8c2f42544ebf2058694cb4644c76 --- /dev/null +++ b/problems/kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel.py @@ -0,0 +1,70 @@ +"""Task kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #56, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel" +SOURCE_KB_ID = 56 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a standard 2D convolution operation with asymmetric input and kernel sizes. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Tuple of two integers representing the height and width of the convolution kernel. + stride (tuple, optional): Tuple of two integers representing the stride in the height and width dimensions. Defaults to (1, 1). + padding (tuple, optional): Tuple of two integers representing the padding in the height and width dimensions. Defaults to (0, 0). + dilation (tuple, optional): Tuple of two integers representing the dilation in the height and width dimensions. Defaults to (1, 1). + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv2d(x) + +# Test code +batch_size = 8 +in_channels = 64 +out_channels = 128 +kernel_size = (5, 7) +height = 512 +width = 256 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 32 +out_channels = 64 +height = 128 +width = 64 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_057_conv_transposed_2d_square_input_square_kernel.py b/problems/kb1_057_conv_transposed_2d_square_input_square_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..37fbda62287f97ea2497e1c46072cdc05169c9ef --- /dev/null +++ b/problems/kb1_057_conv_transposed_2d_square_input_square_kernel.py @@ -0,0 +1,71 @@ +"""Task kb1_057_conv_transposed_2d_square_input_square_kernel (KernelBench Level 1 #57, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_057_conv_transposed_2d_square_input_square_kernel" +SOURCE_KB_ID = 57 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 2D convolution with square input and square kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv_transpose2d(x) + +# Test code +batch_size = 8 +in_channels = 64 # double channels for heavier compute +out_channels = 64 +kernel_size = 3 +# larger square input +height = 1024 +width = 1024 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 32 +out_channels = 32 +height = 256 +width = 256 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel.py b/problems/kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..1c52a55dbbc1b483611f5731e1a094783ec0b1f9 --- /dev/null +++ b/problems/kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel.py @@ -0,0 +1,72 @@ +"""Task kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #58, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel" +SOURCE_KB_ID = 58 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 3D convolution operation with asymmetric input and kernel sizes. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Tuple of 3 integers representing the kernel size in the form (depth, height, width). + stride (tuple, optional): Tuple of 3 integers representing the stride in the form (depth, height, width). Defaults to (1, 1, 1). + padding (tuple, optional): Tuple of 3 integers representing the padding in the form (depth, height, width). Defaults to (0, 0, 0). + output_padding (tuple, optional): Tuple of 3 integers representing the output padding in the form (depth, height, width). Defaults to (0, 0, 0). + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 3D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth_in, height_in, width_in). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out). + """ + return self.conv_transpose3d(x) + +# Test code +batch_size = 16 +in_channels = 32 +out_channels = 16 +kernel_size = (3, 5, 7) # Asymmetric kernel size +depth_in = 16 +height_in = 32 +width_in = 64 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 16 +out_channels = 16 +depth_in = 8 +height_in = 16 +width_in = 32 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, depth_in, height_in, width_in) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_059_conv_standard_3d_asymmetric_input_square_kernel.py b/problems/kb1_059_conv_standard_3d_asymmetric_input_square_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..966b85592f01d78a5c6ecca6bf8422e5cedbdb33 --- /dev/null +++ b/problems/kb1_059_conv_standard_3d_asymmetric_input_square_kernel.py @@ -0,0 +1,70 @@ +"""Task kb1_059_conv_standard_3d_asymmetric_input_square_kernel (KernelBench Level 1 #59, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_059_conv_standard_3d_asymmetric_input_square_kernel" +SOURCE_KB_ID = 59 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a standard 3D convolution operation with an asymmetric input and a square kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel (kernel_size x kernel_size). + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv3d = nn.Conv3d(in_channels, out_channels, (kernel_size, kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 3D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width, depth). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out, depth_out). + """ + return self.conv3d(x) + +# Test code +batch_size = 16 +in_channels = 3 +out_channels = 64 +kernel_size = 3 +width = 256 +height = 256 +depth = 10 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +width = 64 +height = 64 +depth = 8 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width, depth) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_060_conv_standard_3d_square_input_asymmetric_kernel.py b/problems/kb1_060_conv_standard_3d_square_input_asymmetric_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..4b9e6378c044839d457d76c4d6903ed3b3a76a91 --- /dev/null +++ b/problems/kb1_060_conv_standard_3d_square_input_asymmetric_kernel.py @@ -0,0 +1,70 @@ +"""Task kb1_060_conv_standard_3d_square_input_asymmetric_kernel (KernelBench Level 1 #60, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_060_conv_standard_3d_square_input_asymmetric_kernel" +SOURCE_KB_ID = 60 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a standard 3D convolution operation with a square input and an asymmetric kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Size of the convolution kernel (kernel_width, kernel_height, kernel_depth). + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int or tuple, optional): Padding applied to the input. Defaults to 0. + dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv3d = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 3D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, width, height, depth). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, width_out, height_out, depth_out). + """ + return self.conv3d(x) + +# Test code +batch_size = 16 +in_channels = 3 +out_channels = 64 +kernel_size = (3, 5, 7) # Asymmetric kernel +width = 64 +height = 64 +depth = 64 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +width = 32 +height = 32 +depth = 32 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, width, height, depth) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_061_conv_transposed_3d_square_input_square_kernel.py b/problems/kb1_061_conv_transposed_3d_square_input_square_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..ee357c7a1ed37622fa5014074f94dc53e619ec71 --- /dev/null +++ b/problems/kb1_061_conv_transposed_3d_square_input_square_kernel.py @@ -0,0 +1,72 @@ +"""Task kb1_061_conv_transposed_3d_square_input_square_kernel (KernelBench Level 1 #61, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_061_conv_transposed_3d_square_input_square_kernel" +SOURCE_KB_ID = 61 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 3D convolution with square input and square kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 3D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out). + """ + return self.conv_transpose3d(x) + +# Test code +batch_size = 8 +in_channels = 48 +out_channels = 48 +kernel_size = 3 +depth = 64 +height = 64 +width = 64 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2 +in_channels = 16 +out_channels = 16 +depth = 16 +height = 16 +width = 16 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, depth, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_062_conv_standard_2d_square_input_asymmetric_kernel.py b/problems/kb1_062_conv_standard_2d_square_input_asymmetric_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..77f44ec49c73d7ae3c0f36e406064c3fb1cff37f --- /dev/null +++ b/problems/kb1_062_conv_standard_2d_square_input_asymmetric_kernel.py @@ -0,0 +1,70 @@ +"""Task kb1_062_conv_standard_2d_square_input_asymmetric_kernel (KernelBench Level 1 #62, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_062_conv_standard_2d_square_input_asymmetric_kernel" +SOURCE_KB_ID = 62 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a standard 2D convolution operation with a square input and an asymmetric kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Size of the convolution kernel (height, width). + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int or tuple, optional): Padding applied to the input. Defaults to 0. + dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv2d(x) + +# Test code +batch_size = 8 +in_channels = 32 +out_channels = 64 +kernel_size = (5, 9) +width = 512 +height = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 32 +out_channels = 64 +width = 128 +height = 128 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_064_conv_transposed_1d.py b/problems/kb1_064_conv_transposed_1d.py new file mode 100644 index 0000000000000000000000000000000000000000..13339a45216653490e103c3142e618098a8d86a1 --- /dev/null +++ b/problems/kb1_064_conv_transposed_1d.py @@ -0,0 +1,69 @@ +"""Task kb1_064_conv_transposed_1d (KernelBench Level 1 #64, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_064_conv_transposed_1d" +SOURCE_KB_ID = 64 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 1D convolution operation. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 1D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out). + """ + return self.conv1d_transpose(x) + +# Test code +batch_size = 64 +in_channels = 128 +out_channels = 128 +kernel_size = 3 +# much larger signal length for heavier workload +length = 65536 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +in_channels = 64 +out_channels = 64 +length = 8192 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, length) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_064_conv_transposed_1d__fp16.py b/problems/kb1_064_conv_transposed_1d__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..6e8b55a9bbb701d6d7a0a5050570de5fda81cf03 --- /dev/null +++ b/problems/kb1_064_conv_transposed_1d__fp16.py @@ -0,0 +1,69 @@ +"""Task kb1_064_conv_transposed_1d__fp16 (KernelBench Level 1 #64, split=train, category=convolution, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_064_conv_transposed_1d__fp16" +SOURCE_KB_ID = 64 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 1D convolution operation. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 1D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out). + """ + return self.conv1d_transpose(x) + +# Test code +batch_size = 64 +in_channels = 128 +out_channels = 128 +kernel_size = 3 +# much larger signal length for heavier workload +length = 65536 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +in_channels = 64 +out_channels = 64 +length = 8192 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, length) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_065_conv_transposed_2d_square_input_asymmetric_kernel.py b/problems/kb1_065_conv_transposed_2d_square_input_asymmetric_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..dce8eb713eab41fff963d7f30e2f5a1f65960932 --- /dev/null +++ b/problems/kb1_065_conv_transposed_2d_square_input_asymmetric_kernel.py @@ -0,0 +1,70 @@ +"""Task kb1_065_conv_transposed_2d_square_input_asymmetric_kernel (KernelBench Level 1 #65, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_065_conv_transposed_2d_square_input_asymmetric_kernel" +SOURCE_KB_ID = 65 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 2D convolution with a square input and an asymmetric kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Size of the convolution kernel (height, width). + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int or tuple, optional): Padding applied to the input. Defaults to 0. + output_padding (int or tuple, optional): Additional size added to one side of the output shape. Defaults to 0. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv_transpose2d(x) + +# Test code +batch_size = 8 +in_channels = 64 +out_channels = 64 +kernel_size = (3, 7) # larger asymmetric kernel +width = 512 +height = 512 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 32 +out_channels = 32 +width = 128 +height = 128 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel.py b/problems/kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..d37feec149a08debf5bc999f3f5b5771818fb07b --- /dev/null +++ b/problems/kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel.py @@ -0,0 +1,70 @@ +"""Task kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #66, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel" +SOURCE_KB_ID = 66 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a standard 3D convolution operation with asymmetric input and kernel sizes. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Size of the convolution kernel in the form (kernel_size_d, kernel_size_h, kernel_size_w). + stride (tuple, optional): Stride of the convolution in the form (stride_d, stride_h, stride_w). Defaults to (1, 1, 1). + padding (tuple, optional): Padding applied to the input in the form (padding_d, padding_h, padding_w). Defaults to (0, 0, 0). + dilation (tuple, optional): Spacing between kernel elements in the form (dilation_d, dilation_h, dilation_w). Defaults to (1, 1, 1). + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), dilation: tuple = (1, 1, 1), groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv3d = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 3D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out). + """ + return self.conv3d(x) + +# Test code +batch_size = 8 +in_channels = 3 +out_channels = 64 +kernel_size = (3, 5, 7) # Asymmetric kernel size +depth = 16 +height = 128 +width = 128 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +depth = 8 +height = 64 +width = 64 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, depth, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_068_conv_transposed_3d_square_input_asymmetric_kernel.py b/problems/kb1_068_conv_transposed_3d_square_input_asymmetric_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..3653a2539915318f3188833e3f2d428161e67140 --- /dev/null +++ b/problems/kb1_068_conv_transposed_3d_square_input_asymmetric_kernel.py @@ -0,0 +1,75 @@ +"""Task kb1_068_conv_transposed_3d_square_input_asymmetric_kernel (KernelBench Level 1 #68, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_068_conv_transposed_3d_square_input_asymmetric_kernel" +SOURCE_KB_ID = 68 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 3D convolution with a square input and an asymmetric kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Size of the convolution kernel (kernel_depth, kernel_width, kernel_height), + where kernel_width == kernel_height. + stride (tuple, optional): Stride of the convolution. Defaults to (1, 1, 1). + padding (tuple, optional): Padding applied to the input. Defaults to (0, 0, 0). + output_padding (tuple, optional): Additional size added to one side of the output shape. Defaults to (0, 0, 0). + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 3D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, width, height). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, width_out, height_out). + """ + return self.conv_transpose3d(x) + +# Test code +batch_size = 16 +in_channels = 32 +out_channels = 64 +kernel_depth = 3 +kernel_width = 5 +kernel_height = 5 +depth = 64 +width = 64 +height = 64 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 16 +out_channels = 32 +depth = 16 +width = 16 +height = 16 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, depth, width, height) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, (kernel_depth, kernel_width, kernel_height)] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel.py b/problems/kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..e1a15f34ed8b1a3ee5e6cd4df1724feee446f26e --- /dev/null +++ b/problems/kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel.py @@ -0,0 +1,71 @@ +"""Task kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #69, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel" +SOURCE_KB_ID = 69 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 2D convolution operation with asymmetric input and kernel size. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Tuple of integers representing the kernel size (height, width). + stride (tuple, optional): Tuple of integers representing the stride of the convolution. Defaults to (1, 1). + padding (tuple, optional): Tuple of integers representing the padding applied to the input. Defaults to (0, 0). + output_padding (tuple, optional): Tuple of integers representing the additional size added to one side of the output shape. Defaults to (0, 0). + dilation (tuple, optional): Tuple of integers representing the spacing between kernel elements. Defaults to (1, 1). + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), output_padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv_transpose2d(x) + +# Test code +batch_size = 64 +in_channels = 64 +out_channels = 128 +kernel_size = (3, 5) +height_in = 128 +width_in = 256 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 8 +in_channels = 32 +out_channels = 64 +height_in = 64 +width_in = 128 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height_in, width_in) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_070_conv_transposed_3d_asymmetric_input_square_kernel.py b/problems/kb1_070_conv_transposed_3d_asymmetric_input_square_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..f65acfa2cd83156516a31820553c52a76e25bbc2 --- /dev/null +++ b/problems/kb1_070_conv_transposed_3d_asymmetric_input_square_kernel.py @@ -0,0 +1,77 @@ +"""Task kb1_070_conv_transposed_3d_asymmetric_input_square_kernel (KernelBench Level 1 #70, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_070_conv_transposed_3d_asymmetric_input_square_kernel" +SOURCE_KB_ID = 70 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 3D convolution operation with asymmetric input and a square kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int or tuple, optional): Stride of the convolution. Defaults to 1. + padding (int or tuple, optional): Padding applied to the input. Defaults to 0. + output_padding (int or tuple, optional): Additional size added to one side of each dimension in the output shape. + Defaults to 0. + dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, + dilation: int = 1, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, (kernel_size, kernel_size, kernel_size), + stride=stride, padding=padding, output_padding=output_padding, + dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 3D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out). + """ + return self.conv_transpose3d(x) + +# Test code +batch_size = 8 +in_channels = 48 +out_channels = 24 +kernel_size = 3 +depth = 96 +height = 96 +width = 96 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2 +in_channels = 16 +out_channels = 16 +depth = 24 +height = 24 +width = 24 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, depth, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_071_conv_transposed_2d_asymmetric_input_square_kernel.py b/problems/kb1_071_conv_transposed_2d_asymmetric_input_square_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..5e57f12765fabf6e94f008bdaf81181b3cb0a0ce --- /dev/null +++ b/problems/kb1_071_conv_transposed_2d_asymmetric_input_square_kernel.py @@ -0,0 +1,71 @@ +"""Task kb1_071_conv_transposed_2d_asymmetric_input_square_kernel (KernelBench Level 1 #71, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_071_conv_transposed_2d_asymmetric_input_square_kernel" +SOURCE_KB_ID = 71 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 2D convolution with asymmetric input and a square kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv_transpose2d(x) + +# Test code +batch_size = 8 +in_channels = 32 +out_channels = 32 +kernel_size = 3 +# large asymmetric input +height_in = 512 +width_in = 1024 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 32 +out_channels = 32 +height_in = 128 +width_in = 256 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height_in, width_in) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped.py b/problems/kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped.py new file mode 100644 index 0000000000000000000000000000000000000000..d5ca842442799561fe5b12ade278c58255882181 --- /dev/null +++ b/problems/kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped.py @@ -0,0 +1,76 @@ +"""Task kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped (KernelBench Level 1 #72, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped" +SOURCE_KB_ID = 72 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a 3D transposed convolution operation with asymmetric input and kernel, and optional stride. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple of ints): Size of the convolution kernel in the form (kernel_size_depth, kernel_size_height, kernel_size_width). + stride (tuple of ints, optional): Stride of the convolution in the form (stride_depth, stride_height, stride_width). Defaults to (1, 1, 1). + padding (tuple of ints, optional): Padding applied to the input in the form (padding_depth, padding_height, padding_width). Defaults to (0, 0, 0). + output_padding (tuple of ints, optional): Additional size added to one side of the output shape. Defaults to (0, 0, 0). + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 3D transposed convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out). + """ + return self.conv_transpose3d(x) + +# Test code +batch_size = 8 +in_channels = 32 +out_channels = 32 +kernel_size = (3, 5, 7) +depth = 12 +height = 24 +width = 48 +stride = (2, 2, 2) +padding = (1, 2, 3) +output_padding = (1, 1, 1) +groups = 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2 +in_channels = 16 +out_channels = 16 +depth = 8 +height = 12 +width = 24 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, depth, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding, output_padding, groups] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped.py b/problems/kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped.py new file mode 100644 index 0000000000000000000000000000000000000000..8cdc41bb4867e1b32f14220058ec87bef247b9ea --- /dev/null +++ b/problems/kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped.py @@ -0,0 +1,75 @@ +"""Task kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped (KernelBench Level 1 #73, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped" +SOURCE_KB_ID = 73 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a 3D transposed convolution operation with asymmetric input and square kernel. + The input is padded before the convolution. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 3D transposed convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out). + """ + return self.conv_transpose3d(x) + +# Test code +batch_size = 4 +in_channels = 32 +out_channels = 32 +kernel_size = 3 +depth = 32 +height = 64 +width = 128 +stride = 2 +padding = 1 +groups = 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2 +in_channels = 16 +out_channels = 16 +depth = 12 +height = 24 +width = 32 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, depth, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding, groups] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_074_conv_transposed_1d_dilated.py b/problems/kb1_074_conv_transposed_1d_dilated.py new file mode 100644 index 0000000000000000000000000000000000000000..600d8df36a17fca2c0a783fe7c3fb121548d40bd --- /dev/null +++ b/problems/kb1_074_conv_transposed_1d_dilated.py @@ -0,0 +1,70 @@ +"""Task kb1_074_conv_transposed_1d_dilated (KernelBench Level 1 #74, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_074_conv_transposed_1d_dilated" +SOURCE_KB_ID = 74 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 1D convolution operation with square input and asymmetric kernel, optionally with dilation. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 1D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out). + """ + return self.conv1d_transpose(x) + +# Test code +batch_size = 32 +in_channels = 32 +out_channels = 64 +kernel_size = 5 +length = 131072 +stride = 1 +padding = 0 +dilation = 3 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +in_channels = 32 +out_channels = 64 +length = 16384 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, length) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding, dilation] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated.py b/problems/kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated.py new file mode 100644 index 0000000000000000000000000000000000000000..311b4a7e3444f5e5f05aa60e924b9144c0e87b37 --- /dev/null +++ b/problems/kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated.py @@ -0,0 +1,75 @@ +"""Task kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated (KernelBench Level 1 #75, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated" +SOURCE_KB_ID = 75 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a 2D transposed convolution operation with asymmetric input, asymmetric kernel, + grouped, padded, and dilated. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Size of the convolution kernel (height, width). + stride (tuple, optional): Stride of the convolution (height, width). Defaults to (1, 1). + padding (tuple, optional): Padding applied to the input (height, width). Defaults to (0, 0). + dilation (tuple, optional): Spacing between kernel elements (height, width). Defaults to (1, 1). + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 2D transposed convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv_transpose2d(x) + +# Test code +batch_size = 16 +in_channels = 32 +out_channels = 64 +kernel_size = (3, 5) +height = 128 +width = 256 +stride = (2, 3) +padding = (1, 2) +dilation = (2, 1) +groups = 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 32 +out_channels = 64 +height = 64 +width = 64 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding, dilation, groups] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_076_conv_standard_1d_dilated_strided.py b/problems/kb1_076_conv_standard_1d_dilated_strided.py new file mode 100644 index 0000000000000000000000000000000000000000..6f4fb914af26d4af7e97b831e79995084c2cb896 --- /dev/null +++ b/problems/kb1_076_conv_standard_1d_dilated_strided.py @@ -0,0 +1,69 @@ +"""Task kb1_076_conv_standard_1d_dilated_strided (KernelBench Level 1 #76, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_076_conv_standard_1d_dilated_strided" +SOURCE_KB_ID = 76 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a standard 1D convolution operation with asymmetric input and a square kernel, potentially dilated and strided. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, dilation: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv1d = nn.Conv1d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 1D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out). + """ + return self.conv1d(x) + +# Test code +batch_size = 64 +in_channels = 64 +out_channels = 128 +kernel_size = 3 +# longer signal +length = 524280 +stride = 3 +dilation = 4 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +in_channels = 64 +out_channels = 128 +length = 32768 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, length) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, dilation] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided.py b/problems/kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided.py new file mode 100644 index 0000000000000000000000000000000000000000..d8abae72c2e4a3ee0a775a1587e1167d4da75679 --- /dev/null +++ b/problems/kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided.py @@ -0,0 +1,75 @@ +"""Task kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided (KernelBench Level 1 #77, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided" +SOURCE_KB_ID = 77 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a 3D transposed convolution operation with square input and square kernel, + and supports padding, dilation, and stride. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the convolution kernel (square kernel, so only one value needed). + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 3D transposed convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out). + """ + return self.conv_transpose3d(x) + +# Test code +batch_size = 16 +in_channels = 32 +out_channels = 64 +kernel_size = 3 +depth = 16 +height = 32 +width = 32 +stride = 2 +padding = 1 +dilation = 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2 +in_channels = 16 +out_channels = 32 +depth = 8 +height = 16 +width = 16 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, depth, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding, dilation] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded.py b/problems/kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded.py new file mode 100644 index 0000000000000000000000000000000000000000..098ada7994644541b66eaf8da73810c1caf32236 --- /dev/null +++ b/problems/kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded.py @@ -0,0 +1,70 @@ +"""Task kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded (KernelBench Level 1 #78, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded" +SOURCE_KB_ID = 78 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a 2D transposed convolution operation with asymmetric input and kernel, with optional padding. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Size of the convolution kernel (height, width). + stride (tuple, optional): Stride of the convolution (height, width). Defaults to (1, 1). + padding (tuple, optional): Padding applied to the input (height, width). Defaults to (0, 0). + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), bias: bool = False): + super(Model, self).__init__() + self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 2D transposed convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv_transpose2d(x) + +# Test code +batch_size = 8 +in_channels = 32 +out_channels = 32 +kernel_size = (3, 7) +height = 512 +width = 1024 +stride = (1, 1) +padding = (1, 3) + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 32 +out_channels = 32 +height = 128 +width = 256 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated.py b/problems/kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated.py new file mode 100644 index 0000000000000000000000000000000000000000..fb1f61a0a03bf7b777afa45aff4b04e7e8ada047 --- /dev/null +++ b/problems/kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated.py @@ -0,0 +1,72 @@ +"""Task kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated (KernelBench Level 1 #79, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated" +SOURCE_KB_ID = 79 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a transposed 1D convolution operation with asymmetric input and square kernel. + Supports padding, striding, and dilation. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the transposed 1D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out). + """ + return self.conv1d_transpose(x) + +# Test code +batch_size = 16 +in_channels = 32 +out_channels = 64 +kernel_size = 3 +# long sequence +length = 131072 +stride = 2 +padding = 1 +dilation = 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +in_channels = 32 +out_channels = 64 +length = 16384 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, length) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding, dilation] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded.py b/problems/kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded.py new file mode 100644 index 0000000000000000000000000000000000000000..576d210d777b35c5dad81ac68992f1b648e2c2c8 --- /dev/null +++ b/problems/kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded.py @@ -0,0 +1,72 @@ +"""Task kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded (KernelBench Level 1 #80, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded" +SOURCE_KB_ID = 80 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a standard 2D convolution operation with square input and asymmetric kernel, with dilation and padding. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (tuple): Size of the convolution kernel (height, width). + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (tuple, optional): Padding applied to the input (top/bottom, left/right). Defaults to (0, 0). + dilation (tuple, optional): Spacing between kernel elements (height, width). Defaults to (1, 1). + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: tuple = (0, 0), dilation: tuple = (1, 1), bias: bool = False): + super(Model, self).__init__() + self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv2d(x) + +# Test code +batch_size = 8 +in_channels = 32 +out_channels = 64 +kernel_size = (5, 9) +width = 512 +height = 512 +stride = 1 +padding = (2, 4) +dilation = (2, 3) + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 32 +out_channels = 64 +width = 128 +height = 128 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding, dilation] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided.py b/problems/kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided.py new file mode 100644 index 0000000000000000000000000000000000000000..7b22259572596ea0afab01eb8ff954ed5b206121 --- /dev/null +++ b/problems/kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided.py @@ -0,0 +1,73 @@ +"""Task kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided (KernelBench Level 1 #81, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided" +SOURCE_KB_ID = 81 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a 2D transposed convolution operation with asymmetric input and square kernel, supporting dilation, padding, and stride. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the convolution kernel (square, e.g., 3 for a 3x3 kernel). + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the 2D transposed convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv_transpose2d(x) + + +# Test code +batch_size = 16 +in_channels = 32 +out_channels = 64 +kernel_size = 3 +height_in = 64 +width_in = 128 +stride = 5 +padding = 1 +dilation = 2 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 4 +in_channels = 32 +out_channels = 64 +height_in = 32 +width_in = 64 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height_in, width_in) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding, dilation] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel.py b/problems/kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..cb5151a0bff284c3fb89dea694ec76379c49fd85 --- /dev/null +++ b/problems/kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel.py @@ -0,0 +1,69 @@ +"""Task kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel (KernelBench Level 1 #83, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel" +SOURCE_KB_ID = 83 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a depthwise 2D convolution with a square input and an asymmetric kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + kernel_size (int): Size of the convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv2d = nn.Conv2d(in_channels, in_channels, kernel_size=(kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the depthwise 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, in_channels, height_out, width_out). + """ + return self.conv2d(x) + +# Test code +batch_size = 64 +in_channels = 8 +kernel_size = 3 +width = 512 +height = 512 +stride = 1 +padding = 0 +dilation = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 16 +in_channels = 16 +width = 256 +height = 256 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, kernel_size, stride, padding, dilation] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel.py b/problems/kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..e0c59a08a9f6051902a97fe92e1472d9d544a3b3 --- /dev/null +++ b/problems/kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel.py @@ -0,0 +1,70 @@ +"""Task kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel (KernelBench Level 1 #84, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel" +SOURCE_KB_ID = 84 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a depthwise 2D convolution with asymmetric input and square kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the square convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, bias: bool = False): + super(Model, self).__init__() + self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size), stride=stride, padding=padding, groups=in_channels, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the depthwise 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv2d(x) + +# Test code +batch_size = 64 +in_channels = 128 +out_channels = 128 +kernel_size = 3 +width_in = 512 +height_in = 256 +stride = 1 +padding = 0 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 8 +in_channels = 64 +out_channels = 64 +width_in = 256 +height_in = 128 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height_in, width_in) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel.py b/problems/kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..4769d93b7fc0d7852aef90762219d067d0fa92c9 --- /dev/null +++ b/problems/kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel.py @@ -0,0 +1,83 @@ +"""Task kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #85, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel" +SOURCE_KB_ID = 85 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a depthwise 2D convolution with asymmetric input and asymmetric kernel. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size_h (int): Height of the convolution kernel. + kernel_size_w (int): Width of the convolution kernel. + stride_h (int, optional): Stride of the convolution in height dimension. Defaults to 1. + stride_w (int, optional): Stride of the convolution in width dimension. Defaults to 1. + padding_h (int, optional): Padding applied to the input in height dimension. Defaults to 0. + padding_w (int, optional): Padding applied to the input in width dimension. Defaults to 0. + dilation_h (int, optional): Spacing between kernel elements in height dimension. Defaults to 1. + dilation_w (int, optional): Spacing between kernel elements in width dimension. Defaults to 1. + groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size_h: int, kernel_size_w: int, stride_h: int = 1, stride_w: int = 1, padding_h: int = 0, padding_w: int = 0, dilation_h: int = 1, dilation_w: int = 1, groups: int = 1, bias: bool = False): + super(Model, self).__init__() + self.conv2d = nn.Conv2d(in_channels, in_channels, (kernel_size_h, kernel_size_w), stride=(stride_h, stride_w), padding=(padding_h, padding_w), dilation=(dilation_h, dilation_w), groups=in_channels, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the depthwise 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + return self.conv2d(x) + +# Test code +batch_size = 32 +in_channels = 128 +out_channels = 128 +kernel_size_h = 3 +kernel_size_w = 7 +width = 256 +height = 128 +stride_h = 1 +stride_w = 1 +padding_h = 0 +padding_w = 0 +dilation_h = 1 +dilation_w = 1 +groups = in_channels + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 8 +in_channels = 64 +out_channels = 64 +groups = in_channels +width = 128 +height = 128 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size_h, kernel_size_w, stride_h, stride_w, padding_h, padding_w, dilation_h, dilation_w, groups] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_086_conv_depthwise_separable_2d.py b/problems/kb1_086_conv_depthwise_separable_2d.py new file mode 100644 index 0000000000000000000000000000000000000000..f25eaa765504b39b26d92f74ca9c956e9e33bc73 --- /dev/null +++ b/problems/kb1_086_conv_depthwise_separable_2d.py @@ -0,0 +1,75 @@ +"""Task kb1_086_conv_depthwise_separable_2d (KernelBench Level 1 #86, split=train, category=convolution, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_086_conv_depthwise_separable_2d" +SOURCE_KB_ID = 86 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a depthwise-separable 2D convolution operation. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False): + super(Model, self).__init__() + self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias) + self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the depthwise-separable 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + x = self.depthwise(x) + x = self.pointwise(x) + return x + +# Test code +batch_size = 16 +in_channels = 64 +out_channels = 128 +kernel_size = 3 +width = 512 +height = 512 +stride = 1 +padding = 1 +dilation = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 8 +in_channels = 64 +out_channels = 128 +width = 128 +height = 128 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding, dilation] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_086_conv_depthwise_separable_2d__fp16.py b/problems/kb1_086_conv_depthwise_separable_2d__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..7989fd68a5353f648cf74efa4ae3790c8afd15f9 --- /dev/null +++ b/problems/kb1_086_conv_depthwise_separable_2d__fp16.py @@ -0,0 +1,75 @@ +"""Task kb1_086_conv_depthwise_separable_2d__fp16 (KernelBench Level 1 #86, split=train, category=convolution, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_086_conv_depthwise_separable_2d__fp16" +SOURCE_KB_ID = 86 +CATEGORY = "convolution" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + Performs a depthwise-separable 2D convolution operation. + + Args: + in_channels (int): Number of channels in the input tensor. + out_channels (int): Number of channels produced by the convolution. + kernel_size (int): Size of the convolution kernel. + stride (int, optional): Stride of the convolution. Defaults to 1. + padding (int, optional): Padding applied to the input. Defaults to 0. + dilation (int, optional): Spacing between kernel elements. Defaults to 1. + bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`. + """ + def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False): + super(Model, self).__init__() + self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias) + self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias) + + def forward(self, x: torch.Tensor) -> torch.Tensor: + """ + Performs the depthwise-separable 2D convolution. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width). + + Returns: + torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out). + """ + x = self.depthwise(x) + x = self.pointwise(x) + return x + +# Test code +batch_size = 16 +in_channels = 64 +out_channels = 128 +kernel_size = 3 +width = 512 +height = 512 +stride = 1 +padding = 1 +dilation = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 8 +in_channels = 64 +out_channels = 128 +width = 128 +height = 128 + +def get_inputs(): + x = torch.rand(batch_size, in_channels, height, width) + return [x] + +def get_init_inputs(): + return [in_channels, out_channels, kernel_size, stride, padding, dilation] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_088_mingptnewgelu.py b/problems/kb1_088_mingptnewgelu.py new file mode 100644 index 0000000000000000000000000000000000000000..208ac9c99afeb4e446adb56b42d04a0568d7cd90 --- /dev/null +++ b/problems/kb1_088_mingptnewgelu.py @@ -0,0 +1,46 @@ +"""Task kb1_088_mingptnewgelu (KernelBench Level 1 #88, split=train, category=activation, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_088_mingptnewgelu" +SOURCE_KB_ID = 88 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn +import torch.nn.functional as F +import math + +# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py + +class Model(nn.Module): + """ + Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT). + Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415 + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x): + return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0)))) + +batch_size = 8192 +dim = 8192 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + return [torch.randn(batch_size, dim)] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_088_mingptnewgelu__bf16.py b/problems/kb1_088_mingptnewgelu__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..c3d00152ced0f051e410b77568aa656b619b03c6 --- /dev/null +++ b/problems/kb1_088_mingptnewgelu__bf16.py @@ -0,0 +1,46 @@ +"""Task kb1_088_mingptnewgelu__bf16 (KernelBench Level 1 #88, split=train, category=activation, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_088_mingptnewgelu__bf16" +SOURCE_KB_ID = 88 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn +import torch.nn.functional as F +import math + +# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py + +class Model(nn.Module): + """ + Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT). + Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415 + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x): + return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0)))) + +batch_size = 8192 +dim = 8192 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 + +def get_inputs(): + return [torch.randn(batch_size, dim)] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_088_mingptnewgelu__shape_nonpow2.py b/problems/kb1_088_mingptnewgelu__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..1d527a392cbb0897a2bc56a9de9abe5fb05db900 --- /dev/null +++ b/problems/kb1_088_mingptnewgelu__shape_nonpow2.py @@ -0,0 +1,48 @@ +"""Task kb1_088_mingptnewgelu__shape_nonpow2 (KernelBench Level 1 #88, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_088_mingptnewgelu__shape_nonpow2" +SOURCE_KB_ID = 88 +CATEGORY = "activation" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn +import torch.nn.functional as F +import math + +# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py + +class Model(nn.Module): + """ + Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT). + Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415 + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, x): + return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0)))) + +batch_size = 8192 +dim = 8192 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +dim = 4096 +batch_size = 1536 +dim = 5120 + +def get_inputs(): + return [torch.randn(batch_size, dim)] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_090_cumprod.py b/problems/kb1_090_cumprod.py new file mode 100644 index 0000000000000000000000000000000000000000..effeeebb1036cd910db5233df0ceb91948272580 --- /dev/null +++ b/problems/kb1_090_cumprod.py @@ -0,0 +1,63 @@ +"""Task kb1_090_cumprod (KernelBench Level 1 #90, split=train, category=reduction_scan, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_090_cumprod" +SOURCE_KB_ID = 90 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that performs a cumulative product operation along a specified dimension. + + Parameters: + dim (int): The dimension along which to perform the cumulative product operation. + """ + + def __init__(self, dim): + """ + Initialize the CumulativeProductModel. + + Args: + dim (int): The dimension along which to perform the cumulative product. + """ + super(Model, self).__init__() + self.dim = dim + + def forward(self, x): + """ + Forward pass, computing the cumulative product along the specified dimension. + + Args: + x (torch.Tensor): Input tensor of shape (batch_size, *input_shape). + + Returns: + torch.Tensor: Tensor of the same shape as `x` after applying cumulative product along `dim`. + """ + return torch.cumprod(x, dim=self.dim) + +# Define input dimensions and parameters +batch_size = 32768 +input_shape = (32768,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (1024,) + +def get_inputs(): + return [torch.rand(batch_size, *input_shape)] + +def get_init_inputs(): + return [dim] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_091_cumsum_reverse.py b/problems/kb1_091_cumsum_reverse.py new file mode 100644 index 0000000000000000000000000000000000000000..0b38649bb0886d13b74d6697021d73f3e074a286 --- /dev/null +++ b/problems/kb1_091_cumsum_reverse.py @@ -0,0 +1,47 @@ +"""Task kb1_091_cumsum_reverse (KernelBench Level 1 #91, split=train, category=reduction_scan, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_091_cumsum_reverse" +SOURCE_KB_ID = 91 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that performs a reverse cumulative sum operation along a specified dimension. + + Parameters: + dim (int): The dimension along which to perform the reverse cumulative sum. + """ + + def __init__(self, dim): + super(Model, self).__init__() + self.dim = dim + + def forward(self, x): + return torch.cumsum(x.flip(self.dim), dim=self.dim).flip(self.dim) + +batch_size = 32768 +input_shape = (32768,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (2048,) + +def get_inputs(): + return [torch.rand(batch_size, *input_shape)] + +def get_init_inputs(): + return [dim] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_091_cumsum_reverse__shape_wide.py b/problems/kb1_091_cumsum_reverse__shape_wide.py new file mode 100644 index 0000000000000000000000000000000000000000..4dbfa03a32297c9fd2125613c6b6ec2f9a92c539 --- /dev/null +++ b/problems/kb1_091_cumsum_reverse__shape_wide.py @@ -0,0 +1,49 @@ +"""Task kb1_091_cumsum_reverse__shape_wide (KernelBench Level 1 #91, split=train, category=reduction_scan, dtype=fp32, variant=shape_wide).""" +PROBLEM_ID = "kb1_091_cumsum_reverse__shape_wide" +SOURCE_KB_ID = 91 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_wide" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that performs a reverse cumulative sum operation along a specified dimension. + + Parameters: + dim (int): The dimension along which to perform the reverse cumulative sum. + """ + + def __init__(self, dim): + super(Model, self).__init__() + self.dim = dim + + def forward(self, x): + return torch.cumsum(x.flip(self.dim), dim=self.dim).flip(self.dim) + +batch_size = 32768 +input_shape = (32768,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (2048,) +batch_size = 1024 +input_shape = (4096,) + +def get_inputs(): + return [torch.rand(batch_size, *input_shape)] + +def get_init_inputs(): + return [dim] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_092_cumsum_exclusive.py b/problems/kb1_092_cumsum_exclusive.py new file mode 100644 index 0000000000000000000000000000000000000000..00625e7409400f9c3fa12732e1fc119b833f977f --- /dev/null +++ b/problems/kb1_092_cumsum_exclusive.py @@ -0,0 +1,48 @@ +"""Task kb1_092_cumsum_exclusive (KernelBench Level 1 #92, split=train, category=reduction_scan, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_092_cumsum_exclusive" +SOURCE_KB_ID = 92 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that performs an exclusive cumulative sum (does not include the current element). + + Parameters: + dim (int): The dimension along which to perform the exclusive cumulative sum. + """ + + def __init__(self, dim): + super(Model, self).__init__() + self.dim = dim + + def forward(self, x): + cumsum = torch.cumsum(x.narrow(dim=self.dim, start=0, length=x.size(self.dim)-1), dim=self.dim) + return torch.cat((torch.zeros_like(x.select(self.dim, 0).unsqueeze(self.dim)), cumsum), dim=self.dim) + +batch_size = 32768 +input_shape = (32768,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (2048,) + +def get_inputs(): + return [torch.rand(batch_size, *input_shape)] + +def get_init_inputs(): + return [dim] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_093_masked_cumsum.py b/problems/kb1_093_masked_cumsum.py new file mode 100644 index 0000000000000000000000000000000000000000..22c59b1ea1b0837e2beb53febe107e33ee0f3e60 --- /dev/null +++ b/problems/kb1_093_masked_cumsum.py @@ -0,0 +1,57 @@ +"""Task kb1_093_masked_cumsum (KernelBench Level 1 #93, split=train, category=reduction_scan, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_093_masked_cumsum" +SOURCE_KB_ID = 93 +CATEGORY = "reduction_scan" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that performs a masked cumulative sum, only summing elements that satisfy a condition. + + Parameters: + dim (int): The dimension along which to perform the masked cumulative sum. + """ + + def __init__(self, dim): + super(Model, self).__init__() + self.dim = dim + + def forward(self, x, mask): + """ + Args: + x (torch.Tensor): Input tensor of shape (batch_size, *input_shape). + mask (torch.Tensor): Boolean mask of the same shape as x. + + Returns: + torch.Tensor: Cumulative sum of elements where mask is True. + """ + return torch.cumsum(x * mask, dim=self.dim) + +batch_size = 32768 +input_shape = (32768,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (2048,) + +def get_inputs(): + x = torch.rand(batch_size, *input_shape) + mask = torch.randint(0, 2, x.shape).bool() # Random boolean mask + return [x, mask] + +def get_init_inputs(): + return [dim] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_096_huberloss.py b/problems/kb1_096_huberloss.py new file mode 100644 index 0000000000000000000000000000000000000000..9afe416597d2654a04c9cd26e251177c08342539 --- /dev/null +++ b/problems/kb1_096_huberloss.py @@ -0,0 +1,46 @@ +"""Task kb1_096_huberloss (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_096_huberloss" +SOURCE_KB_ID = 96 +CATEGORY = "loss_attention" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that computes Smooth L1 (Huber) Loss for regression tasks. + + Parameters: + None + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, predictions, targets): + return torch.nn.functional.smooth_l1_loss(predictions, targets) + +batch_size = 32768 +input_shape = (32768,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (4096,) + +def get_inputs(): + scale = torch.rand(()) + return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_096_huberloss__bf16.py b/problems/kb1_096_huberloss__bf16.py new file mode 100644 index 0000000000000000000000000000000000000000..9b0364965ed13b75ede20f8ba615700b8ddcfe9c --- /dev/null +++ b/problems/kb1_096_huberloss__bf16.py @@ -0,0 +1,46 @@ +"""Task kb1_096_huberloss__bf16 (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=bf16, variant=bf16).""" +PROBLEM_ID = "kb1_096_huberloss__bf16" +SOURCE_KB_ID = 96 +CATEGORY = "loss_attention" +SPLIT = "train" +DTYPE = "bf16" +VARIANT = "bf16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that computes Smooth L1 (Huber) Loss for regression tasks. + + Parameters: + None + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, predictions, targets): + return torch.nn.functional.smooth_l1_loss(predictions, targets) + +batch_size = 32768 +input_shape = (32768,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (4096,) + +def get_inputs(): + scale = torch.rand(()) + return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_096_huberloss__shape_nonpow2.py b/problems/kb1_096_huberloss__shape_nonpow2.py new file mode 100644 index 0000000000000000000000000000000000000000..c7b76c28090a242c602f9ed12e0a4b3be9dc7257 --- /dev/null +++ b/problems/kb1_096_huberloss__shape_nonpow2.py @@ -0,0 +1,48 @@ +"""Task kb1_096_huberloss__shape_nonpow2 (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=fp32, variant=shape_nonpow2).""" +PROBLEM_ID = "kb1_096_huberloss__shape_nonpow2" +SOURCE_KB_ID = 96 +CATEGORY = "loss_attention" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_nonpow2" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that computes Smooth L1 (Huber) Loss for regression tasks. + + Parameters: + None + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, predictions, targets): + return torch.nn.functional.smooth_l1_loss(predictions, targets) + +batch_size = 32768 +input_shape = (32768,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (4096,) +batch_size = 1500 +input_shape = (3000,) + +def get_inputs(): + scale = torch.rand(()) + return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_098_kldivloss.py b/problems/kb1_098_kldivloss.py new file mode 100644 index 0000000000000000000000000000000000000000..45886b41e4a571a1d6b9a4caeafe6b166a84b459 --- /dev/null +++ b/problems/kb1_098_kldivloss.py @@ -0,0 +1,46 @@ +"""Task kb1_098_kldivloss (KernelBench Level 1 #98, split=train, category=loss_attention, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_098_kldivloss" +SOURCE_KB_ID = 98 +CATEGORY = "loss_attention" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that computes Kullback-Leibler Divergence for comparing two distributions. + + Parameters: + None + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, predictions, targets): + return torch.nn.functional.kl_div(torch.log(predictions), targets, reduction='batchmean') + +batch_size = 8192 * 2 +input_shape = (8192 * 2,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (4096,) + +def get_inputs(): + scale = torch.rand(()) + return [(torch.rand(batch_size, *input_shape)*scale).softmax(dim=-1), torch.rand(batch_size, *input_shape).softmax(dim=-1)] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_098_kldivloss__fp16.py b/problems/kb1_098_kldivloss__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..18d50e5499b433b6d6cc966cbc3b78c600b7aa0f --- /dev/null +++ b/problems/kb1_098_kldivloss__fp16.py @@ -0,0 +1,46 @@ +"""Task kb1_098_kldivloss__fp16 (KernelBench Level 1 #98, split=train, category=loss_attention, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_098_kldivloss__fp16" +SOURCE_KB_ID = 98 +CATEGORY = "loss_attention" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that computes Kullback-Leibler Divergence for comparing two distributions. + + Parameters: + None + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, predictions, targets): + return torch.nn.functional.kl_div(torch.log(predictions), targets, reduction='batchmean') + +batch_size = 8192 * 2 +input_shape = (8192 * 2,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (4096,) + +def get_inputs(): + scale = torch.rand(()) + return [(torch.rand(batch_size, *input_shape)*scale).softmax(dim=-1), torch.rand(batch_size, *input_shape).softmax(dim=-1)] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_099_tripletmarginloss.py b/problems/kb1_099_tripletmarginloss.py new file mode 100644 index 0000000000000000000000000000000000000000..461bff1c21df215ba4805c5998a50f78d966897c --- /dev/null +++ b/problems/kb1_099_tripletmarginloss.py @@ -0,0 +1,47 @@ +"""Task kb1_099_tripletmarginloss (KernelBench Level 1 #99, split=train, category=loss_attention, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_099_tripletmarginloss" +SOURCE_KB_ID = 99 +CATEGORY = "loss_attention" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that computes Triplet Margin Loss for metric learning tasks. + + Parameters: + margin (float): The margin between the positive and negative samples. + """ + def __init__(self, margin=1.0): + super(Model, self).__init__() + self.loss_fn = torch.nn.TripletMarginLoss(margin=margin) + + def forward(self, anchor, positive, negative): + return self.loss_fn(anchor, positive, negative) + +batch_size = 32768 +input_shape = (8192,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (2048,) + +def get_inputs(): + scale = torch.rand(()) + return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape), torch.rand(batch_size, *input_shape)] + +def get_init_inputs(): + return [1.0] # Default margin +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_099_tripletmarginloss__shape_wide.py b/problems/kb1_099_tripletmarginloss__shape_wide.py new file mode 100644 index 0000000000000000000000000000000000000000..b58b99673c202071e0fe941b6db6d368f660e379 --- /dev/null +++ b/problems/kb1_099_tripletmarginloss__shape_wide.py @@ -0,0 +1,49 @@ +"""Task kb1_099_tripletmarginloss__shape_wide (KernelBench Level 1 #99, split=train, category=loss_attention, dtype=fp32, variant=shape_wide).""" +PROBLEM_ID = "kb1_099_tripletmarginloss__shape_wide" +SOURCE_KB_ID = 99 +CATEGORY = "loss_attention" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "shape_wide" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that computes Triplet Margin Loss for metric learning tasks. + + Parameters: + margin (float): The margin between the positive and negative samples. + """ + def __init__(self, margin=1.0): + super(Model, self).__init__() + self.loss_fn = torch.nn.TripletMarginLoss(margin=margin) + + def forward(self, anchor, positive, negative): + return self.loss_fn(anchor, positive, negative) + +batch_size = 32768 +input_shape = (8192,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (2048,) +batch_size = 1024 +input_shape = (4096,) + +def get_inputs(): + scale = torch.rand(()) + return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape), torch.rand(batch_size, *input_shape)] + +def get_init_inputs(): + return [1.0] # Default margin +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_100_hingeloss.py b/problems/kb1_100_hingeloss.py new file mode 100644 index 0000000000000000000000000000000000000000..51087452443bf70ba1438d9fd3758e2e5dfc6815 --- /dev/null +++ b/problems/kb1_100_hingeloss.py @@ -0,0 +1,45 @@ +"""Task kb1_100_hingeloss (KernelBench Level 1 #100, split=train, category=loss_attention, dtype=fp32, variant=base).""" +PROBLEM_ID = "kb1_100_hingeloss" +SOURCE_KB_ID = 100 +CATEGORY = "loss_attention" +SPLIT = "train" +DTYPE = "fp32" +VARIANT = "base" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that computes Hinge Loss for binary classification tasks. + + Parameters: + None + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, predictions, targets): + return torch.mean(torch.clamp(1 - predictions * targets, min=0)) + +batch_size = 32768 +input_shape = (32768,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (2048,) + +def get_inputs(): + return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/problems/kb1_100_hingeloss__fp16.py b/problems/kb1_100_hingeloss__fp16.py new file mode 100644 index 0000000000000000000000000000000000000000..497b0fcf78ac0f1daf36ec8639c01f6c8890e243 --- /dev/null +++ b/problems/kb1_100_hingeloss__fp16.py @@ -0,0 +1,45 @@ +"""Task kb1_100_hingeloss__fp16 (KernelBench Level 1 #100, split=train, category=loss_attention, dtype=fp16, variant=fp16).""" +PROBLEM_ID = "kb1_100_hingeloss__fp16" +SOURCE_KB_ID = 100 +CATEGORY = "loss_attention" +SPLIT = "train" +DTYPE = "fp16" +VARIANT = "fp16" + +import torch +import torch.nn as nn + +class Model(nn.Module): + """ + A model that computes Hinge Loss for binary classification tasks. + + Parameters: + None + """ + def __init__(self): + super(Model, self).__init__() + + def forward(self, predictions, targets): + return torch.mean(torch.clamp(1 - predictions * targets, min=0)) + +batch_size = 32768 +input_shape = (32768,) +dim = 1 + +# --- Task shape configuration (4GB-safe laptop envelope) --- +batch_size = 2048 +input_shape = (2048,) + +def get_inputs(): + return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1] + +def get_init_inputs(): + return [] +if __name__ == "__main__": + import sys + from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + from verifier import verify_kernel, format_result + res = verify_kernel(None, __file__, self_check=True) + print(format_result(res)) + sys.exit(0 if res["status"] == "PASS" else 1) diff --git a/teacher_traces_v2_clean.jsonl b/teacher_traces_v2_clean.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..1a8a1bca8ecda0b6f55ae62939a2e22555b1464c --- /dev/null +++ b/teacher_traces_v2_clean.jsonl @@ -0,0 +1,140 @@ +{"timestamp": "2026-12-01T19:33:42.029989+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_002_standard_matrix_multiplication", "source_kb_id": 2, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_002_standard_matrix_multiplication.py", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_002_standard_matrix_multiplication (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled 2D Triton matmul using tl.dot with IEEE fp32 precision and fp16/bf16 tensor-core accumulation.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.5037, "raw_speedup": 0.5037, "ref_ms": 1.724928, "cand_ms": 3.424256, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.724928, "mean_ms": 1.800376, "min_ms": 1.447936, "max_ms": 2.475008, "std_ms": 0.270498}, "cand_stats": {"median_ms": 3.424256, "mean_ms": 3.27209, "min_ms": 1.430528, "max_ms": 5.042176, "std_ms": 0.874883}}, "audited_timestamp": "2026-12-01T23:26:32.103240+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9656, "raw_speedup": 0.9656, "ref_ms": 1.623552, "cand_ms": 1.681408, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.623552, "mean_ms": 1.924096, "min_ms": 1.527808, "max_ms": 2.889728, "std_ms": 0.551433}, "cand_stats": {"median_ms": 1.681408, "mean_ms": 1.756119, "min_ms": 0.854016, "max_ms": 3.661824, "std_ms": 0.449201}}} +{"timestamp": "2026-12-01T19:33:48.525987+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_004_matrix_vector_multiplication", "source_kb_id": 4, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_004_matrix_vector_multiplication.py", "reference_code": "\"\"\"Task kb1_004_matrix_vector_multiplication (KernelBench Level 1 #4, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_004_matrix_vector_multiplication\"\nSOURCE_KB_ID = 4\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix-vector multiplication (C = A * B).\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix-vector multiplication.\n\n Args:\n A: Input matrix of shape (M, K).\n B: Input vector of shape (K, 1).\n\n Returns:\n Output vector of shape (M, 1).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256 * 8 # 2048\nK = 131072 * 8 # 1048576\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 16384\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, 1)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_004_matrix_vector_multiplication (KernelBench Level 1 #4, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_004_matrix_vector_multiplication\"\nSOURCE_KB_ID = 4\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix-vector multiplication (C = A * B).\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix-vector multiplication.\n\n Args:\n A: Input matrix of shape (M, K).\n B: Input vector of shape (K, 1).\n\n Returns:\n Output vector of shape (M, 1).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256 * 8 # 2048\nK = 131072 * 8 # 1048576\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 16384\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, 1)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Row-parallel Triton matrix-vector multiplication (M, K) @ (K, 1) accumulating in fp32.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matvec_kernel(a_ptr, b_ptr, c_ptr, M, K, stride_am, stride_ak, BLOCK_K: tl.constexpr):\n row = tl.program_id(0)\n acc = 0.0\n for k_start in range(0, K, BLOCK_K):\n offs_k = k_start + tl.arange(0, BLOCK_K)\n mask = offs_k < K\n a = tl.load(a_ptr + row * stride_am + offs_k * stride_ak, mask=mask, other=0.0).to(tl.float32)\n b = tl.load(b_ptr + offs_k, mask=mask, other=0.0).to(tl.float32)\n acc += tl.sum(a * b, axis=0)\n tl.store(c_ptr + row, acc)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n A = A.contiguous()\n b_vec = B.contiguous().view(-1)\n M, K = A.shape\n out = torch.empty((M, 1), device=A.device, dtype=A.dtype)\n matvec_kernel[(M,)](A, b_vec, out, M, K, A.stride(0), A.stride(1), BLOCK_K=1024, num_warps=4)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.7673, "raw_speedup": 0.7673, "ref_ms": 0.464384, "cand_ms": 0.605184, "max_abs_diff": 0.00146484375, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.464384, "mean_ms": 0.487076, "min_ms": 0.427008, "max_ms": 0.638976, "std_ms": 0.046301}, "cand_stats": {"median_ms": 0.605184, "mean_ms": 0.663368, "min_ms": 0.495616, "max_ms": 1.588224, "std_ms": 0.180744}}, "audited_timestamp": "2026-12-01T23:26:41.497217+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.011, "raw_speedup": 1.011, "ref_ms": 0.375808, "cand_ms": 0.371712, "max_abs_diff": 0.00146484375, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.375808, "mean_ms": 0.387973, "min_ms": 0.37376, "max_ms": 0.602112, "std_ms": 0.03894}, "cand_stats": {"median_ms": 0.371712, "mean_ms": 0.395592, "min_ms": 0.370688, "max_ms": 0.837632, "std_ms": 0.088566}}} +{"timestamp": "2026-12-01T19:33:53.939013+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_005_matrix_scalar_multiplication", "source_kb_id": 5, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_005_matrix_scalar_multiplication.py", "reference_code": "\"\"\"Task kb1_005_matrix_scalar_multiplication (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_005_matrix_scalar_multiplication (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Elementwise Triton matrix-scalar multiplication C = A * s.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef mat_scalar_mul_kernel(a_ptr, out_ptr, s, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n a = tl.load(a_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, (a.to(tl.float32) * s).to(a.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n A = A.contiguous()\n out = torch.empty_like(A)\n n_elements = A.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n mat_scalar_mul_kernel[grid](A, out, float(s), n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9927, "raw_speedup": 0.9927, "ref_ms": 0.904192, "cand_ms": 0.910848, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.904192, "mean_ms": 0.890409, "min_ms": 0.805888, "max_ms": 0.950272, "std_ms": 0.034502}, "cand_stats": {"median_ms": 0.910848, "mean_ms": 0.908513, "min_ms": 0.81408, "max_ms": 0.990208, "std_ms": 0.026824}}, "audited_timestamp": "2026-12-01T23:26:48.028127+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9973, "raw_speedup": 0.9973, "ref_ms": 0.751616, "cand_ms": 0.753664, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.751616, "mean_ms": 0.772137, "min_ms": 0.74752, "max_ms": 0.997376, "std_ms": 0.055195}, "cand_stats": {"median_ms": 0.753664, "mean_ms": 0.784835, "min_ms": 0.74752, "max_ms": 1.158144, "std_ms": 0.076509}}} +{"timestamp": "2026-12-01T19:34:00.741267+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_006_matmul_with_large_k_dimension", "source_kb_id": 6, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_006_matmul_with_large_k_dimension.py", "reference_code": "\"\"\"Task kb1_006_matmul_with_large_k_dimension (KernelBench Level 1 #6, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_006_matmul_with_large_k_dimension (KernelBench Level 1 #6, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul for large K with fp32 accumulator and IEEE dot precision.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.53, "raw_speedup": 0.53, "ref_ms": 0.90112, "cand_ms": 1.700352, "max_abs_diff": 0.0908203125, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.90112, "mean_ms": 0.957788, "min_ms": 0.817152, "max_ms": 1.564672, "std_ms": 0.150547}, "cand_stats": {"median_ms": 1.700352, "mean_ms": 1.739633, "min_ms": 1.613824, "max_ms": 2.300928, "std_ms": 0.125045}}, "audited_timestamp": "2026-12-01T23:26:57.260592+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.5982, "raw_speedup": 0.5982, "ref_ms": 0.915456, "cand_ms": 1.530368, "max_abs_diff": 0.0908203125, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.915456, "mean_ms": 0.923873, "min_ms": 0.909312, "max_ms": 1.089536, "std_ms": 0.03062}, "cand_stats": {"median_ms": 1.530368, "mean_ms": 1.453466, "min_ms": 1.165312, "max_ms": 2.019328, "std_ms": 0.223427}}} +{"timestamp": "2026-12-01T19:34:08.107828+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_007_matmul_with_small_k_dimension", "source_kb_id": 7, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_007_matmul_with_small_k_dimension.py", "reference_code": "\"\"\"Task kb1_007_matmul_with_small_k_dimension (KernelBench Level 1 #7, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_007_matmul_with_small_k_dimension\"\nSOURCE_KB_ID = 7\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a small K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16384 * 2\nK = 32 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nK = 64\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_007_matmul_with_small_k_dimension (KernelBench Level 1 #7, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_007_matmul_with_small_k_dimension\"\nSOURCE_KB_ID = 7\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a small K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16384 * 2\nK = 32 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nK = 64\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul for small K with masked K-tile loads.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.7789, "raw_speedup": 0.7789, "ref_ms": 0.723456, "cand_ms": 0.928768, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.723456, "mean_ms": 0.750019, "min_ms": 0.615424, "max_ms": 1.036288, "std_ms": 0.084023}, "cand_stats": {"median_ms": 0.928768, "mean_ms": 0.987116, "min_ms": 0.787456, "max_ms": 1.560576, "std_ms": 0.175197}}, "audited_timestamp": "2026-12-01T23:27:03.844465+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.8509, "raw_speedup": 0.8509, "ref_ms": 0.628224, "cand_ms": 0.738304, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.628224, "mean_ms": 0.639775, "min_ms": 0.555008, "max_ms": 1.110016, "std_ms": 0.079965}, "cand_stats": {"median_ms": 0.738304, "mean_ms": 0.759357, "min_ms": 0.720896, "max_ms": 1.09568, "std_ms": 0.06269}}} +{"timestamp": "2026-12-01T19:34:15.243420+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_008_matmul_with_irregular_shapes", "source_kb_id": 8, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_008_matmul_with_irregular_shapes.py", "reference_code": "\"\"\"Task kb1_008_matmul_with_irregular_shapes (KernelBench Level 1 #8, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_008_matmul_with_irregular_shapes\"\nSOURCE_KB_ID = 8\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with irregular shapes\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor with shape (M, K).\n B: Input tensor with shape (K, N).\n\n Returns:\n C: Output tensor with shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 8205\nK = 2949\nN = 5921\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2051\nK = 1473\nN = 1973\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_008_matmul_with_irregular_shapes (KernelBench Level 1 #8, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_008_matmul_with_irregular_shapes\"\nSOURCE_KB_ID = 8\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with irregular shapes\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor with shape (M, K).\n B: Input tensor with shape (K, N).\n\n Returns:\n C: Output tensor with shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 8205\nK = 2949\nN = 5921\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2051\nK = 1473\nN = 1973\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul with boundary masking for irregular shapes.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.5798, "raw_speedup": 0.5798, "ref_ms": 2.608128, "cand_ms": 4.498432, "max_abs_diff": 0.001251220703125, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.608128, "mean_ms": 2.676183, "min_ms": 2.436096, "max_ms": 3.506176, "std_ms": 0.226122}, "cand_stats": {"median_ms": 4.498432, "mean_ms": 4.49794, "min_ms": 3.912704, "max_ms": 5.653504, "std_ms": 0.409088}}, "audited_timestamp": "2026-12-01T23:27:10.784706+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.7333, "raw_speedup": 0.7333, "ref_ms": 2.830336, "cand_ms": 3.859968, "max_abs_diff": 0.001251220703125, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.830336, "mean_ms": 2.697544, "min_ms": 2.36544, "max_ms": 2.98496, "std_ms": 0.19713}, "cand_stats": {"median_ms": 3.859968, "mean_ms": 3.907584, "min_ms": 3.639296, "max_ms": 4.421632, "std_ms": 0.178833}}} +{"timestamp": "2026-12-01T19:34:22.296825+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_009_tall_skinny_matrix_multiplication", "source_kb_id": 9, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_009_tall_skinny_matrix_multiplication.py", "reference_code": "\"\"\"Task kb1_009_tall_skinny_matrix_multiplication (KernelBench Level 1 #9, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_009_tall_skinny_matrix_multiplication\"\nSOURCE_KB_ID = 9\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) where one of the matrices is tall and skinny (M >> N or N >> M)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): Input matrix of shape (M, K) or (K, M) where M >> N or N >> M.\n B (torch.Tensor): Input matrix of shape (K, N) or (N, K) where M >> N or N >> M.\n\n Returns:\n torch.Tensor: Output matrix of shape (M, N) or (N, M)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 8192\nN = 64\n\ndef get_inputs():\n A = torch.rand(M, N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_009_tall_skinny_matrix_multiplication (KernelBench Level 1 #9, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_009_tall_skinny_matrix_multiplication\"\nSOURCE_KB_ID = 9\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) where one of the matrices is tall and skinny (M >> N or N >> M)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): Input matrix of shape (M, K) or (K, M) where M >> N or N >> M.\n B (torch.Tensor): Input matrix of shape (K, N) or (N, K) where M >> N or N >> M.\n\n Returns:\n torch.Tensor: Output matrix of shape (M, N) or (N, M)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 8192\nN = 64\n\ndef get_inputs():\n A = torch.rand(M, N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul for tall-skinny matrices.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.767, "raw_speedup": 0.767, "ref_ms": 2.666496, "cand_ms": 3.47648, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.666496, "mean_ms": 2.861302, "min_ms": 2.308096, "max_ms": 7.693312, "std_ms": 0.78944}, "cand_stats": {"median_ms": 3.47648, "mean_ms": 3.580764, "min_ms": 3.098624, "max_ms": 4.671488, "std_ms": 0.385904}}, "audited_timestamp": "2026-12-01T23:27:18.005544+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.7185, "raw_speedup": 0.7185, "ref_ms": 2.25536, "cand_ms": 3.139072, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.25536, "mean_ms": 2.298778, "min_ms": 2.226176, "max_ms": 2.786304, "std_ms": 0.107671}, "cand_stats": {"median_ms": 3.139072, "mean_ms": 3.179889, "min_ms": 3.01056, "max_ms": 4.178944, "std_ms": 0.202597}}} +{"timestamp": "2026-12-01T19:34:28.776047+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_010_3d_tensor_matrix_multiplication", "source_kb_id": 10, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_010_3d_tensor_matrix_multiplication.py", "reference_code": "\"\"\"Task kb1_010_3d_tensor_matrix_multiplication (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_010_3d_tensor_matrix_multiplication (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "3D tensor-matrix multiplication (N, M, K) @ (K, L) flattened to 2D tiled Triton matmul.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n N, M, K = A.shape\n L = B.shape[1]\n return triton_matmul(A.contiguous().view(N * M, K), B.contiguous()).view(N, M, L)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8986, "raw_speedup": 0.8986, "ref_ms": 1.933312, "cand_ms": 2.151424, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.933312, "mean_ms": 1.983529, "min_ms": 1.595392, "max_ms": 3.083264, "std_ms": 0.334158}, "cand_stats": {"median_ms": 2.151424, "mean_ms": 2.31938, "min_ms": 1.990656, "max_ms": 3.47648, "std_ms": 0.337719}}, "audited_timestamp": "2026-12-01T23:27:26.483096+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0595, "raw_speedup": 1.0595, "ref_ms": 1.814528, "cand_ms": 1.71264, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.814528, "mean_ms": 1.881743, "min_ms": 1.811456, "max_ms": 2.27328, "std_ms": 0.107112}, "cand_stats": {"median_ms": 1.71264, "mean_ms": 1.762284, "min_ms": 1.659904, "max_ms": 2.25792, "std_ms": 0.133048}}} +{"timestamp": "2026-12-01T19:34:36.319646+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_011_4d_tensor_matrix_multiplication", "source_kb_id": 11, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_011_4d_tensor_matrix_multiplication.py", "reference_code": "\"\"\"Task kb1_011_4d_tensor_matrix_multiplication (KernelBench Level 1 #11, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_011_4d_tensor_matrix_multiplication\"\nSOURCE_KB_ID = 11\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 4D tensor-matrix multiplication: \n C[b, i, j, k] = sum_l A[b, i, j, l] * B[l, k]\n\n Args:\n A (torch.Tensor): Input 4D tensor of shape (b, i, j, l)\n B (torch.Tensor): Input matrix of shape (l, k)\n\n Returns:\n torch.Tensor: Output 4D tensor of shape (b, i, j, k)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, A, B):\n \"\"\"\n Performs the 4D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 4D tensor of shape (b, i, j, l)\n B (torch.Tensor): Input matrix of shape (l, k)\n\n Returns:\n torch.Tensor: Output 4D tensor of shape (b, i, j, k)\n \"\"\"\n return torch.einsum(\"bijl,lk->bijk\", A, B)\n\n# Test code\nb = 8\ni = 256\nj = 512\nl = 256\nk = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nb = 4\ni = 128\nj = 256\nl = 128\nk = 256\n\ndef get_inputs():\n A = torch.rand(b, i, j, l)\n B = torch.rand(l, k)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_011_4d_tensor_matrix_multiplication (KernelBench Level 1 #11, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_011_4d_tensor_matrix_multiplication\"\nSOURCE_KB_ID = 11\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 4D tensor-matrix multiplication: \n C[b, i, j, k] = sum_l A[b, i, j, l] * B[l, k]\n\n Args:\n A (torch.Tensor): Input 4D tensor of shape (b, i, j, l)\n B (torch.Tensor): Input matrix of shape (l, k)\n\n Returns:\n torch.Tensor: Output 4D tensor of shape (b, i, j, k)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, A, B):\n \"\"\"\n Performs the 4D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 4D tensor of shape (b, i, j, l)\n B (torch.Tensor): Input matrix of shape (l, k)\n\n Returns:\n torch.Tensor: Output 4D tensor of shape (b, i, j, k)\n \"\"\"\n return torch.einsum(\"bijl,lk->bijk\", A, B)\n\n# Test code\nb = 8\ni = 256\nj = 512\nl = 256\nk = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nb = 4\ni = 128\nj = 256\nl = 128\nk = 256\n\ndef get_inputs():\n A = torch.rand(b, i, j, l)\n B = torch.rand(l, k)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "4D tensor-matrix multiplication einsum('bijl,lk->bijk', A, B) flattened to 2D tiled Triton matmul.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n b, i, j, l = A.shape\n k = B.shape[1]\n return triton_matmul(A.contiguous().view(b * i * j, l), B.contiguous()).view(b, i, j, k)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.7338, "raw_speedup": 0.7338, "ref_ms": 1.900032, "cand_ms": 2.589184, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.900032, "mean_ms": 2.010952, "min_ms": 1.700864, "max_ms": 3.054592, "std_ms": 0.291833}, "cand_stats": {"median_ms": 2.589184, "mean_ms": 2.679562, "min_ms": 2.347008, "max_ms": 3.6096, "std_ms": 0.302011}}, "audited_timestamp": "2026-12-01T23:27:34.011006+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.7505, "raw_speedup": 0.7505, "ref_ms": 1.746432, "cand_ms": 2.32704, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.746432, "mean_ms": 1.734205, "min_ms": 1.5616, "max_ms": 2.095104, "std_ms": 0.093121}, "cand_stats": {"median_ms": 2.32704, "mean_ms": 2.385142, "min_ms": 2.217984, "max_ms": 3.175424, "std_ms": 0.193371}}} +{"timestamp": "2026-12-01T19:34:40.749826+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_012_matmul_with_diagonal_matrices", "source_kb_id": 12, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_012_matmul_with_diagonal_matrices.py", "reference_code": "\"\"\"Task kb1_012_matmul_with_diagonal_matrices (KernelBench Level 1 #12, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_012_matmul_with_diagonal_matrices\"\nSOURCE_KB_ID = 12\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication of a diagonal matrix with another matrix.\n C = diag(A) * B\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): A 1D tensor representing the diagonal of the diagonal matrix. Shape: (N,).\n B (torch.Tensor): A 2D tensor representing the second matrix. Shape: (N, M).\n\n Returns:\n torch.Tensor: The result of the matrix multiplication. Shape: (N, M).\n \"\"\"\n # Logically equivalent to torch.diag(A) @ B \n # more efficient as no need to materialize a full N\u00d7N matrix\n return A.unsqueeze(1) * B\n\nM = 4096\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2048\nN = 2048\n\ndef get_inputs():\n A = torch.rand(N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_012_matmul_with_diagonal_matrices (KernelBench Level 1 #12, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_012_matmul_with_diagonal_matrices\"\nSOURCE_KB_ID = 12\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication of a diagonal matrix with another matrix.\n C = diag(A) * B\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): A 1D tensor representing the diagonal of the diagonal matrix. Shape: (N,).\n B (torch.Tensor): A 2D tensor representing the second matrix. Shape: (N, M).\n\n Returns:\n torch.Tensor: The result of the matrix multiplication. Shape: (N, M).\n \"\"\"\n # Logically equivalent to torch.diag(A) @ B \n # more efficient as no need to materialize a full N\u00d7N matrix\n return A.unsqueeze(1) * B\n\nM = 4096\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2048\nN = 2048\n\ndef get_inputs():\n A = torch.rand(N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton diagonal-matrix multiplication C[r, c] = A[r] * B[r, c].", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef diag_matmul_kernel(a_ptr, b_ptr, c_ptr, N, M, stride_bn, stride_bm, BLOCK_M: tl.constexpr):\n row = tl.program_id(0)\n col_block = tl.program_id(1)\n cols = col_block * BLOCK_M + tl.arange(0, BLOCK_M)\n mask = cols < M\n a_val = tl.load(a_ptr + row)\n b_vals = tl.load(b_ptr + row * stride_bn + cols * stride_bm, mask=mask, other=0.0)\n tl.store(c_ptr + row * stride_bn + cols * stride_bm, a_val * b_vals, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n A = A.contiguous()\n B = B.contiguous()\n N, M = B.shape\n out = torch.empty_like(B)\n BLOCK_M = 1024\n diag_matmul_kernel[(N, triton.cdiv(M, BLOCK_M))](A, B, out, N, M, B.stride(0), B.stride(1), BLOCK_M=BLOCK_M)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8467, "raw_speedup": 0.8467, "ref_ms": 0.2432, "cand_ms": 0.287232, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.2432, "mean_ms": 0.272609, "min_ms": 0.234496, "max_ms": 0.407552, "std_ms": 0.047827}, "cand_stats": {"median_ms": 0.287232, "mean_ms": 0.28842, "min_ms": 0.239616, "max_ms": 0.352256, "std_ms": 0.02652}}, "audited_timestamp": "2026-12-01T23:27:39.152162+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9841, "raw_speedup": 0.9841, "ref_ms": 0.190464, "cand_ms": 0.193536, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.190464, "mean_ms": 0.192799, "min_ms": 0.18944, "max_ms": 0.316416, "std_ms": 0.01788}, "cand_stats": {"median_ms": 0.193536, "mean_ms": 0.208097, "min_ms": 0.191488, "max_ms": 0.504832, "std_ms": 0.047533}}} +{"timestamp": "2026-12-01T19:34:46.534728+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_013_matmul_for_symmetric_matrices", "source_kb_id": 13, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_013_matmul_for_symmetric_matrices.py", "reference_code": "\"\"\"Task kb1_013_matmul_for_symmetric_matrices (KernelBench Level 1 #13, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_013_matmul_for_symmetric_matrices\"\nSOURCE_KB_ID = 13\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with A and B being symmetric matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of two symmetric matrices.\n\n Args:\n A (torch.Tensor): Input matrix A, shape (N, N), symmetric.\n B (torch.Tensor): Input matrix B, shape (N, N), symmetric.\n\n Returns:\n torch.Tensor: Output matrix C, shape (N, N).\n \"\"\"\n return torch.matmul(A, B)\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\n\ndef get_inputs():\n \"\"\"\n Generates a pair of random symmetric matrices for testing.\n\n Returns:\n list: List containing two symmetric tensors A and B.\n \"\"\"\n A = torch.rand(N, N)\n A = (A + A.T) / 2 # Ensure symmetry\n B = torch.rand(N, N)\n B = (B + B.T) / 2 # Ensure symmetry\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs needed for this model.\n\n Returns:\n list: Empty list.\n \"\"\"\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_013_matmul_for_symmetric_matrices (KernelBench Level 1 #13, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_013_matmul_for_symmetric_matrices\"\nSOURCE_KB_ID = 13\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with A and B being symmetric matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of two symmetric matrices.\n\n Args:\n A (torch.Tensor): Input matrix A, shape (N, N), symmetric.\n B (torch.Tensor): Input matrix B, shape (N, N), symmetric.\n\n Returns:\n torch.Tensor: Output matrix C, shape (N, N).\n \"\"\"\n return torch.matmul(A, B)\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\n\ndef get_inputs():\n \"\"\"\n Generates a pair of random symmetric matrices for testing.\n\n Returns:\n list: List containing two symmetric tensors A and B.\n \"\"\"\n A = torch.rand(N, N)\n A = (A + A.T) / 2 # Ensure symmetry\n B = torch.rand(N, N)\n B = (B + B.T) / 2 # Ensure symmetry\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs needed for this model.\n\n Returns:\n list: Empty list.\n \"\"\"\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul for symmetric square matrices.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.019, "raw_speedup": 1.019, "ref_ms": 0.65792, "cand_ms": 0.645632, "max_abs_diff": 0.000640869140625, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.65792, "mean_ms": 0.672604, "min_ms": 0.577536, "max_ms": 0.910336, "std_ms": 0.081889}, "cand_stats": {"median_ms": 0.645632, "mean_ms": 0.661094, "min_ms": 0.549888, "max_ms": 1.000448, "std_ms": 0.076262}}, "audited_timestamp": "2026-12-01T23:27:46.149699+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9769, "raw_speedup": 0.9769, "ref_ms": 0.477184, "cand_ms": 0.488448, "max_abs_diff": 0.000640869140625, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.477184, "mean_ms": 0.479949, "min_ms": 0.47616, "max_ms": 0.528384, "std_ms": 0.007807}, "cand_stats": {"median_ms": 0.488448, "mean_ms": 0.504054, "min_ms": 0.487424, "max_ms": 0.667648, "std_ms": 0.034448}}} +{"timestamp": "2026-12-01T19:34:52.655231+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_014_matmul_for_upper_triangular_matrices", "source_kb_id": 14, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_014_matmul_for_upper_triangular_matrices.py", "reference_code": "\"\"\"Task kb1_014_matmul_for_upper_triangular_matrices (KernelBench Level 1 #14, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_014_matmul_for_upper_triangular_matrices\"\nSOURCE_KB_ID = 14\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix multiplication (C = A * B) for upper triangular matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication for upper triangular matrices.\n\n Args:\n A (torch.Tensor): Upper triangular matrix of shape (N, N).\n B (torch.Tensor): Upper triangular matrix of shape (N, N).\n\n Returns:\n torch.Tensor: The product of A and B, also an upper triangular matrix of shape (N, N).\n \"\"\"\n return torch.triu(torch.matmul(A, B))\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\n\ndef get_inputs():\n \"\"\"\n Generates upper triangular matrices for testing.\n\n Returns:\n list: A list containing two upper triangular matrices of shape (N, N).\n \"\"\"\n A = torch.triu(torch.rand(N, N))\n B = torch.triu(torch.rand(N, N))\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs are needed for this model.\n\n Returns:\n list: An empty list.\n \"\"\"\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_014_matmul_for_upper_triangular_matrices (KernelBench Level 1 #14, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_014_matmul_for_upper_triangular_matrices\"\nSOURCE_KB_ID = 14\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix multiplication (C = A * B) for upper triangular matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication for upper triangular matrices.\n\n Args:\n A (torch.Tensor): Upper triangular matrix of shape (N, N).\n B (torch.Tensor): Upper triangular matrix of shape (N, N).\n\n Returns:\n torch.Tensor: The product of A and B, also an upper triangular matrix of shape (N, N).\n \"\"\"\n return torch.triu(torch.matmul(A, B))\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\n\ndef get_inputs():\n \"\"\"\n Generates upper triangular matrices for testing.\n\n Returns:\n list: A list containing two upper triangular matrices of shape (N, N).\n \"\"\"\n A = torch.triu(torch.rand(N, N))\n B = torch.triu(torch.rand(N, N))\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs are needed for this model.\n\n Returns:\n list: An empty list.\n \"\"\"\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton upper-triangular matmul skipping strictly lower-triangular tiles.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef triu_matmul_kernel(\n a_ptr, b_ptr, c_ptr, N,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr, USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n c_mask = (offs_m[:, None] < N) & (offs_n[None, :] < N)\n if pid_m * BLOCK_M > (pid_n + 1) * BLOCK_N - 1:\n tl.store(c_ptrs, tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32), mask=c_mask)\n return\n offs_k = tl.arange(0, BLOCK_K)\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, N, BLOCK_K):\n k_mask = (k_start + offs_k) < N\n a = tl.load(a_ptr + offs_m[:, None] * stride_am + (k_start + offs_k)[None, :] * stride_ak, mask=(offs_m[:, None] < N) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptr + (k_start + offs_k)[:, None] * stride_bk + offs_n[None, :] * stride_bn, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n acc = tl.where(offs_m[:, None] <= offs_n[None, :], acc, 0.0)\n tl.store(c_ptrs, acc, mask=c_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n N = A.shape[0]\n C = torch.empty((N, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n triu_matmul_kernel[(triton.cdiv(N, BM), triton.cdiv(N, BN))](\n A, B, C, N, A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32),\n )\n return C\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.3638, "raw_speedup": 1.3638, "ref_ms": 0.550912, "cand_ms": 0.403968, "max_abs_diff": 0.000518798828125, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.550912, "mean_ms": 0.564756, "min_ms": 0.543744, "max_ms": 0.845824, "std_ms": 0.044137}, "cand_stats": {"median_ms": 0.403968, "mean_ms": 0.415539, "min_ms": 0.346112, "max_ms": 0.657408, "std_ms": 0.051604}}, "audited_timestamp": "2026-12-01T23:27:52.756514+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.3942, "raw_speedup": 1.3942, "ref_ms": 0.516096, "cand_ms": 0.370176, "max_abs_diff": 0.000518798828125, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.516096, "mean_ms": 0.535941, "min_ms": 0.514048, "max_ms": 0.738304, "std_ms": 0.04753}, "cand_stats": {"median_ms": 0.370176, "mean_ms": 0.378696, "min_ms": 0.274432, "max_ms": 0.564224, "std_ms": 0.054791}}} +{"timestamp": "2026-12-01T19:34:58.400784+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_015_matmul_for_lower_triangular_matrices", "source_kb_id": 15, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_015_matmul_for_lower_triangular_matrices.py", "reference_code": "\"\"\"Task kb1_015_matmul_for_lower_triangular_matrices (KernelBench Level 1 #15, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_015_matmul_for_lower_triangular_matrices\"\nSOURCE_KB_ID = 15\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication (C = A * B) where A and B are lower triangular matrices. \n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of lower triangular matrices A and B.\n\n Args:\n A (torch.Tensor): Lower triangular matrix of shape (N, N).\n B (torch.Tensor): Lower triangular matrix of shape (N, N).\n\n Returns:\n torch.Tensor: The result of matrix multiplication C of shape (N, N).\n \"\"\"\n return torch.tril(torch.matmul(A, B))\n\nM = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\n\ndef get_inputs():\n A = torch.rand(M, M)\n B = torch.rand(M, M)\n A = torch.tril(A)\n B = torch.tril(B)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_015_matmul_for_lower_triangular_matrices (KernelBench Level 1 #15, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_015_matmul_for_lower_triangular_matrices\"\nSOURCE_KB_ID = 15\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication (C = A * B) where A and B are lower triangular matrices. \n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of lower triangular matrices A and B.\n\n Args:\n A (torch.Tensor): Lower triangular matrix of shape (N, N).\n B (torch.Tensor): Lower triangular matrix of shape (N, N).\n\n Returns:\n torch.Tensor: The result of matrix multiplication C of shape (N, N).\n \"\"\"\n return torch.tril(torch.matmul(A, B))\n\nM = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\n\ndef get_inputs():\n A = torch.rand(M, M)\n B = torch.rand(M, M)\n A = torch.tril(A)\n B = torch.tril(B)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton lower-triangular matmul skipping strictly upper-triangular tiles.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef tril_matmul_kernel(\n a_ptr, b_ptr, c_ptr, N,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr, USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n c_mask = (offs_m[:, None] < N) & (offs_n[None, :] < N)\n if pid_n * BLOCK_N > (pid_m + 1) * BLOCK_M - 1:\n tl.store(c_ptrs, tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32), mask=c_mask)\n return\n offs_k = tl.arange(0, BLOCK_K)\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, N, BLOCK_K):\n k_mask = (k_start + offs_k) < N\n a = tl.load(a_ptr + offs_m[:, None] * stride_am + (k_start + offs_k)[None, :] * stride_ak, mask=(offs_m[:, None] < N) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptr + (k_start + offs_k)[:, None] * stride_bk + offs_n[None, :] * stride_bn, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n acc = tl.where(offs_m[:, None] >= offs_n[None, :], acc, 0.0)\n tl.store(c_ptrs, acc, mask=c_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n N = A.shape[0]\n C = torch.empty((N, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n tril_matmul_kernel[(triton.cdiv(N, BM), triton.cdiv(N, BN))](\n A, B, C, N, A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32),\n )\n return C\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.4218, "raw_speedup": 1.4218, "ref_ms": 0.586752, "cand_ms": 0.412672, "max_abs_diff": 0.000457763671875, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.586752, "mean_ms": 0.606966, "min_ms": 0.54272, "max_ms": 0.821248, "std_ms": 0.062203}, "cand_stats": {"median_ms": 0.412672, "mean_ms": 0.429302, "min_ms": 0.338944, "max_ms": 0.791552, "std_ms": 0.066257}}, "audited_timestamp": "2026-12-01T23:28:00.882294+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.9202, "raw_speedup": 1.9202, "ref_ms": 0.51712, "cand_ms": 0.269312, "max_abs_diff": 0.000457763671875, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.51712, "mean_ms": 0.522138, "min_ms": 0.514048, "max_ms": 0.656384, "std_ms": 0.026109}, "cand_stats": {"median_ms": 0.269312, "mean_ms": 0.283136, "min_ms": 0.26624, "max_ms": 0.390144, "std_ms": 0.028692}}} +{"timestamp": "2026-12-01T19:35:04.602420+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_016_matmul_with_transposed_a", "source_kb_id": 16, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_016_matmul_with_transposed_a.py", "reference_code": "\"\"\"Task kb1_016_matmul_with_transposed_a (KernelBench Level 1 #16, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_016_matmul_with_transposed_a (KernelBench Level 1 #16, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul with transposed A (A.T @ B) via strided pointers.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A.T, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9039, "raw_speedup": 0.9039, "ref_ms": 0.977408, "cand_ms": 1.081344, "max_abs_diff": 0.00201416015625, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.977408, "mean_ms": 1.035837, "min_ms": 0.8192, "max_ms": 2.271232, "std_ms": 0.237656}, "cand_stats": {"median_ms": 1.081344, "mean_ms": 1.100145, "min_ms": 0.989184, "max_ms": 1.318912, "std_ms": 0.061582}}, "audited_timestamp": "2026-12-01T23:28:07.631457+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9978, "raw_speedup": 0.9978, "ref_ms": 0.917504, "cand_ms": 0.919552, "max_abs_diff": 0.00201416015625, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.917504, "mean_ms": 0.931164, "min_ms": 0.91648, "max_ms": 1.076224, "std_ms": 0.0399}, "cand_stats": {"median_ms": 0.919552, "mean_ms": 0.953262, "min_ms": 0.917504, "max_ms": 1.183744, "std_ms": 0.069231}}} +{"timestamp": "2026-12-01T19:35:12.034707+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_018_matmul_with_transposed_both", "source_kb_id": 18, "category": "matmul", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_018_matmul_with_transposed_both.py", "reference_code": "\"\"\"Task kb1_018_matmul_with_transposed_both (KernelBench Level 1 #18, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_018_matmul_with_transposed_both\"\nSOURCE_KB_ID = 18\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B.T)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(N, K)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_018_matmul_with_transposed_both (KernelBench Level 1 #18, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_018_matmul_with_transposed_both\"\nSOURCE_KB_ID = 18\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B.T)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(N, K)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul with both A and B transposed (A.T @ B.T) via strided pointers.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A.T, B.T)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.3238, "raw_speedup": 0.3238, "ref_ms": 1.027072, "cand_ms": 3.172352, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.027072, "mean_ms": 1.093427, "min_ms": 0.905216, "max_ms": 1.595392, "std_ms": 0.167142}, "cand_stats": {"median_ms": 3.172352, "mean_ms": 3.250586, "min_ms": 2.801664, "max_ms": 4.171776, "std_ms": 0.326771}}, "audited_timestamp": "2026-12-01T23:28:14.671568+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.4724, "raw_speedup": 0.4724, "ref_ms": 1.014784, "cand_ms": 2.148352, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.014784, "mean_ms": 1.029202, "min_ms": 1.010688, "max_ms": 1.211392, "std_ms": 0.044024}, "cand_stats": {"median_ms": 2.148352, "mean_ms": 2.172047, "min_ms": 2.046976, "max_ms": 2.93888, "std_ms": 0.156064}}} +{"timestamp": "2026-12-01T19:35:16.866793+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_020_leakyrelu", "source_kb_id": 20, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_020_leakyrelu.py", "reference_code": "\"\"\"Task kb1_020_leakyrelu (KernelBench Level 1 #20, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_020_leakyrelu (KernelBench Level 1 #20, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fuse LeakyReLU elementwise in Triton using tl.where(x >= 0, x, x * negative_slope), matching Model.__init__(negative_slope).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef leaky_relu_kernel(x_ptr, out_ptr, n_elements, negative_slope, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n out = tl.where(x >= 0, x, x * negative_slope)\n tl.store(out_ptr + offsets, out, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, negative_slope: float = 0.01):\n super().__init__()\n self.negative_slope = negative_slope\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n leaky_relu_kernel[grid](x, out, n_elements, self.negative_slope, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9845, "raw_speedup": 0.9845, "ref_ms": 0.519168, "cand_ms": 0.52736, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.519168, "mean_ms": 0.51884, "min_ms": 0.431104, "max_ms": 0.65536, "std_ms": 0.052326}, "cand_stats": {"median_ms": 0.52736, "mean_ms": 0.566231, "min_ms": 0.448512, "max_ms": 1.079296, "std_ms": 0.110439}}, "audited_timestamp": "2026-12-01T23:28:19.982319+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9987, "raw_speedup": 0.9987, "ref_ms": 0.37888, "cand_ms": 0.379392, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.37888, "mean_ms": 0.385126, "min_ms": 0.376832, "max_ms": 0.477184, "std_ms": 0.022058}, "cand_stats": {"median_ms": 0.379392, "mean_ms": 0.405176, "min_ms": 0.376832, "max_ms": 0.722944, "std_ms": 0.066686}}} +{"timestamp": "2026-12-01T19:35:20.906088+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_021_sigmoid", "source_kb_id": 21, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_021_sigmoid.py", "reference_code": "\"\"\"Task kb1_021_sigmoid (KernelBench Level 1 #21, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_021_sigmoid (KernelBench Level 1 #21, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise Sigmoid in Triton using tl.sigmoid in fp32.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef sigmoid_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n out = tl.sigmoid(x.to(tl.float32)).to(x.dtype)\n tl.store(out_ptr + offsets, out, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n sigmoid_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9221, "raw_speedup": 0.9221, "ref_ms": 0.4608, "cand_ms": 0.499712, "max_abs_diff": 1.7881393432617188e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.4608, "mean_ms": 0.476856, "min_ms": 0.43008, "max_ms": 0.608256, "std_ms": 0.039556}, "cand_stats": {"median_ms": 0.499712, "mean_ms": 0.502006, "min_ms": 0.453632, "max_ms": 0.617472, "std_ms": 0.037979}}, "audited_timestamp": "2026-12-01T23:28:25.565941+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0027, "raw_speedup": 1.0027, "ref_ms": 0.379904, "cand_ms": 0.37888, "max_abs_diff": 1.7881393432617188e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.379904, "mean_ms": 0.385065, "min_ms": 0.377856, "max_ms": 0.544768, "std_ms": 0.024539}, "cand_stats": {"median_ms": 0.37888, "mean_ms": 0.382812, "min_ms": 0.375808, "max_ms": 0.447488, "std_ms": 0.01486}}} +{"timestamp": "2026-12-01T19:35:25.263296+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_022_tanh", "source_kb_id": 22, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_022_tanh.py", "reference_code": "\"\"\"Task kb1_022_tanh (KernelBench Level 1 #22, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_022_tanh (KernelBench Level 1 #22, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise Tanh in Triton via 2*tl.sigmoid(2*x)-1 in fp32.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef tanh_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n out = (2.0 * tl.sigmoid(2.0 * xf) - 1.0).to(x.dtype)\n tl.store(out_ptr + offsets, out, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n tanh_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9447, "raw_speedup": 0.9447, "ref_ms": 0.454656, "cand_ms": 0.48128, "max_abs_diff": 2.384185791015625e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.454656, "mean_ms": 0.469176, "min_ms": 0.431104, "max_ms": 0.948224, "std_ms": 0.073076}, "cand_stats": {"median_ms": 0.48128, "mean_ms": 0.483942, "min_ms": 0.439296, "max_ms": 0.54272, "std_ms": 0.019882}}, "audited_timestamp": "2026-12-01T23:28:32.547338+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0027, "raw_speedup": 1.0027, "ref_ms": 0.379904, "cand_ms": 0.37888, "max_abs_diff": 2.384185791015625e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.379904, "mean_ms": 0.384389, "min_ms": 0.376832, "max_ms": 0.441344, "std_ms": 0.013622}, "cand_stats": {"median_ms": 0.37888, "mean_ms": 0.393687, "min_ms": 0.375808, "max_ms": 0.534528, "std_ms": 0.035747}}} +{"timestamp": "2026-12-01T19:35:30.078894+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_024_logsoftmax", "source_kb_id": 24, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_024_logsoftmax.py", "reference_code": "\"\"\"Task kb1_024_logsoftmax (KernelBench Level 1 #24, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_024_logsoftmax (KernelBench Level 1 #24, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fuse numerically stable row-wise LogSoftmax in Triton supporting arbitrary dim via transpose.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef log_softmax_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n row_max = -float(\"inf\")\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=-float(\"inf\")).to(tl.float32)\n row_max = tl.maximum(row_max, tl.max(x, axis=0))\n sum_exp = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=-float(\"inf\")).to(tl.float32)\n sum_exp += tl.sum(tl.where(mask, tl.exp(x - row_max), 0.0), axis=0)\n lse = row_max + tl.log(sum_exp)\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0)\n tl.store(out_ptr + row * stride_row + cols, (x.to(tl.float32) - lse).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int = 1):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n dim = self.dim % x.ndim\n x_t = x.transpose(dim, -1).contiguous()\n orig_shape = x_t.shape\n x_2d = x_t.view(-1, orig_shape[-1])\n n_rows, n_cols = x_2d.shape\n out = torch.empty_like(x_2d)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 4096)\n log_softmax_kernel[(n_rows,)](x_2d, out, x_2d.stride(0), n_cols, BLOCK_SIZE=BLOCK_SIZE)\n return out.view(orig_shape).transpose(dim, -1).contiguous()\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.5494, "raw_speedup": 0.5494, "ref_ms": 0.458752, "cand_ms": 0.835072, "max_abs_diff": 1.9073486328125e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.458752, "mean_ms": 0.465142, "min_ms": 0.427008, "max_ms": 0.539648, "std_ms": 0.026411}, "cand_stats": {"median_ms": 0.835072, "mean_ms": 0.842301, "min_ms": 0.749568, "max_ms": 1.15712, "std_ms": 0.083524}}, "audited_timestamp": "2026-12-01T23:28:38.102029+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.5597, "raw_speedup": 0.5597, "ref_ms": 0.384, "cand_ms": 0.68608, "max_abs_diff": 1.9073486328125e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.384, "mean_ms": 0.392233, "min_ms": 0.381952, "max_ms": 0.570368, "std_ms": 0.02967}, "cand_stats": {"median_ms": 0.68608, "mean_ms": 0.73685, "min_ms": 0.677888, "max_ms": 1.040384, "std_ms": 0.083628}}} +{"timestamp": "2026-12-01T19:35:34.604696+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_027_selu", "source_kb_id": 27, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_027_selu.py", "reference_code": "\"\"\"Task kb1_027_selu (KernelBench Level 1 #27, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_027_selu\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_027_selu (KernelBench Level 1 #27, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_027_selu\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise SELU in Triton with standard alpha and scale constants.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef selu_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = 1.0507009873554805 * tl.where(xf > 0.0, xf, 1.6732632423543772 * (tl.exp(xf) - 1.0))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n selu_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8415, "raw_speedup": 0.8415, "ref_ms": 0.467456, "cand_ms": 0.55552, "max_abs_diff": 3.5762786865234375e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.467456, "mean_ms": 0.497562, "min_ms": 0.43008, "max_ms": 0.569344, "std_ms": 0.045744}, "cand_stats": {"median_ms": 0.55552, "mean_ms": 0.570122, "min_ms": 0.5376, "max_ms": 0.677888, "std_ms": 0.036768}}, "audited_timestamp": "2026-12-01T23:28:43.366038+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.8791, "raw_speedup": 0.8791, "ref_ms": 0.394752, "cand_ms": 0.449024, "max_abs_diff": 3.5762786865234375e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.394752, "mean_ms": 0.41001, "min_ms": 0.37888, "max_ms": 0.508928, "std_ms": 0.032431}, "cand_stats": {"median_ms": 0.449024, "mean_ms": 0.452137, "min_ms": 0.379904, "max_ms": 0.512, "std_ms": 0.026104}}} +{"timestamp": "2026-12-01T19:35:39.225956+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_028_hardsigmoid", "source_kb_id": 28, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_028_hardsigmoid.py", "reference_code": "\"\"\"Task kb1_028_hardsigmoid (KernelBench Level 1 #28, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_028_hardsigmoid\"\nSOURCE_KB_ID = 28\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardSigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardSigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardSigmoid applied, same shape as input.\n \"\"\"\n return torch.nn.functional.hardsigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_028_hardsigmoid (KernelBench Level 1 #28, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_028_hardsigmoid\"\nSOURCE_KB_ID = 28\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardSigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardSigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardSigmoid applied, same shape as input.\n \"\"\"\n return torch.nn.functional.hardsigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise HardSigmoid in Triton: clamp((x + 3) / 6, 0, 1).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef hardsigmoid_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = tl.minimum(tl.maximum((xf + 3.0) / 6.0, 0.0), 1.0)\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n hardsigmoid_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8689, "raw_speedup": 0.8689, "ref_ms": 0.461312, "cand_ms": 0.530944, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.461312, "mean_ms": 0.486359, "min_ms": 0.425984, "max_ms": 0.636928, "std_ms": 0.054449}, "cand_stats": {"median_ms": 0.530944, "mean_ms": 0.580567, "min_ms": 0.425984, "max_ms": 1.477632, "std_ms": 0.184217}}, "audited_timestamp": "2026-12-01T23:28:48.305686+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.8847, "raw_speedup": 0.8847, "ref_ms": 0.380928, "cand_ms": 0.430592, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.380928, "mean_ms": 0.398418, "min_ms": 0.376832, "max_ms": 0.487424, "std_ms": 0.028503}, "cand_stats": {"median_ms": 0.430592, "mean_ms": 0.44503, "min_ms": 0.380928, "max_ms": 1.07008, "std_ms": 0.095561}}} +{"timestamp": "2026-12-01T19:35:44.536302+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_029_softplus", "source_kb_id": 29, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_029_softplus.py", "reference_code": "\"\"\"Task kb1_029_softplus (KernelBench Level 1 #29, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_029_softplus (KernelBench Level 1 #29, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement numerically stable Softplus in Triton: x when x > 20 else log(1 + exp(x)).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef softplus_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = tl.where(xf > 20.0, xf, tl.log(1.0 + tl.exp(xf)))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n softplus_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8533, "raw_speedup": 0.8533, "ref_ms": 0.470528, "cand_ms": 0.551424, "max_abs_diff": 4.76837158203125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.470528, "mean_ms": 0.505897, "min_ms": 0.436224, "max_ms": 0.740352, "std_ms": 0.075704}, "cand_stats": {"median_ms": 0.551424, "mean_ms": 0.586097, "min_ms": 0.459776, "max_ms": 0.897024, "std_ms": 0.097947}}, "audited_timestamp": "2026-12-01T23:28:53.475121+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0027, "raw_speedup": 1.0027, "ref_ms": 0.380928, "cand_ms": 0.379904, "max_abs_diff": 4.76837158203125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.380928, "mean_ms": 0.381768, "min_ms": 0.376832, "max_ms": 0.41472, "std_ms": 0.005413}, "cand_stats": {"median_ms": 0.379904, "mean_ms": 0.391455, "min_ms": 0.376832, "max_ms": 0.520192, "std_ms": 0.032825}}} +{"timestamp": "2026-12-01T19:35:48.892355+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_030_softsign", "source_kb_id": 30, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_030_softsign.py", "reference_code": "\"\"\"Task kb1_030_softsign (KernelBench Level 1 #30, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_030_softsign\"\nSOURCE_KB_ID = 30\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softsign activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softsign activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softsign applied, same shape as input.\n \"\"\"\n return x / (1 + torch.abs(x))\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_030_softsign (KernelBench Level 1 #30, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_030_softsign\"\nSOURCE_KB_ID = 30\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softsign activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softsign activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softsign applied, same shape as input.\n \"\"\"\n return x / (1 + torch.abs(x))\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise Softsign in Triton: x / (1 + |x|).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef softsign_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = xf / (1.0 + tl.abs(xf))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n softsign_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 2.624, "raw_speedup": 2.624, "ref_ms": 1.48992, "cand_ms": 0.567808, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.48992, "mean_ms": 1.680445, "min_ms": 1.41824, "max_ms": 2.924544, "std_ms": 0.376225}, "cand_stats": {"median_ms": 0.567808, "mean_ms": 0.595169, "min_ms": 0.444416, "max_ms": 0.930816, "std_ms": 0.100393}}, "audited_timestamp": "2026-12-01T23:28:58.770842+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 3.1576, "raw_speedup": 3.1576, "ref_ms": 1.312768, "cand_ms": 0.415744, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.312768, "mean_ms": 1.318298, "min_ms": 1.308672, "max_ms": 1.37216, "std_ms": 0.015084}, "cand_stats": {"median_ms": 0.415744, "mean_ms": 0.422666, "min_ms": 0.37888, "max_ms": 0.49152, "std_ms": 0.025468}}} +{"timestamp": "2026-12-01T19:35:53.123448+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_031_elu", "source_kb_id": 31, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_031_elu.py", "reference_code": "\"\"\"Task kb1_031_elu (KernelBench Level 1 #31, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_031_elu\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_031_elu (KernelBench Level 1 #31, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_031_elu\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise ELU in Triton matching Model.__init__(alpha=1.0).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef elu_kernel(x_ptr, out_ptr, n_elements, alpha, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = tl.where(xf > 0.0, xf, alpha * (tl.exp(xf) - 1.0))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, alpha: float = 1.0):\n super().__init__()\n self.alpha = alpha\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n elu_kernel[grid](x, out, n_elements, self.alpha, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9065, "raw_speedup": 0.9065, "ref_ms": 0.461824, "cand_ms": 0.50944, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.461824, "mean_ms": 0.472003, "min_ms": 0.42496, "max_ms": 0.541696, "std_ms": 0.02535}, "cand_stats": {"median_ms": 0.50944, "mean_ms": 0.528916, "min_ms": 0.4352, "max_ms": 1.022976, "std_ms": 0.095865}}, "audited_timestamp": "2026-12-01T23:29:05.213890+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0027, "raw_speedup": 1.0027, "ref_ms": 0.379904, "cand_ms": 0.37888, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.379904, "mean_ms": 0.388157, "min_ms": 0.376832, "max_ms": 0.538624, "std_ms": 0.03084}, "cand_stats": {"median_ms": 0.37888, "mean_ms": 0.383549, "min_ms": 0.376832, "max_ms": 0.528384, "std_ms": 0.022724}}} +{"timestamp": "2026-12-01T19:35:57.188867+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_032_hardtanh", "source_kb_id": 32, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_032_hardtanh.py", "reference_code": "\"\"\"Task kb1_032_hardtanh (KernelBench Level 1 #32, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_032_hardtanh\"\nSOURCE_KB_ID = 32\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardTanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardTanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardTanh applied, same shape as input.\n \"\"\"\n return F.hardtanh(x, min_val=-1., max_val=1.)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_032_hardtanh (KernelBench Level 1 #32, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_032_hardtanh\"\nSOURCE_KB_ID = 32\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardTanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardTanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardTanh applied, same shape as input.\n \"\"\"\n return F.hardtanh(x, min_val=-1., max_val=1.)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise HardTanh in Triton: clamp(x, -1.0, 1.0).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef hardtanh_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = tl.minimum(tl.maximum(xf, -1.0), 1.0)\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n hardtanh_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.0286, "raw_speedup": 1.0286, "ref_ms": 0.551936, "cand_ms": 0.536576, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.551936, "mean_ms": 0.604508, "min_ms": 0.443392, "max_ms": 1.00864, "std_ms": 0.119637}, "cand_stats": {"median_ms": 0.536576, "mean_ms": 0.578028, "min_ms": 0.442368, "max_ms": 0.989184, "std_ms": 0.114752}}, "audited_timestamp": "2026-12-01T23:29:10.449619+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9987, "raw_speedup": 0.9987, "ref_ms": 0.37888, "cand_ms": 0.379392, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.37888, "mean_ms": 0.383386, "min_ms": 0.375808, "max_ms": 0.44032, "std_ms": 0.015504}, "cand_stats": {"median_ms": 0.379392, "mean_ms": 0.386806, "min_ms": 0.376832, "max_ms": 0.531456, "std_ms": 0.024837}}} +{"timestamp": "2026-12-01T19:36:02.393543+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_033_batchnorm", "source_kb_id": 33, "category": "normalization", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_033_batchnorm.py", "reference_code": "\"\"\"Task kb1_033_batchnorm (KernelBench Level 1 #33, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_033_batchnorm (KernelBench Level 1 #33, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton BatchNorm2d inference kernel preserving self.bn = nn.BatchNorm2d(num_features).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef batchnorm2d_eval_kernel(\n x_ptr, out_ptr, w_ptr, b_ptr, mean_ptr, var_ptr,\n n_elements, C, HW, eps, BLOCK_SIZE: tl.constexpr,\n):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n c = (offsets // HW) % C\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n mean = tl.load(mean_ptr + c, mask=mask, other=0.0).to(tl.float32)\n var = tl.load(var_ptr + c, mask=mask, other=1.0).to(tl.float32)\n w = tl.load(w_ptr + c, mask=mask, other=1.0).to(tl.float32)\n b = tl.load(b_ptr + c, mask=mask, other=0.0).to(tl.float32)\n y = (x.to(tl.float32) - mean) * tl.rsqrt(var + eps) * w + b\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, num_features: int):\n super().__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, H, W = x.shape\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n batchnorm2d_eval_kernel[grid](\n x, out, self.bn.weight, self.bn.bias,\n self.bn.running_mean, self.bn.running_var,\n n_elements, C, H * W, self.bn.eps, BLOCK_SIZE=1024,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9983, "raw_speedup": 0.9983, "ref_ms": 0.92672, "cand_ms": 0.928256, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.92672, "mean_ms": 0.951398, "min_ms": 0.845824, "max_ms": 1.190912, "std_ms": 0.08132}, "cand_stats": {"median_ms": 0.928256, "mean_ms": 0.98943, "min_ms": 0.827392, "max_ms": 1.80224, "std_ms": 0.175488}}, "audited_timestamp": "2026-12-01T23:29:16.699427+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0074, "raw_speedup": 1.0074, "ref_ms": 0.765952, "cand_ms": 0.76032, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.765952, "mean_ms": 0.7808, "min_ms": 0.761856, "max_ms": 1.26464, "std_ms": 0.072513}, "cand_stats": {"median_ms": 0.76032, "mean_ms": 0.797123, "min_ms": 0.75264, "max_ms": 1.193984, "std_ms": 0.08447}}} +{"timestamp": "2026-12-01T19:36:07.895496+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_034_instancenorm", "source_kb_id": 34, "category": "normalization", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_034_instancenorm.py", "reference_code": "\"\"\"Task kb1_034_instancenorm (KernelBench Level 1 #34, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_034_instancenorm\"\nSOURCE_KB_ID = 34\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Instance Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the InstanceNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.inorm = nn.InstanceNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Instance Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Instance Normalization applied, same shape as input.\n \"\"\"\n return self.inorm(x)\n\nbatch_size = 112 # heavier workload\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_034_instancenorm (KernelBench Level 1 #34, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_034_instancenorm\"\nSOURCE_KB_ID = 34\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Instance Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the InstanceNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.inorm = nn.InstanceNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Instance Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Instance Normalization applied, same shape as input.\n \"\"\"\n return self.inorm(x)\n\nbatch_size = 112 # heavier workload\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton InstanceNorm2d kernel normalizing each (n, c) plane over H*W.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef instancenorm2d_kernel(x_ptr, out_ptr, HW, eps, BLOCK_SIZE: tl.constexpr):\n nc = tl.program_id(0)\n base = nc * HW\n sum_x = 0.0\n sum_x2 = 0.0\n for off in range(0, HW, BLOCK_SIZE):\n idx = off + tl.arange(0, BLOCK_SIZE)\n mask = idx < HW\n x = tl.load(x_ptr + base + idx, mask=mask, other=0.0).to(tl.float32)\n sum_x += tl.sum(x, axis=0)\n sum_x2 += tl.sum(x * x, axis=0)\n mean = sum_x / HW\n var = tl.maximum(sum_x2 / HW - mean * mean, 0.0)\n rstd = tl.rsqrt(var + eps)\n for off in range(0, HW, BLOCK_SIZE):\n idx = off + tl.arange(0, BLOCK_SIZE)\n mask = idx < HW\n x = tl.load(x_ptr + base + idx, mask=mask, other=0.0)\n tl.store(out_ptr + base + idx, ((x.to(tl.float32) - mean) * rstd).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, num_features: int):\n super().__init__()\n self.inorm = nn.InstanceNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, H, W = x.shape\n out = torch.empty_like(x)\n instancenorm2d_kernel[(N * C,)](x, out, H * W, self.inorm.eps, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.0203, "raw_speedup": 1.0203, "ref_ms": 1.387008, "cand_ms": 1.35936, "max_abs_diff": 1.430511474609375e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.387008, "mean_ms": 1.382748, "min_ms": 1.252352, "max_ms": 1.719296, "std_ms": 0.089461}, "cand_stats": {"median_ms": 1.35936, "mean_ms": 1.357046, "min_ms": 1.226752, "max_ms": 1.513472, "std_ms": 0.050863}}, "audited_timestamp": "2026-12-01T23:29:22.579877+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0406, "raw_speedup": 1.0406, "ref_ms": 1.156096, "cand_ms": 1.11104, "max_abs_diff": 1.430511474609375e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.156096, "mean_ms": 1.183826, "min_ms": 1.13664, "max_ms": 1.583104, "std_ms": 0.086264}, "cand_stats": {"median_ms": 1.11104, "mean_ms": 1.127936, "min_ms": 1.108992, "max_ms": 1.360896, "std_ms": 0.04767}}} +{"timestamp": "2026-12-01T19:36:13.196058+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_035_groupnorm", "source_kb_id": 35, "category": "normalization", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_035_groupnorm.py", "reference_code": "\"\"\"Task kb1_035_groupnorm (KernelBench Level 1 #35, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_035_groupnorm (KernelBench Level 1 #35, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton GroupNorm kernel normalizing each (n, g) group with affine weight/bias from self.gn.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef groupnorm_kernel(x_ptr, out_ptr, w_ptr, b_ptr, C, G, HW, eps, BLOCK_SIZE: tl.constexpr):\n ng = tl.program_id(0)\n n = ng // G\n g = ng % G\n c_per_g = C // G\n group_size = c_per_g * HW\n base = (n * C + g * c_per_g) * HW\n sum_x = 0.0\n sum_x2 = 0.0\n for off in range(0, group_size, BLOCK_SIZE):\n idx = off + tl.arange(0, BLOCK_SIZE)\n mask = idx < group_size\n x = tl.load(x_ptr + base + idx, mask=mask, other=0.0).to(tl.float32)\n sum_x += tl.sum(x, axis=0)\n sum_x2 += tl.sum(x * x, axis=0)\n mean = sum_x / group_size\n var = tl.maximum(sum_x2 / group_size - mean * mean, 0.0)\n rstd = tl.rsqrt(var + eps)\n for off in range(0, group_size, BLOCK_SIZE):\n idx = off + tl.arange(0, BLOCK_SIZE)\n mask = idx < group_size\n c = g * c_per_g + (idx // HW)\n x = tl.load(x_ptr + base + idx, mask=mask, other=0.0)\n w = tl.load(w_ptr + c, mask=mask, other=1.0).to(tl.float32)\n b = tl.load(b_ptr + c, mask=mask, other=0.0).to(tl.float32)\n tl.store(out_ptr + base + idx, ((x.to(tl.float32) - mean) * rstd * w + b).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, num_features: int, num_groups: int):\n super().__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, H, W = x.shape\n G = self.gn.num_groups\n out = torch.empty_like(x)\n groupnorm_kernel[(N * G,)](x, out, self.gn.weight, self.gn.bias, C, G, H * W, self.gn.eps, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.0574, "raw_speedup": 1.0574, "ref_ms": 1.357824, "cand_ms": 1.284096, "max_abs_diff": 1.430511474609375e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.357824, "mean_ms": 1.356288, "min_ms": 1.273856, "max_ms": 1.436672, "std_ms": 0.023595}, "cand_stats": {"median_ms": 1.284096, "mean_ms": 1.299825, "min_ms": 1.18272, "max_ms": 1.554432, "std_ms": 0.066705}}, "audited_timestamp": "2026-12-01T23:29:28.416060+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0192, "raw_speedup": 1.0192, "ref_ms": 1.19552, "cand_ms": 1.172992, "max_abs_diff": 1.430511474609375e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.19552, "mean_ms": 1.222492, "min_ms": 1.189888, "max_ms": 1.44384, "std_ms": 0.059539}, "cand_stats": {"median_ms": 1.172992, "mean_ms": 1.167933, "min_ms": 1.108992, "max_ms": 1.32096, "std_ms": 0.059934}}} +{"timestamp": "2026-12-01T19:36:19.102767+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_037_frobeniusnorm", "source_kb_id": 37, "category": "normalization", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_037_frobeniusnorm.py", "reference_code": "\"\"\"Task kb1_037_frobeniusnorm (KernelBench Level 1 #37, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_037_frobeniusnorm\"\nSOURCE_KB_ID = 37\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Frobenius norm normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the Frobenius norm normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Frobenius norm normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with Frobenius norm normalization applied, same shape as input.\n \"\"\"\n norm = torch.norm(x, p='fro')\n return x / norm\n\nbatch_size = 112\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_037_frobeniusnorm (KernelBench Level 1 #37, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_037_frobeniusnorm\"\nSOURCE_KB_ID = 37\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Frobenius norm normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the Frobenius norm normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Frobenius norm normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with Frobenius norm normalization applied, same shape as input.\n \"\"\"\n norm = torch.norm(x, p='fro')\n return x / norm\n\nbatch_size = 112\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Two-stage Triton Frobenius normalization: block sum-of-squares + fused scalar scale.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef sum_sq_partial_kernel(x_ptr, partial_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n tl.store(partial_ptr + pid, tl.sum(x * x, axis=0))\n\n@triton.jit\ndef div_scalar_kernel(x_ptr, out_ptr, inv_norm_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n inv_norm = tl.load(inv_norm_ptr)\n tl.store(out_ptr + offsets, (x.to(tl.float32) * inv_norm).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n n_elements = x.numel()\n BLOCK_SIZE = 1024\n n_blocks = triton.cdiv(n_elements, BLOCK_SIZE)\n partial = torch.empty((n_blocks,), device=x.device, dtype=torch.float32)\n sum_sq_partial_kernel[(n_blocks,)](x, partial, n_elements, BLOCK_SIZE=BLOCK_SIZE)\n inv_norm = torch.rsqrt(partial.sum())\n out = torch.empty_like(x)\n div_scalar_kernel[(n_blocks,)](x, out, inv_norm, n_elements, BLOCK_SIZE=BLOCK_SIZE)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 10, "speedup": 1.0064, "raw_speedup": 1.0064, "ref_ms": 1.28, "cand_ms": 1.271808, "max_abs_diff": 2.3283064365386963e-10, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.28, "mean_ms": 1.3073, "min_ms": 1.175552, "max_ms": 1.824768, "std_ms": 0.121902}, "cand_stats": {"median_ms": 1.271808, "mean_ms": 1.299558, "min_ms": 1.204224, "max_ms": 1.67936, "std_ms": 0.090717}}, "audited_timestamp": "2026-12-01T23:29:34.295849+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9632, "raw_speedup": 0.9632, "ref_ms": 1.153024, "cand_ms": 1.197056, "max_abs_diff": 2.3283064365386963e-10, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.153024, "mean_ms": 1.167708, "min_ms": 1.11104, "max_ms": 1.41312, "std_ms": 0.066083}, "cand_stats": {"median_ms": 1.197056, "mean_ms": 1.195172, "min_ms": 1.123328, "max_ms": 1.437696, "std_ms": 0.065025}}} +{"timestamp": "2026-12-01T19:36:23.537367+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_038_l1norm", "source_kb_id": 38, "category": "normalization", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_038_l1norm.py", "reference_code": "\"\"\"Task kb1_038_l1norm (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_038_l1norm (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused row-wise Triton L1 normalization: x / mean(|x|, dim=1, keepdim=True).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef l1_norm_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n sum_abs = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n sum_abs += tl.sum(tl.abs(x), axis=0)\n inv_mean = n_cols / sum_abs\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0)\n tl.store(out_ptr + row * stride_row + cols, (x.to(tl.float32) * inv_mean).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n n_rows, n_cols = x.shape\n out = torch.empty_like(x)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 4096)\n l1_norm_kernel[(n_rows,)](x, out, x.stride(0), n_cols, BLOCK_SIZE=BLOCK_SIZE)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.5267, "raw_speedup": 1.5267, "ref_ms": 1.055232, "cand_ms": 0.6912, "max_abs_diff": 1.430511474609375e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.055232, "mean_ms": 1.076777, "min_ms": 0.986112, "max_ms": 1.430528, "std_ms": 0.087321}, "cand_stats": {"median_ms": 0.6912, "mean_ms": 0.695992, "min_ms": 0.644096, "max_ms": 0.813056, "std_ms": 0.02912}}, "audited_timestamp": "2026-12-01T23:29:40.962677+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.6612, "raw_speedup": 1.6612, "ref_ms": 0.939008, "cand_ms": 0.565248, "max_abs_diff": 1.430511474609375e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.939008, "mean_ms": 0.950047, "min_ms": 0.935936, "max_ms": 1.01888, "std_ms": 0.023314}, "cand_stats": {"median_ms": 0.565248, "mean_ms": 0.588247, "min_ms": 0.557056, "max_ms": 0.748544, "std_ms": 0.040203}}} +{"timestamp": "2026-12-01T19:36:27.673383+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_039_l2norm", "source_kb_id": 39, "category": "normalization", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_039_l2norm.py", "reference_code": "\"\"\"Task kb1_039_l2norm (KernelBench Level 1 #39, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_039_l2norm (KernelBench Level 1 #39, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused row-wise Triton L2 normalization: x / sqrt(sum(x^2, dim=1, keepdim=True)).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef l2_norm_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n sum_sq = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n sum_sq += tl.sum(x * x, axis=0)\n inv_norm = tl.rsqrt(sum_sq)\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0)\n tl.store(out_ptr + row * stride_row + cols, (x.to(tl.float32) * inv_norm).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n n_rows, n_cols = x.shape\n out = torch.empty_like(x)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 4096)\n l2_norm_kernel[(n_rows,)](x, out, x.stride(0), n_cols, BLOCK_SIZE=BLOCK_SIZE)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9398, "raw_speedup": 0.9398, "ref_ms": 0.638976, "cand_ms": 0.679936, "max_abs_diff": 1.4901161193847656e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.638976, "mean_ms": 0.639918, "min_ms": 0.607232, "max_ms": 0.683008, "std_ms": 0.013927}, "cand_stats": {"median_ms": 0.679936, "mean_ms": 0.678359, "min_ms": 0.618496, "max_ms": 0.771072, "std_ms": 0.031085}}, "audited_timestamp": "2026-12-01T23:29:45.927397+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0046, "raw_speedup": 1.0046, "ref_ms": 0.562176, "cand_ms": 0.559616, "max_abs_diff": 1.4901161193847656e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.562176, "mean_ms": 0.568074, "min_ms": 0.561152, "max_ms": 0.661504, "std_ms": 0.019967}, "cand_stats": {"median_ms": 0.559616, "mean_ms": 0.596726, "min_ms": 0.555008, "max_ms": 0.741376, "std_ms": 0.049363}}} +{"timestamp": "2026-12-01T19:36:32.141468+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_041_max_pooling_1d", "source_kb_id": 41, "category": "pooling", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_041_max_pooling_1d.py", "reference_code": "\"\"\"Task kb1_041_max_pooling_1d (KernelBench Level 1 #41, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_041_max_pooling_1d\"\nSOURCE_KB_ID = 41\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max Pooling 1D.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False):\n \"\"\"\n Initializes the Max Pooling 1D layer.\n\n Args:\n kernel_size (int): Size of the window to take a max over.\n stride (int, optional): Stride of the window. Defaults to None (same as kernel_size).\n padding (int, optional): Implicit zero padding to be added on both sides. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n return_indices (bool, optional): Whether to return the indices of the maximum values. Defaults to False.\n \"\"\"\n super(Model, self).__init__()\n self.maxpool = nn.MaxPool1d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max Pooling 1D to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, sequence_length).\n\n Returns:\n torch.Tensor: Output tensor with Max Pooling 1D applied, shape (batch_size, num_features, output_sequence_length).\n \"\"\"\n return self.maxpool(x)\n\nbatch_size = 64\nfeatures = 192\nsequence_length = 65536\n\nkernel_size = 8\nstride = 1\npadding = 4\ndilation = 3 \n\nreturn_indices = False\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nsequence_length = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, features, sequence_length)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding, dilation, return_indices]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_041_max_pooling_1d (KernelBench Level 1 #41, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_041_max_pooling_1d\"\nSOURCE_KB_ID = 41\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max Pooling 1D.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False):\n \"\"\"\n Initializes the Max Pooling 1D layer.\n\n Args:\n kernel_size (int): Size of the window to take a max over.\n stride (int, optional): Stride of the window. Defaults to None (same as kernel_size).\n padding (int, optional): Implicit zero padding to be added on both sides. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n return_indices (bool, optional): Whether to return the indices of the maximum values. Defaults to False.\n \"\"\"\n super(Model, self).__init__()\n self.maxpool = nn.MaxPool1d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max Pooling 1D to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, sequence_length).\n\n Returns:\n torch.Tensor: Output tensor with Max Pooling 1D applied, shape (batch_size, num_features, output_sequence_length).\n \"\"\"\n return self.maxpool(x)\n\nbatch_size = 64\nfeatures = 192\nsequence_length = 65536\n\nkernel_size = 8\nstride = 1\npadding = 4\ndilation = 3 \n\nreturn_indices = False\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nsequence_length = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, features, sequence_length)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding, dilation, return_indices]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton MaxPool1D kernel matching exact Model.__init__(kernel_size, stride, padding, dilation, return_indices).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef maxpool1d_kernel(x_ptr, out_ptr, L_in, L_out, K: tl.constexpr, stride, padding, dilation, BLOCK_L: tl.constexpr):\n nc = tl.program_id(0)\n l_out = tl.program_id(1) * BLOCK_L + tl.arange(0, BLOCK_L)\n out_mask = l_out < L_out\n best = tl.full((BLOCK_L,), -float(\"inf\"), dtype=tl.float32)\n for k in range(K):\n l_in = l_out * stride - padding + k * dilation\n in_mask = out_mask & (l_in >= 0) & (l_in < L_in)\n vals = tl.load(x_ptr + nc * L_in + l_in, mask=in_mask, other=-float(\"inf\")).to(tl.float32)\n best = tl.maximum(best, vals)\n tl.store(out_ptr + nc * L_out + l_out, best, mask=out_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False):\n super().__init__()\n self.kernel_size = kernel_size\n self.stride = stride if stride is not None else kernel_size\n self.padding = padding\n self.dilation = dilation\n self.return_indices = return_indices\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, L_in = x.shape\n L_out = (L_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n out = torch.empty((N, C, L_out), device=x.device, dtype=x.dtype)\n BLOCK_L = 256\n maxpool1d_kernel[(N * C, triton.cdiv(L_out, BLOCK_L))](\n x, out, L_in, L_out, K=self.kernel_size, stride=self.stride, padding=self.padding, dilation=self.dilation, BLOCK_L=BLOCK_L,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.9704, "raw_speedup": 1.9704, "ref_ms": 1.056256, "cand_ms": 0.536064, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.056256, "mean_ms": 1.096909, "min_ms": 1.019904, "max_ms": 1.565696, "std_ms": 0.109838}, "cand_stats": {"median_ms": 0.536064, "mean_ms": 0.563118, "min_ms": 0.495616, "max_ms": 0.87552, "std_ms": 0.071007}}, "audited_timestamp": "2026-12-01T23:29:51.011762+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 2.2577, "raw_speedup": 2.2577, "ref_ms": 0.90624, "cand_ms": 0.401408, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.90624, "mean_ms": 0.892314, "min_ms": 0.82432, "max_ms": 1.29024, "std_ms": 0.09063}, "cand_stats": {"median_ms": 0.401408, "mean_ms": 0.414454, "min_ms": 0.400384, "max_ms": 0.485376, "std_ms": 0.025665}}} +{"timestamp": "2026-12-01T19:36:36.092757+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_043_max_pooling_3d", "source_kb_id": 43, "category": "pooling", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_043_max_pooling_3d.py", "reference_code": "\"\"\"Task kb1_043_max_pooling_3d (KernelBench Level 1 #43, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_043_max_pooling_3d\"\nSOURCE_KB_ID = 43\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max Pooling 3D.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False, ceil_mode: bool = False):\n \"\"\"\n Initializes the Max Pooling 3D layer.\n\n Args:\n kernel_size (int): Size of the kernel for the max pooling operation.\n stride (int, optional): Stride of the pooling operation. Defaults to None, which means stride is equal to kernel_size.\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n return_indices (bool, optional): Whether to return indices of the maximum values. Defaults to False.\n ceil_mode (bool, optional): When True, the output size is ceil(input_size / stride) instead of floor. Defaults to False.\n \"\"\"\n super(Model, self).__init__()\n self.maxpool = nn.MaxPool3d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices, ceil_mode=ceil_mode)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max Pooling 3D to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, dim1, dim2, dim3).\n\n Returns:\n torch.Tensor: Output tensor with Max Pooling 3D applied.\n \"\"\"\n return self.maxpool(x)\n\nbatch_size = 16\nchannels = 32\ndim1 = 128\ndim2 = 128\ndim3 = 128\nkernel_size = 3\nstride = 2\npadding = 1\ndilation = 3\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nchannels = 16\ndim1 = 32\ndim2 = 32\ndim3 = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, dim1, dim2, dim3)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding, dilation]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_043_max_pooling_3d (KernelBench Level 1 #43, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_043_max_pooling_3d\"\nSOURCE_KB_ID = 43\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max Pooling 3D.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False, ceil_mode: bool = False):\n \"\"\"\n Initializes the Max Pooling 3D layer.\n\n Args:\n kernel_size (int): Size of the kernel for the max pooling operation.\n stride (int, optional): Stride of the pooling operation. Defaults to None, which means stride is equal to kernel_size.\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n return_indices (bool, optional): Whether to return indices of the maximum values. Defaults to False.\n ceil_mode (bool, optional): When True, the output size is ceil(input_size / stride) instead of floor. Defaults to False.\n \"\"\"\n super(Model, self).__init__()\n self.maxpool = nn.MaxPool3d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices, ceil_mode=ceil_mode)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max Pooling 3D to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, dim1, dim2, dim3).\n\n Returns:\n torch.Tensor: Output tensor with Max Pooling 3D applied.\n \"\"\"\n return self.maxpool(x)\n\nbatch_size = 16\nchannels = 32\ndim1 = 128\ndim2 = 128\ndim3 = 128\nkernel_size = 3\nstride = 2\npadding = 1\ndilation = 3\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nchannels = 16\ndim1 = 32\ndim2 = 32\ndim3 = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, dim1, dim2, dim3)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding, dilation]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton MaxPool3D kernel matching exact Model.__init__ signature.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef maxpool3d_kernel(x_ptr, out_ptr, D_in, H_in, W_in, D_out, H_out, W_out, K: tl.constexpr, stride, padding, dilation, BLOCK: tl.constexpr):\n nc = tl.program_id(0)\n total_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < total_out\n wo = idx % W_out\n ho = (idx // W_out) % H_out\n do = idx // (W_out * H_out)\n best = tl.full((BLOCK,), -float(\"inf\"), dtype=tl.float32)\n x_base = nc * D_in * H_in * W_in\n for kd in range(K):\n di = do * stride - padding + kd * dilation\n for kh in range(K):\n hi = ho * stride - padding + kh * dilation\n for kw in range(K):\n wi = wo * stride - padding + kw * dilation\n m = out_mask & (di >= 0) & (di < D_in) & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n v = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=-float(\"inf\")).to(tl.float32)\n best = tl.maximum(best, v)\n tl.store(out_ptr + nc * total_out + idx, best, mask=out_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False, ceil_mode: bool = False):\n super().__init__()\n self.kernel_size = kernel_size\n self.stride = stride if stride is not None else kernel_size\n self.padding = padding\n self.dilation = dilation\n self.return_indices = return_indices\n self.ceil_mode = ceil_mode\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, D_in, H_in, W_in = x.shape\n D_out = (D_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n H_out = (H_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n W_out = (W_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n out = torch.empty((N, C, D_out, H_out, W_out), device=x.device, dtype=x.dtype)\n BLOCK = 256\n maxpool3d_kernel[(N * C, triton.cdiv(D_out * H_out * W_out, BLOCK))](\n x, out, D_in, H_in, W_in, D_out, H_out, W_out,\n K=self.kernel_size, stride=self.stride, padding=self.padding, dilation=self.dilation, BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9884, "raw_speedup": 0.9884, "ref_ms": 0.17408, "cand_ms": 0.176128, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.17408, "mean_ms": 0.201093, "min_ms": 0.164864, "max_ms": 0.316416, "std_ms": 0.040692}, "cand_stats": {"median_ms": 0.176128, "mean_ms": 0.196936, "min_ms": 0.104448, "max_ms": 0.772096, "std_ms": 0.100417}}, "audited_timestamp": "2026-12-01T23:29:55.733631+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 2.1091, "raw_speedup": 2.1091, "ref_ms": 0.118784, "cand_ms": 0.05632, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.118784, "mean_ms": 0.121815, "min_ms": 0.11776, "max_ms": 0.22016, "std_ms": 0.016683}, "cand_stats": {"median_ms": 0.05632, "mean_ms": 0.074998, "min_ms": 0.054272, "max_ms": 0.118784, "std_ms": 0.022459}}} +{"timestamp": "2026-12-01T19:36:40.627983+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_044_average_pooling_1d", "source_kb_id": 44, "category": "pooling", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_044_average_pooling_1d.py", "reference_code": "\"\"\"Task kb1_044_average_pooling_1d (KernelBench Level 1 #44, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_044_average_pooling_1d\"\nSOURCE_KB_ID = 44\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 1D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = 1, padding: int = 0):\n \"\"\"\n Initializes the 1D Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the pooling window.\n stride (int, optional): Stride of the pooling operation. Defaults to 1.\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool1d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies 1D Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, input_length).\n\n Returns:\n torch.Tensor: Output tensor with 1D Average Pooling applied, shape (batch_size, in_channels, output_length).\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 64\nin_channels = 128\ninput_length = 65536\nkernel_size = 8\nstride = 1\npadding = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\ninput_length = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, input_length)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_044_average_pooling_1d (KernelBench Level 1 #44, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_044_average_pooling_1d\"\nSOURCE_KB_ID = 44\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 1D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = 1, padding: int = 0):\n \"\"\"\n Initializes the 1D Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the pooling window.\n stride (int, optional): Stride of the pooling operation. Defaults to 1.\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool1d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies 1D Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, input_length).\n\n Returns:\n torch.Tensor: Output tensor with 1D Average Pooling applied, shape (batch_size, in_channels, output_length).\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 64\nin_channels = 128\ninput_length = 65536\nkernel_size = 8\nstride = 1\npadding = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\ninput_length = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, input_length)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton AvgPool1D kernel matching Model.__init__(kernel_size, stride=1, padding=0).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef avgpool1d_kernel(x_ptr, out_ptr, L_in, L_out, K: tl.constexpr, stride, padding, BLOCK_L: tl.constexpr):\n nc = tl.program_id(0)\n l_out = tl.program_id(1) * BLOCK_L + tl.arange(0, BLOCK_L)\n out_mask = l_out < L_out\n acc = tl.zeros((BLOCK_L,), dtype=tl.float32)\n for k in range(K):\n l_in = l_out * stride - padding + k\n in_mask = out_mask & (l_in >= 0) & (l_in < L_in)\n acc += tl.load(x_ptr + nc * L_in + l_in, mask=in_mask, other=0.0).to(tl.float32)\n tl.store(out_ptr + nc * L_out + l_out, acc / K, mask=out_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, kernel_size: int, stride: int = 1, padding: int = 0):\n super().__init__()\n self.kernel_size = kernel_size\n self.stride = stride if stride is not None else kernel_size\n self.padding = padding\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, L_in = x.shape\n L_out = (L_in + 2 * self.padding - self.kernel_size) // self.stride + 1\n out = torch.empty((N, C, L_out), device=x.device, dtype=x.dtype)\n BLOCK_L = 256\n avgpool1d_kernel[(N * C, triton.cdiv(L_out, BLOCK_L))](\n x, out, L_in, L_out, K=self.kernel_size, stride=self.stride, padding=self.padding, BLOCK_L=BLOCK_L,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.9089, "raw_speedup": 1.9089, "ref_ms": 1.179648, "cand_ms": 0.617984, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.179648, "mean_ms": 1.240535, "min_ms": 1.087488, "max_ms": 2.272256, "std_ms": 0.209554}, "cand_stats": {"median_ms": 0.617984, "mean_ms": 0.644383, "min_ms": 0.504832, "max_ms": 1.09056, "std_ms": 0.129976}}, "audited_timestamp": "2026-12-01T23:30:01.014044+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 2.5547, "raw_speedup": 2.5547, "ref_ms": 1.004544, "cand_ms": 0.393216, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.004544, "mean_ms": 1.045443, "min_ms": 0.991232, "max_ms": 1.803264, "std_ms": 0.125813}, "cand_stats": {"median_ms": 0.393216, "mean_ms": 0.407245, "min_ms": 0.391168, "max_ms": 0.623616, "std_ms": 0.040577}}} +{"timestamp": "2026-12-01T19:36:48.567757+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_045_average_pooling_2d", "source_kb_id": 45, "category": "pooling", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_045_average_pooling_2d.py", "reference_code": "\"\"\"Task kb1_045_average_pooling_2d (KernelBench Level 1 #45, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_045_average_pooling_2d\"\nSOURCE_KB_ID = 45\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 2D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):\n \"\"\"\n Initializes the Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the pooling window.\n stride (int, optional): Stride of the pooling operation. Defaults to None (same as kernel_size).\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool2d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies 2D Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Average Pooling applied.\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 16\nchannels = 64\nheight = 2048\nwidth = 2048\nkernel_size = 11\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nchannels = 64\nheight = 256\nwidth = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_045_average_pooling_2d (KernelBench Level 1 #45, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_045_average_pooling_2d\"\nSOURCE_KB_ID = 45\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 2D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):\n \"\"\"\n Initializes the Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the pooling window.\n stride (int, optional): Stride of the pooling operation. Defaults to None (same as kernel_size).\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool2d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies 2D Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Average Pooling applied.\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 16\nchannels = 64\nheight = 2048\nwidth = 2048\nkernel_size = 11\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nchannels = 64\nheight = 256\nwidth = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton AvgPool2D kernel matching Model.__init__(kernel_size, stride=None, padding=0).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef avgpool2d_kernel(x_ptr, out_ptr, H_in, W_in, H_out, W_out, K: tl.constexpr, stride, padding, BLOCK: tl.constexpr):\n nc = tl.program_id(0)\n total_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < total_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n x_base = nc * H_in * W_in\n for kh in range(K):\n hi = ho * stride - padding + kh\n for kw in range(K):\n wi = wo * stride - padding + kw\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n acc += tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n tl.store(out_ptr + nc * total_out + idx, acc / (K * K), mask=out_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):\n super().__init__()\n self.kernel_size = kernel_size\n self.stride = stride if stride is not None else kernel_size\n self.padding = padding\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, H_in, W_in = x.shape\n H_out = (H_in + 2 * self.padding - self.kernel_size) // self.stride + 1\n W_out = (W_in + 2 * self.padding - self.kernel_size) // self.stride + 1\n out = torch.empty((N, C, H_out, W_out), device=x.device, dtype=x.dtype)\n BLOCK = 256\n avgpool2d_kernel[(N * C, triton.cdiv(H_out * W_out, BLOCK))](\n x, out, H_in, W_in, H_out, W_out, K=self.kernel_size, stride=self.stride, padding=self.padding, BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.7565, "raw_speedup": 0.7565, "ref_ms": 1.765888, "cand_ms": 2.334208, "max_abs_diff": 5.960464477539063e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.765888, "mean_ms": 1.833267, "min_ms": 1.589248, "max_ms": 2.849792, "std_ms": 0.255802}, "cand_stats": {"median_ms": 2.334208, "mean_ms": 2.422333, "min_ms": 2.026496, "max_ms": 3.249152, "std_ms": 0.317451}}, "audited_timestamp": "2026-12-01T23:30:08.839642+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.7594, "raw_speedup": 0.7594, "ref_ms": 1.507328, "cand_ms": 1.985024, "max_abs_diff": 5.960464477539063e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.507328, "mean_ms": 1.530122, "min_ms": 1.50016, "max_ms": 1.934336, "std_ms": 0.070234}, "cand_stats": {"median_ms": 1.985024, "mean_ms": 2.035692, "min_ms": 1.910784, "max_ms": 2.612224, "std_ms": 0.133222}}} +{"timestamp": "2026-12-01T19:36:52.942218+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_046_average_pooling_3d", "source_kb_id": 46, "category": "pooling", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_046_average_pooling_3d.py", "reference_code": "\"\"\"Task kb1_046_average_pooling_3d (KernelBench Level 1 #46, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_046_average_pooling_3d\"\nSOURCE_KB_ID = 46\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 3D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):\n \"\"\"\n Initializes the Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the kernel to apply pooling.\n stride (int, optional): Stride of the pooling operation. Defaults to None, which uses the kernel size.\n padding (int, optional): Padding to apply before pooling. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool3d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Average Pooling applied, shape depends on kernel_size, stride and padding.\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 16\nchannels = 32\ndepth = 128\nheight = 128\nwidth = 256\nkernel_size = 3\nstride = 2\npadding = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nchannels = 16\ndepth = 32\nheight = 32\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_046_average_pooling_3d (KernelBench Level 1 #46, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_046_average_pooling_3d\"\nSOURCE_KB_ID = 46\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 3D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):\n \"\"\"\n Initializes the Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the kernel to apply pooling.\n stride (int, optional): Stride of the pooling operation. Defaults to None, which uses the kernel size.\n padding (int, optional): Padding to apply before pooling. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool3d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Average Pooling applied, shape depends on kernel_size, stride and padding.\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 16\nchannels = 32\ndepth = 128\nheight = 128\nwidth = 256\nkernel_size = 3\nstride = 2\npadding = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nchannels = 16\ndepth = 32\nheight = 32\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton AvgPool3D kernel matching Model.__init__(kernel_size, stride=None, padding=0).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef avgpool3d_kernel(x_ptr, out_ptr, D_in, H_in, W_in, D_out, H_out, W_out, K: tl.constexpr, stride, padding, BLOCK: tl.constexpr):\n nc = tl.program_id(0)\n total_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < total_out\n wo = idx % W_out\n ho = (idx // W_out) % H_out\n do = idx // (W_out * H_out)\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n x_base = nc * D_in * H_in * W_in\n for kd in range(K):\n di = do * stride - padding + kd\n for kh in range(K):\n hi = ho * stride - padding + kh\n for kw in range(K):\n wi = wo * stride - padding + kw\n m = out_mask & (di >= 0) & (di < D_in) & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n acc += tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n tl.store(out_ptr + nc * total_out + idx, acc / (K * K * K), mask=out_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):\n super().__init__()\n self.kernel_size = kernel_size\n self.stride = stride if stride is not None else kernel_size\n self.padding = padding\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, D_in, H_in, W_in = x.shape\n D_out = (D_in + 2 * self.padding - self.kernel_size) // self.stride + 1\n H_out = (H_in + 2 * self.padding - self.kernel_size) // self.stride + 1\n W_out = (W_in + 2 * self.padding - self.kernel_size) // self.stride + 1\n out = torch.empty((N, C, D_out, H_out, W_out), device=x.device, dtype=x.dtype)\n BLOCK = 256\n avgpool3d_kernel[(N * C, triton.cdiv(D_out * H_out * W_out, BLOCK))](\n x, out, D_in, H_in, W_in, D_out, H_out, W_out, K=self.kernel_size, stride=self.stride, padding=self.padding, BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8395, "raw_speedup": 0.8395, "ref_ms": 0.184832, "cand_ms": 0.22016, "max_abs_diff": 5.960464477539063e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.184832, "mean_ms": 0.20267, "min_ms": 0.175104, "max_ms": 0.290816, "std_ms": 0.029232}, "cand_stats": {"median_ms": 0.22016, "mean_ms": 0.251351, "min_ms": 0.171008, "max_ms": 0.64512, "std_ms": 0.082758}}, "audited_timestamp": "2026-12-01T23:30:15.186490+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.1622, "raw_speedup": 1.1622, "ref_ms": 0.132096, "cand_ms": 0.113664, "max_abs_diff": 5.960464477539063e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.132096, "mean_ms": 0.133837, "min_ms": 0.131072, "max_ms": 0.216064, "std_ms": 0.011888}, "cand_stats": {"median_ms": 0.113664, "mean_ms": 0.117535, "min_ms": 0.11264, "max_ms": 0.161792, "std_ms": 0.011375}}} +{"timestamp": "2026-12-01T19:36:57.333506+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_048_mean_reduction_over_a_dimension", "source_kb_id": 48, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_048_mean_reduction_over_a_dimension.py", "reference_code": "\"\"\"Task kb1_048_mean_reduction_over_a_dimension (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_048_mean_reduction_over_a_dimension (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton mean reduction over arbitrary dim using strided outer/inner indexing.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef mean_reduce_kernel(x_ptr, out_ptr, reduce_size, inner_size, BLOCK_R: tl.constexpr):\n pid = tl.program_id(0)\n outer = pid // inner_size\n inner = pid % inner_size\n base = outer * reduce_size * inner_size + inner\n acc = 0.0\n for r_start in range(0, reduce_size, BLOCK_R):\n r = r_start + tl.arange(0, BLOCK_R)\n mask = r < reduce_size\n vals = tl.load(x_ptr + base + r * inner_size, mask=mask, other=0.0).to(tl.float32)\n acc += tl.sum(vals, axis=0)\n tl.store(out_ptr + pid, acc / reduce_size)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n dim = self.dim % x.ndim\n outer_size = 1\n for s in x.shape[:dim]:\n outer_size *= s\n reduce_size = x.shape[dim]\n inner_size = 1\n for s in x.shape[dim + 1:]:\n inner_size *= s\n out = torch.empty(x.shape[:dim] + x.shape[dim + 1:], device=x.device, dtype=x.dtype)\n BLOCK_R = min(triton.next_power_of_2(reduce_size), 1024)\n mean_reduce_kernel[(outer_size * inner_size,)](x, out, reduce_size, inner_size, BLOCK_R=BLOCK_R)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.3544, "raw_speedup": 0.3544, "ref_ms": 0.241664, "cand_ms": 0.681984, "max_abs_diff": 2.9802322387695312e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.241664, "mean_ms": 0.281088, "min_ms": 0.238592, "max_ms": 0.81408, "std_ms": 0.102316}, "cand_stats": {"median_ms": 0.681984, "mean_ms": 0.732877, "min_ms": 0.605184, "max_ms": 1.332224, "std_ms": 0.130908}}, "audited_timestamp": "2026-12-01T23:30:20.273537+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.4216, "raw_speedup": 0.4216, "ref_ms": 0.195584, "cand_ms": 0.463872, "max_abs_diff": 2.9802322387695312e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.195584, "mean_ms": 0.198656, "min_ms": 0.19456, "max_ms": 0.257024, "std_ms": 0.012344}, "cand_stats": {"median_ms": 0.463872, "mean_ms": 0.47743, "min_ms": 0.461824, "max_ms": 0.54272, "std_ms": 0.025911}}} +{"timestamp": "2026-12-01T19:37:01.582989+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_049_max_reduction_over_a_dimension", "source_kb_id": 49, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_049_max_reduction_over_a_dimension.py", "reference_code": "\"\"\"Task kb1_049_max_reduction_over_a_dimension (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_049_max_reduction_over_a_dimension (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton max reduction over arbitrary dim using strided outer/inner indexing.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef max_reduce_kernel(x_ptr, out_ptr, reduce_size, inner_size, BLOCK_R: tl.constexpr):\n pid = tl.program_id(0)\n outer = pid // inner_size\n inner = pid % inner_size\n base = outer * reduce_size * inner_size + inner\n best = -float(\"inf\")\n for r_start in range(0, reduce_size, BLOCK_R):\n r = r_start + tl.arange(0, BLOCK_R)\n mask = r < reduce_size\n vals = tl.load(x_ptr + base + r * inner_size, mask=mask, other=-float(\"inf\")).to(tl.float32)\n best = tl.maximum(best, tl.max(vals, axis=0))\n tl.store(out_ptr + pid, best)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n dim = self.dim % x.ndim\n outer_size = 1\n for s in x.shape[:dim]:\n outer_size *= s\n reduce_size = x.shape[dim]\n inner_size = 1\n for s in x.shape[dim + 1:]:\n inner_size *= s\n out = torch.empty(x.shape[:dim] + x.shape[dim + 1:], device=x.device, dtype=x.dtype)\n BLOCK_R = min(triton.next_power_of_2(reduce_size), 1024)\n max_reduce_kernel[(outer_size * inner_size,)](x, out, reduce_size, inner_size, BLOCK_R=BLOCK_R)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.5565, "raw_speedup": 0.5565, "ref_ms": 0.363008, "cand_ms": 0.652288, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.363008, "mean_ms": 0.407265, "min_ms": 0.31232, "max_ms": 0.88064, "std_ms": 0.097931}, "cand_stats": {"median_ms": 0.652288, "mean_ms": 0.754258, "min_ms": 0.53248, "max_ms": 2.26816, "std_ms": 0.296449}}, "audited_timestamp": "2026-12-01T23:30:25.385664+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.4628, "raw_speedup": 0.4628, "ref_ms": 0.251904, "cand_ms": 0.544256, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.251904, "mean_ms": 0.258601, "min_ms": 0.198656, "max_ms": 0.3072, "std_ms": 0.023504}, "cand_stats": {"median_ms": 0.544256, "mean_ms": 0.55083, "min_ms": 0.477184, "max_ms": 0.606208, "std_ms": 0.024537}}} +{"timestamp": "2026-12-01T19:37:05.762484+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_052_argmin_over_a_dimension", "source_kb_id": 52, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_052_argmin_over_a_dimension.py", "reference_code": "\"\"\"Task kb1_052_argmin_over_a_dimension (KernelBench Level 1 #52, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_052_argmin_over_a_dimension\"\nSOURCE_KB_ID = 52\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that finds the index of the minimum value along a specified dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to perform argmin on.\n\n Args:\n dim (int): Dimension along which to find the minimum value.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Finds the index of the minimum value along the specified dimension.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Tensor containing the indices of the minimum values along the specified dimension.\n \"\"\"\n return torch.argmin(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [dim]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_052_argmin_over_a_dimension (KernelBench Level 1 #52, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_052_argmin_over_a_dimension\"\nSOURCE_KB_ID = 52\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that finds the index of the minimum value along a specified dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to perform argmin on.\n\n Args:\n dim (int): Dimension along which to find the minimum value.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Finds the index of the minimum value along the specified dimension.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Tensor containing the indices of the minimum values along the specified dimension.\n \"\"\"\n return torch.argmin(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [dim]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton argmin over arbitrary dim returning int64 indices via block-wise tl.min + tl.argmin.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef argmin_kernel(x_ptr, out_ptr, reduce_size, inner_size, BLOCK_R: tl.constexpr):\n pid = tl.program_id(0)\n outer = pid // inner_size\n inner = pid % inner_size\n base = outer * reduce_size * inner_size + inner\n best_val = float(\"inf\")\n best_idx = 0\n for r_start in range(0, reduce_size, BLOCK_R):\n r = r_start + tl.arange(0, BLOCK_R)\n mask = r < reduce_size\n vals = tl.load(x_ptr + base + r * inner_size, mask=mask, other=float(\"inf\")).to(tl.float32)\n cur_min = tl.min(vals, axis=0)\n cur_arg = r_start + tl.argmin(vals, axis=0)\n is_better = cur_min < best_val\n best_val = tl.where(is_better, cur_min, best_val)\n best_idx = tl.where(is_better, cur_arg, best_idx)\n tl.store(out_ptr + pid, best_idx.to(tl.int64))\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n dim = self.dim % x.ndim\n outer_size = 1\n for s in x.shape[:dim]:\n outer_size *= s\n reduce_size = x.shape[dim]\n inner_size = 1\n for s in x.shape[dim + 1:]:\n inner_size *= s\n out = torch.empty(x.shape[:dim] + x.shape[dim + 1:], device=x.device, dtype=torch.int64)\n BLOCK_R = min(triton.next_power_of_2(reduce_size), 1024)\n argmin_kernel[(outer_size * inner_size,)](x, out, reduce_size, inner_size, BLOCK_R=BLOCK_R)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.5057, "raw_speedup": 0.5057, "ref_ms": 0.316416, "cand_ms": 0.625664, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "int64", "error": null, "ref_stats": {"median_ms": 0.316416, "mean_ms": 0.321229, "min_ms": 0.243712, "max_ms": 0.507904, "std_ms": 0.057113}, "cand_stats": {"median_ms": 0.625664, "mean_ms": 0.654131, "min_ms": 0.572416, "max_ms": 0.995328, "std_ms": 0.084015}}, "audited_timestamp": "2026-12-01T23:30:30.653087+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.4181, "raw_speedup": 0.4181, "ref_ms": 0.198656, "cand_ms": 0.475136, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "int64", "error": null, "ref_stats": {"median_ms": 0.198656, "mean_ms": 0.203059, "min_ms": 0.197632, "max_ms": 0.246784, "std_ms": 0.013063}, "cand_stats": {"median_ms": 0.475136, "mean_ms": 0.485171, "min_ms": 0.474112, "max_ms": 0.57856, "std_ms": 0.025246}}} +{"timestamp": "2026-12-01T19:37:09.902619+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_053_min_reduction_over_a_dimension", "source_kb_id": 53, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_053_min_reduction_over_a_dimension.py", "reference_code": "\"\"\"Task kb1_053_min_reduction_over_a_dimension (KernelBench Level 1 #53, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_053_min_reduction_over_a_dimension\"\nSOURCE_KB_ID = 53\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs min reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies min reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after min reduction over the specified dimension.\n \"\"\"\n return torch.min(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_053_min_reduction_over_a_dimension (KernelBench Level 1 #53, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_053_min_reduction_over_a_dimension\"\nSOURCE_KB_ID = 53\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs min reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies min reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after min reduction over the specified dimension.\n \"\"\"\n return torch.min(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton min reduction over arbitrary dim using strided outer/inner indexing.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef min_reduce_kernel(x_ptr, out_ptr, reduce_size, inner_size, BLOCK_R: tl.constexpr):\n pid = tl.program_id(0)\n outer = pid // inner_size\n inner = pid % inner_size\n base = outer * reduce_size * inner_size + inner\n best = float(\"inf\")\n for r_start in range(0, reduce_size, BLOCK_R):\n r = r_start + tl.arange(0, BLOCK_R)\n mask = r < reduce_size\n vals = tl.load(x_ptr + base + r * inner_size, mask=mask, other=float(\"inf\")).to(tl.float32)\n best = tl.minimum(best, tl.min(vals, axis=0))\n tl.store(out_ptr + pid, best)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n dim = self.dim % x.ndim\n outer_size = 1\n for s in x.shape[:dim]:\n outer_size *= s\n reduce_size = x.shape[dim]\n inner_size = 1\n for s in x.shape[dim + 1:]:\n inner_size *= s\n out = torch.empty(x.shape[:dim] + x.shape[dim + 1:], device=x.device, dtype=x.dtype)\n BLOCK_R = min(triton.next_power_of_2(reduce_size), 1024)\n min_reduce_kernel[(outer_size * inner_size,)](x, out, reduce_size, inner_size, BLOCK_R=BLOCK_R)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.4147, "raw_speedup": 0.4147, "ref_ms": 0.260096, "cand_ms": 0.6272, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.260096, "mean_ms": 0.279511, "min_ms": 0.242688, "max_ms": 0.564224, "std_ms": 0.055119}, "cand_stats": {"median_ms": 0.6272, "mean_ms": 0.653578, "min_ms": 0.54784, "max_ms": 0.9472, "std_ms": 0.079101}}, "audited_timestamp": "2026-12-01T23:30:35.696133+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.4571, "raw_speedup": 0.4571, "ref_ms": 0.24832, "cand_ms": 0.543232, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.24832, "mean_ms": 0.256778, "min_ms": 0.203776, "max_ms": 0.340992, "std_ms": 0.020585}, "cand_stats": {"median_ms": 0.543232, "mean_ms": 0.545772, "min_ms": 0.516096, "max_ms": 0.67072, "std_ms": 0.023769}}} +{"timestamp": "2026-12-01T19:37:17.114375+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_055_conv_standard_2d_asymmetric_input_square_kernel", "source_kb_id": 55, "category": "convolution", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_055_conv_standard_2d_asymmetric_input_square_kernel.py", "reference_code": "\"\"\"Task kb1_055_conv_standard_2d_asymmetric_input_square_kernel (KernelBench Level 1 #55, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_055_conv_standard_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 55\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\n# smaller spatial dims\nheight = 512\nwidth = 1024\nin_channels = 64 # increased channels\nout_channels = 128\nkernel_size = 3\n# asymmetric input: make width considerably larger than height\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nheight = 128\nwidth = 256\nin_channels = 32\nout_channels = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_055_conv_standard_2d_asymmetric_input_square_kernel (KernelBench Level 1 #55, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_055_conv_standard_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 55\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\n# smaller spatial dims\nheight = 512\nwidth = 1024\nin_channels = 64 # increased channels\nout_channels = 128\nkernel_size = 3\n# asymmetric input: make width considerably larger than height\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nheight = 128\nwidth = 256\nin_channels = 32\nout_channels = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton direct Conv2D kernel preserving self.conv2d = nn.Conv2d(...) signature and weights.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef conv2d_kernel(x_ptr, w_ptr, out_ptr, C_in, H_in, W_in, C_out, H_out, W_out, K: tl.constexpr, stride, padding, dilation, BLOCK_HW: tl.constexpr):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n for ci in range(C_in):\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (co * C_in + ci) * K * K\n for kh in range(K):\n hi = ho * stride - padding + kh * dilation\n for kw in range(K):\n wi = wo * stride - padding + kw * dilation\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n acc += tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32) * tl.load(w_ptr + w_base + kh * K + kw).to(tl.float32)\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super().__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n self.kernel_size = kernel_size\n self.stride = stride\n self.padding = padding\n self.dilation = dilation\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n w = self.conv2d.weight.contiguous()\n N, C_in, H_in, W_in = x.shape\n C_out = w.shape[0]\n H_out = (H_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n W_out = (W_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x.device, dtype=x.dtype)\n BLOCK_HW = 256\n conv2d_kernel[(N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))](\n x, w, out, C_in, H_in, W_in, C_out, H_out, W_out,\n K=self.kernel_size, stride=self.stride, padding=self.padding, dilation=self.dilation, BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.1252, "raw_speedup": 0.1252, "ref_ms": 1.038336, "cand_ms": 8.29184, "max_abs_diff": 0.0004495978355407715, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.038336, "mean_ms": 1.062216, "min_ms": 0.943104, "max_ms": 1.381376, "std_ms": 0.082563}, "cand_stats": {"median_ms": 8.29184, "mean_ms": 8.538112, "min_ms": 8.19712, "max_ms": 11.287552, "std_ms": 0.681545}}, "audited_timestamp": "2026-12-01T23:30:45.601924+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.135, "raw_speedup": 0.135, "ref_ms": 1.112064, "cand_ms": 8.239616, "max_abs_diff": 0.0004495978355407715, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.112064, "mean_ms": 1.170309, "min_ms": 1.108992, "max_ms": 1.769472, "std_ms": 0.148599}, "cand_stats": {"median_ms": 8.239616, "mean_ms": 8.310313, "min_ms": 7.979008, "max_ms": 9.331712, "std_ms": 0.253655}}} +{"timestamp": "2026-12-01T19:37:26.497047+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_076_conv_standard_1d_dilated_strided", "source_kb_id": 76, "category": "convolution", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_076_conv_standard_1d_dilated_strided.py", "reference_code": "\"\"\"Task kb1_076_conv_standard_1d_dilated_strided (KernelBench Level 1 #76, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_076_conv_standard_1d_dilated_strided\"\nSOURCE_KB_ID = 76\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 1D convolution operation with asymmetric input and a square kernel, potentially dilated and strided.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d = nn.Conv1d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 64\nout_channels = 128\nkernel_size = 3\n# longer signal\nlength = 524280\nstride = 3\ndilation = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nlength = 32768\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, dilation]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_076_conv_standard_1d_dilated_strided (KernelBench Level 1 #76, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_076_conv_standard_1d_dilated_strided\"\nSOURCE_KB_ID = 76\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 1D convolution operation with asymmetric input and a square kernel, potentially dilated and strided.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d = nn.Conv1d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 64\nout_channels = 128\nkernel_size = 3\n# longer signal\nlength = 524280\nstride = 3\ndilation = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nlength = 32768\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, dilation]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton strided/dilated Conv1D kernel preserving self.conv1d = nn.Conv1d(...) signature and weights.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef conv1d_kernel(x_ptr, w_ptr, out_ptr, C_in, L_in, C_out, L_out, K: tl.constexpr, stride, dilation, BLOCK_L: tl.constexpr):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n lo = tl.program_id(1) * BLOCK_L + tl.arange(0, BLOCK_L)\n out_mask = lo < L_out\n acc = tl.zeros((BLOCK_L,), dtype=tl.float32)\n for ci in range(C_in):\n x_base = (n * C_in + ci) * L_in\n w_base = (co * C_in + ci) * K\n for k in range(K):\n li = lo * stride + k * dilation\n m = out_mask & (li < L_in)\n acc += tl.load(x_ptr + x_base + li, mask=m, other=0.0).to(tl.float32) * tl.load(w_ptr + w_base + k).to(tl.float32)\n tl.store(out_ptr + nc_out * L_out + lo, acc, mask=out_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, dilation: int = 1, bias: bool = False):\n super().__init__()\n self.conv1d = nn.Conv1d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, bias=bias)\n self.kernel_size = kernel_size\n self.stride = stride\n self.dilation = dilation\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n w = self.conv1d.weight.contiguous()\n N, C_in, L_in = x.shape\n C_out = w.shape[0]\n L_out = (L_in - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n out = torch.empty((N, C_out, L_out), device=x.device, dtype=x.dtype)\n BLOCK_L = 256\n conv1d_kernel[(N * C_out, triton.cdiv(L_out, BLOCK_L))](\n x, w, out, C_in, L_in, C_out, L_out,\n K=self.kernel_size, stride=self.stride, dilation=self.dilation, BLOCK_L=BLOCK_L,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.1729, "raw_speedup": 0.1729, "ref_ms": 2.246656, "cand_ms": 12.990976, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.246656, "mean_ms": 2.627277, "min_ms": 1.874944, "max_ms": 16.96768, "std_ms": 2.107841}, "cand_stats": {"median_ms": 12.990976, "mean_ms": 13.213737, "min_ms": 12.017664, "max_ms": 15.59552, "std_ms": 0.797506}}, "audited_timestamp": "2026-12-01T23:30:54.564726+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.1508, "raw_speedup": 0.1508, "ref_ms": 1.87392, "cand_ms": 12.425728, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.87392, "mean_ms": 1.962373, "min_ms": 1.767424, "max_ms": 3.233792, "std_ms": 0.290963}, "cand_stats": {"median_ms": 12.425728, "mean_ms": 12.441846, "min_ms": 12.201984, "max_ms": 13.032448, "std_ms": 0.14874}}} +{"timestamp": "2026-12-01T19:37:31.604242+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel", "source_kb_id": 83, "category": "convolution", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel.py", "reference_code": "\"\"\"Task kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel (KernelBench Level 1 #83, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 83\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, in_channels, kernel_size=(kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, in_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 8\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 0\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 16\nwidth = 256\nheight = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, kernel_size, stride, padding, dilation]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel (KernelBench Level 1 #83, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 83\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, in_channels, kernel_size=(kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, in_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 8\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 0\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 16\nwidth = 256\nheight = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, kernel_size, stride, padding, dilation]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton depthwise 2D asymmetric (K, 1) conv preserving self.conv2d signature and weights.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef dw_conv2d_kx1_kernel(x_ptr, w_ptr, out_ptr, C, H_in, W_in, H_out, W_out, K: tl.constexpr, stride, padding, dilation, BLOCK: tl.constexpr):\n nc = tl.program_id(0)\n c = nc % C\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n wi = wo * stride - padding\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n x_base = nc * H_in * W_in\n w_base = c * K\n for kh in range(K):\n hi = ho * stride - padding + kh * dilation\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n acc += tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32) * tl.load(w_ptr + w_base + kh).to(tl.float32)\n tl.store(out_ptr + nc * HW_out + idx, acc, mask=out_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super().__init__()\n self.conv2d = nn.Conv2d(in_channels, in_channels, kernel_size=(kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.kernel_size = kernel_size\n self.stride = stride\n self.padding = padding\n self.dilation = dilation\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n w = self.conv2d.weight.contiguous()\n N, C, H_in, W_in = x.shape\n H_out = (H_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n W_out = (W_in + 2 * self.padding - 1) // self.stride + 1\n out = torch.empty((N, C, H_out, W_out), device=x.device, dtype=x.dtype)\n BLOCK = 256\n dw_conv2d_kx1_kernel[(N * C, triton.cdiv(H_out * W_out, BLOCK))](\n x, w, out, C, H_in, W_in, H_out, W_out,\n K=self.kernel_size, stride=self.stride, padding=self.padding, dilation=self.dilation, BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 2.0781, "raw_speedup": 2.0781, "ref_ms": 2.233344, "cand_ms": 1.074688, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.233344, "mean_ms": 2.346066, "min_ms": 2.085888, "max_ms": 3.456, "std_ms": 0.295439}, "cand_stats": {"median_ms": 1.074688, "mean_ms": 1.146798, "min_ms": 0.95232, "max_ms": 1.588224, "std_ms": 0.160704}}, "audited_timestamp": "2026-12-01T23:31:00.878243+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 2.282, "raw_speedup": 2.282, "ref_ms": 2.108928, "cand_ms": 0.92416, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.108928, "mean_ms": 2.084475, "min_ms": 1.609728, "max_ms": 2.958336, "std_ms": 0.224172}, "cand_stats": {"median_ms": 0.92416, "mean_ms": 0.944456, "min_ms": 0.869376, "max_ms": 1.201152, "std_ms": 0.089103}}} +{"timestamp": "2026-12-01T19:37:36.450087+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel", "source_kb_id": 84, "category": "convolution", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel.py", "reference_code": "\"\"\"Task kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel (KernelBench Level 1 #84, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 84\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with asymmetric input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size), stride=stride, padding=padding, groups=in_channels, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 128\nout_channels = 128\nkernel_size = 3\nwidth_in = 512\nheight_in = 256\nstride = 1\npadding = 0\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 64\nwidth_in = 256\nheight_in = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel (KernelBench Level 1 #84, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 84\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with asymmetric input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size), stride=stride, padding=padding, groups=in_channels, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 128\nout_channels = 128\nkernel_size = 3\nwidth_in = 512\nheight_in = 256\nstride = 1\npadding = 0\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 64\nwidth_in = 256\nheight_in = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton depthwise 2D square conv preserving self.conv2d signature and weights.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef dw_conv2d_kernel(x_ptr, w_ptr, out_ptr, C, H_in, W_in, H_out, W_out, K: tl.constexpr, stride, padding, BLOCK: tl.constexpr):\n nc = tl.program_id(0)\n c = nc % C\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n x_base = nc * H_in * W_in\n w_base = c * K * K\n for kh in range(K):\n hi = ho * stride - padding + kh\n for kw in range(K):\n wi = wo * stride - padding + kw\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n acc += tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32) * tl.load(w_ptr + w_base + kh * K + kw).to(tl.float32)\n tl.store(out_ptr + nc * HW_out + idx, acc, mask=out_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, bias: bool = False):\n super().__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size), stride=stride, padding=padding, groups=in_channels, bias=bias)\n self.kernel_size = kernel_size\n self.stride = stride\n self.padding = padding\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n w = self.conv2d.weight.contiguous()\n N, C, H_in, W_in = x.shape\n H_out = (H_in + 2 * self.padding - self.kernel_size) // self.stride + 1\n W_out = (W_in + 2 * self.padding - self.kernel_size) // self.stride + 1\n out = torch.empty((N, C, H_out, W_out), device=x.device, dtype=x.dtype)\n BLOCK = 256\n dw_conv2d_kernel[(N * C, triton.cdiv(H_out * W_out, BLOCK))](\n x, w, out, C, H_in, W_in, H_out, W_out,\n K=self.kernel_size, stride=self.stride, padding=self.padding, BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.0573, "raw_speedup": 1.0573, "ref_ms": 1.54112, "cand_ms": 1.457664, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.54112, "mean_ms": 1.570304, "min_ms": 1.3824, "max_ms": 2.235392, "std_ms": 0.172496}, "cand_stats": {"median_ms": 1.457664, "mean_ms": 1.549988, "min_ms": 1.38752, "max_ms": 2.444288, "std_ms": 0.223762}}, "audited_timestamp": "2026-12-01T23:31:06.975395+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.2228, "raw_speedup": 1.2228, "ref_ms": 1.562624, "cand_ms": 1.277952, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.562624, "mean_ms": 1.505198, "min_ms": 1.250304, "max_ms": 2.062336, "std_ms": 0.161927}, "cand_stats": {"median_ms": 1.277952, "mean_ms": 1.314673, "min_ms": 1.267712, "max_ms": 1.645568, "std_ms": 0.087907}}} +{"timestamp": "2026-12-01T19:37:44.171094+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_086_conv_depthwise_separable_2d", "source_kb_id": 86, "category": "convolution", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_086_conv_depthwise_separable_2d.py", "reference_code": "\"\"\"Task kb1_086_conv_depthwise_separable_2d (KernelBench Level 1 #86, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_086_conv_depthwise_separable_2d\"\nSOURCE_KB_ID = 86\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise-separable 2D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise-separable 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n x = self.depthwise(x)\n x = self.pointwise(x)\n return x\n\n# Test code\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 1\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_086_conv_depthwise_separable_2d (KernelBench Level 1 #86, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_086_conv_depthwise_separable_2d\"\nSOURCE_KB_ID = 86\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise-separable 2D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise-separable 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n x = self.depthwise(x)\n x = self.pointwise(x)\n return x\n\n# Test code\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 1\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton depthwise-separable 2D conv (depthwise Triton kernel + 1x1 pointwise tiled Triton tl.dot kernel).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef dw_conv2d_dilated_kernel(x_ptr, w_ptr, out_ptr, C, H_in, W_in, H_out, W_out, K: tl.constexpr, stride, padding, dilation, BLOCK: tl.constexpr):\n nc = tl.program_id(0)\n c = nc % C\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n x_base = nc * H_in * W_in\n w_base = c * K * K\n for kh in range(K):\n hi = ho * stride - padding + kh * dilation\n for kw in range(K):\n wi = wo * stride - padding + kw * dilation\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n acc += tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32) * tl.load(w_ptr + w_base + kh * K + kw).to(tl.float32)\n tl.store(out_ptr + nc * HW_out + idx, acc, mask=out_mask)\n\n@triton.jit\ndef pointwise_mm_kernel(\n w_ptr, x_ptr, out_ptr, C_out, HW, C_in,\n stride_wc, stride_wk, stride_xn, stride_xk, stride_xhw, stride_on, stride_oc, stride_ohw,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr, USE_IEEE: tl.constexpr,\n):\n n = tl.program_id(2)\n offs_m = tl.program_id(0) * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = tl.program_id(1) * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, C_in, BLOCK_K):\n k_mask = (k_start + offs_k) < C_in\n w = tl.load(w_ptr + offs_m[:, None] * stride_wc + (k_start + offs_k)[None, :] * stride_wk, mask=(offs_m[:, None] < C_out) & k_mask[None, :], other=0.0)\n x = tl.load(x_ptr + n * stride_xn + (k_start + offs_k)[:, None] * stride_xk + offs_n[None, :] * stride_xhw, mask=k_mask[:, None] & (offs_n[None, :] < HW), other=0.0)\n if USE_IEEE:\n acc += tl.dot(w, x, input_precision=\"ieee\")\n else:\n acc += tl.dot(w, x)\n tl.store(out_ptr + n * stride_on + offs_m[:, None] * stride_oc + offs_n[None, :] * stride_ohw, acc, mask=(offs_m[:, None] < C_out) & (offs_n[None, :] < HW))\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super().__init__()\n self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias)\n self.kernel_size = kernel_size\n self.stride = stride\n self.padding = padding\n self.dilation = dilation\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C_in, H_in, W_in = x.shape\n H_out = (H_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n W_out = (W_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n dw_out = torch.empty((N, C_in, H_out, W_out), device=x.device, dtype=x.dtype)\n BLOCK = 256\n dw_conv2d_dilated_kernel[(N * C_in, triton.cdiv(H_out * W_out, BLOCK))](\n x, self.depthwise.weight.contiguous(), dw_out,\n C_in, H_in, W_in, H_out, W_out, K=self.kernel_size, stride=self.stride, padding=self.padding, dilation=self.dilation, BLOCK=BLOCK,\n )\n C_out = self.pointwise.weight.shape[0]\n HW = H_out * W_out\n w_pw = self.pointwise.weight.contiguous().view(C_out, C_in)\n dw_flat = dw_out.view(N, C_in, HW)\n out = torch.empty((N, C_out, HW), device=x.device, dtype=x.dtype)\n BM, BN, BK = 32, 64, 32\n pointwise_mm_kernel[(triton.cdiv(C_out, BM), triton.cdiv(HW, BN), N)](\n w_pw, dw_flat, out, C_out, HW, C_in,\n w_pw.stride(0), w_pw.stride(1),\n dw_flat.stride(0), dw_flat.stride(1), dw_flat.stride(2),\n out.stride(0), out.stride(1), out.stride(2),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(x.dtype == torch.float32),\n )\n return out.view(N, C_out, H_out, W_out)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 10, "speedup": 1.0816, "raw_speedup": 1.0816, "ref_ms": 1.505792, "cand_ms": 1.392128, "max_abs_diff": 0.00037276744842529297, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.505792, "mean_ms": 1.587855, "min_ms": 1.301504, "max_ms": 2.62144, "std_ms": 0.287664}, "cand_stats": {"median_ms": 1.392128, "mean_ms": 1.48523, "min_ms": 1.248256, "max_ms": 2.486272, "std_ms": 0.266168}}, "audited_timestamp": "2026-12-01T23:31:15.531246+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.2643, "raw_speedup": 1.2643, "ref_ms": 1.388544, "cand_ms": 1.09824, "max_abs_diff": 0.00037276744842529297, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.388544, "mean_ms": 1.39479, "min_ms": 1.381376, "max_ms": 1.514496, "std_ms": 0.024969}, "cand_stats": {"median_ms": 1.09824, "mean_ms": 1.14178, "min_ms": 1.08544, "max_ms": 1.349632, "std_ms": 0.061661}}} +{"timestamp": "2026-12-01T19:37:48.771728+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_088_mingptnewgelu", "source_kb_id": 88, "category": "activation", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_088_mingptnewgelu.py", "reference_code": "\"\"\"Task kb1_088_mingptnewgelu (KernelBench Level 1 #88, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_088_mingptnewgelu (KernelBench Level 1 #88, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fuse MinGPT NewGELU (0.5*x*(1 + tanh(sqrt(2/pi)*(x + 0.044715*x^3)))) into a single Triton pass.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef new_gelu_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n inner = 0.7978845608028654 * (xf + 0.044715 * xf * xf * xf)\n tanh_val = 2.0 * tl.sigmoid(2.0 * inner) - 1.0\n y = 0.5 * xf * (1.0 + tanh_val)\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n new_gelu_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 7.2295, "raw_speedup": 7.2295, "ref_ms": 3.6608, "cand_ms": 0.506368, "max_abs_diff": 4.76837158203125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 3.6608, "mean_ms": 3.791483, "min_ms": 3.479552, "max_ms": 4.639744, "std_ms": 0.317271}, "cand_stats": {"median_ms": 0.506368, "mean_ms": 0.530186, "min_ms": 0.438272, "max_ms": 1.122304, "std_ms": 0.114278}}, "audited_timestamp": "2026-12-01T23:31:22.777942+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 7.8779, "raw_speedup": 7.8779, "ref_ms": 3.436544, "cand_ms": 0.436224, "max_abs_diff": 4.76837158203125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 3.436544, "mean_ms": 3.437711, "min_ms": 3.372032, "max_ms": 3.658752, "std_ms": 0.061302}, "cand_stats": {"median_ms": 0.436224, "mean_ms": 0.437207, "min_ms": 0.376832, "max_ms": 0.697344, "std_ms": 0.06443}}} +{"timestamp": "2026-12-01T19:37:52.859887+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_090_cumprod", "source_kb_id": 90, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_090_cumprod.py", "reference_code": "\"\"\"Task kb1_090_cumprod (KernelBench Level 1 #90, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_090_cumprod\"\nSOURCE_KB_ID = 90\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a cumulative product operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the cumulative product operation.\n \"\"\"\n\n def __init__(self, dim):\n \"\"\"\n Initialize the CumulativeProductModel.\n\n Args:\n dim (int): The dimension along which to perform the cumulative product.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n \"\"\"\n Forward pass, computing the cumulative product along the specified dimension.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, *input_shape).\n\n Returns:\n torch.Tensor: Tensor of the same shape as `x` after applying cumulative product along `dim`.\n \"\"\"\n return torch.cumprod(x, dim=self.dim)\n\n# Define input dimensions and parameters\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (1024,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_090_cumprod (KernelBench Level 1 #90, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_090_cumprod\"\nSOURCE_KB_ID = 90\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a cumulative product operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the cumulative product operation.\n \"\"\"\n\n def __init__(self, dim):\n \"\"\"\n Initialize the CumulativeProductModel.\n\n Args:\n dim (int): The dimension along which to perform the cumulative product.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n \"\"\"\n Forward pass, computing the cumulative product along the specified dimension.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, *input_shape).\n\n Returns:\n torch.Tensor: Tensor of the same shape as `x` after applying cumulative product along `dim`.\n \"\"\"\n return torch.cumprod(x, dim=self.dim)\n\n# Define input dimensions and parameters\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (1024,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Row-wise Triton cumulative product via tl.associative_scan.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef _mul_combine(a, b):\n return a * b\n\n@triton.jit\ndef cumprod_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n cols = tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=1.0).to(tl.float32)\n y = tl.associative_scan(x, axis=0, combine_fn=_mul_combine)\n tl.store(out_ptr + row * stride_row + cols, y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n dim = self.dim % x.ndim\n x_t = x.transpose(dim, -1).contiguous()\n orig_shape = x_t.shape\n x_2d = x_t.view(-1, orig_shape[-1])\n n_rows, n_cols = x_2d.shape\n out = torch.empty_like(x_2d)\n cumprod_kernel[(n_rows,)](x_2d, out, x_2d.stride(0), n_cols, BLOCK_SIZE=triton.next_power_of_2(n_cols))\n return out.view(orig_shape).transpose(dim, -1).contiguous()\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9357, "raw_speedup": 0.9357, "ref_ms": 0.186368, "cand_ms": 0.199168, "max_abs_diff": 5.960464477539063e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.186368, "mean_ms": 0.203633, "min_ms": 0.181248, "max_ms": 0.555008, "std_ms": 0.056054}, "cand_stats": {"median_ms": 0.199168, "mean_ms": 0.208138, "min_ms": 0.14336, "max_ms": 0.318464, "std_ms": 0.033512}}, "audited_timestamp": "2026-12-01T23:31:27.838891+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.3958, "raw_speedup": 1.3958, "ref_ms": 0.137216, "cand_ms": 0.098304, "max_abs_diff": 5.960464477539063e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.137216, "mean_ms": 0.137441, "min_ms": 0.136192, "max_ms": 0.139264, "std_ms": 0.000909}, "cand_stats": {"median_ms": 0.098304, "mean_ms": 0.101069, "min_ms": 0.096256, "max_ms": 0.150528, "std_ms": 0.012175}}} +{"timestamp": "2026-12-01T19:37:58.151279+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_091_cumsum_reverse", "source_kb_id": 91, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_091_cumsum_reverse.py", "reference_code": "\"\"\"Task kb1_091_cumsum_reverse (KernelBench Level 1 #91, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_091_cumsum_reverse\"\nSOURCE_KB_ID = 91\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a reverse cumulative sum operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the reverse cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n return torch.cumsum(x.flip(self.dim), dim=self.dim).flip(self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_091_cumsum_reverse (KernelBench Level 1 #91, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_091_cumsum_reverse\"\nSOURCE_KB_ID = 91\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a reverse cumulative sum operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the reverse cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n return torch.cumsum(x.flip(self.dim), dim=self.dim).flip(self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Row-wise Triton reverse cumsum using tl.cumsum(..., reverse=True).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef cumsum_reverse_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n cols = tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n y = tl.cumsum(x, axis=0, reverse=True)\n tl.store(out_ptr + row * stride_row + cols, y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n dim = self.dim % x.ndim\n x_t = x.transpose(dim, -1).contiguous()\n orig_shape = x_t.shape\n x_2d = x_t.view(-1, orig_shape[-1])\n n_rows, n_cols = x_2d.shape\n out = torch.empty_like(x_2d)\n cumsum_reverse_kernel[(n_rows,)](x_2d, out, x_2d.stride(0), n_cols, BLOCK_SIZE=triton.next_power_of_2(n_cols))\n return out.view(orig_shape).transpose(dim, -1).contiguous()\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 2.5678, "raw_speedup": 2.5678, "ref_ms": 0.766464, "cand_ms": 0.298496, "max_abs_diff": 0.00115966796875, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.766464, "mean_ms": 0.814326, "min_ms": 0.692224, "max_ms": 1.85856, "std_ms": 0.201985}, "cand_stats": {"median_ms": 0.298496, "mean_ms": 0.321679, "min_ms": 0.236544, "max_ms": 0.466944, "std_ms": 0.055401}}, "audited_timestamp": "2026-12-01T23:31:33.231640+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 3.376, "raw_speedup": 3.376, "ref_ms": 0.648192, "cand_ms": 0.192, "max_abs_diff": 0.00115966796875, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.648192, "mean_ms": 0.651366, "min_ms": 0.64512, "max_ms": 0.699392, "std_ms": 0.011463}, "cand_stats": {"median_ms": 0.192, "mean_ms": 0.195441, "min_ms": 0.190464, "max_ms": 0.274432, "std_ms": 0.014884}}} +{"timestamp": "2026-12-01T19:38:02.364275+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_092_cumsum_exclusive", "source_kb_id": 92, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_092_cumsum_exclusive.py", "reference_code": "\"\"\"Task kb1_092_cumsum_exclusive (KernelBench Level 1 #92, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_092_cumsum_exclusive\"\nSOURCE_KB_ID = 92\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs an exclusive cumulative sum (does not include the current element).\n\n Parameters:\n dim (int): The dimension along which to perform the exclusive cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n cumsum = torch.cumsum(x.narrow(dim=self.dim, start=0, length=x.size(self.dim)-1), dim=self.dim)\n return torch.cat((torch.zeros_like(x.select(self.dim, 0).unsqueeze(self.dim)), cumsum), dim=self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_092_cumsum_exclusive (KernelBench Level 1 #92, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_092_cumsum_exclusive\"\nSOURCE_KB_ID = 92\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs an exclusive cumulative sum (does not include the current element).\n\n Parameters:\n dim (int): The dimension along which to perform the exclusive cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n cumsum = torch.cumsum(x.narrow(dim=self.dim, start=0, length=x.size(self.dim)-1), dim=self.dim)\n return torch.cat((torch.zeros_like(x.select(self.dim, 0).unsqueeze(self.dim)), cumsum), dim=self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Row-wise Triton exclusive cumsum: inclusive tl.cumsum(x) minus x.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef cumsum_exclusive_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n cols = tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n y = tl.cumsum(x, axis=0) - x\n tl.store(out_ptr + row * stride_row + cols, y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n dim = self.dim % x.ndim\n x_t = x.transpose(dim, -1).contiguous()\n orig_shape = x_t.shape\n x_2d = x_t.view(-1, orig_shape[-1])\n n_rows, n_cols = x_2d.shape\n out = torch.empty_like(x_2d)\n cumsum_exclusive_kernel[(n_rows,)](x_2d, out, x_2d.stride(0), n_cols, BLOCK_SIZE=triton.next_power_of_2(n_cols))\n return out.view(orig_shape).transpose(dim, -1).contiguous()\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 2.3277, "raw_speedup": 2.3277, "ref_ms": 0.771072, "cand_ms": 0.331264, "max_abs_diff": 0.0010986328125, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.771072, "mean_ms": 0.798044, "min_ms": 0.705536, "max_ms": 1.243136, "std_ms": 0.098883}, "cand_stats": {"median_ms": 0.331264, "mean_ms": 0.354857, "min_ms": 0.299008, "max_ms": 0.637952, "std_ms": 0.064144}}, "audited_timestamp": "2026-12-01T23:31:38.163531+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 3.4946, "raw_speedup": 3.4946, "ref_ms": 0.6656, "cand_ms": 0.190464, "max_abs_diff": 0.0010986328125, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.6656, "mean_ms": 0.677294, "min_ms": 0.661504, "max_ms": 0.756736, "std_ms": 0.023375}, "cand_stats": {"median_ms": 0.190464, "mean_ms": 0.194724, "min_ms": 0.18944, "max_ms": 0.27648, "std_ms": 0.014824}}} +{"timestamp": "2026-12-01T19:38:06.480376+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_093_masked_cumsum", "source_kb_id": 93, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_093_masked_cumsum.py", "reference_code": "\"\"\"Task kb1_093_masked_cumsum (KernelBench Level 1 #93, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_093_masked_cumsum\"\nSOURCE_KB_ID = 93\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a masked cumulative sum, only summing elements that satisfy a condition.\n\n Parameters:\n dim (int): The dimension along which to perform the masked cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x, mask):\n \"\"\"\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, *input_shape).\n mask (torch.Tensor): Boolean mask of the same shape as x.\n\n Returns:\n torch.Tensor: Cumulative sum of elements where mask is True.\n \"\"\"\n return torch.cumsum(x * mask, dim=self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n x = torch.rand(batch_size, *input_shape)\n mask = torch.randint(0, 2, x.shape).bool() # Random boolean mask\n return [x, mask]\n\ndef get_init_inputs():\n return [dim]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_093_masked_cumsum (KernelBench Level 1 #93, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_093_masked_cumsum\"\nSOURCE_KB_ID = 93\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a masked cumulative sum, only summing elements that satisfy a condition.\n\n Parameters:\n dim (int): The dimension along which to perform the masked cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x, mask):\n \"\"\"\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, *input_shape).\n mask (torch.Tensor): Boolean mask of the same shape as x.\n\n Returns:\n torch.Tensor: Cumulative sum of elements where mask is True.\n \"\"\"\n return torch.cumsum(x * mask, dim=self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n x = torch.rand(batch_size, *input_shape)\n mask = torch.randint(0, 2, x.shape).bool() # Random boolean mask\n return [x, mask]\n\ndef get_init_inputs():\n return [dim]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused row-wise Triton masked cumsum: tl.cumsum(tl.where(mask, x, 0.0)).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef masked_cumsum_kernel(x_ptr, m_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n cols = tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n m = tl.load(m_ptr + row * stride_row + cols, mask=mask, other=0)\n y = tl.cumsum(tl.where(m != 0, x, 0.0), axis=0)\n tl.store(out_ptr + row * stride_row + cols, y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor, mask: torch.Tensor) -> torch.Tensor:\n dim = self.dim % x.ndim\n x_t = x.transpose(dim, -1).contiguous()\n m_t = mask.transpose(dim, -1).contiguous()\n orig_shape = x_t.shape\n x_2d = x_t.view(-1, orig_shape[-1])\n m_2d = m_t.view(-1, orig_shape[-1])\n n_rows, n_cols = x_2d.shape\n out = torch.empty_like(x_2d)\n masked_cumsum_kernel[(n_rows,)](x_2d, m_2d, out, x_2d.stride(0), n_cols, BLOCK_SIZE=triton.next_power_of_2(n_cols))\n return out.view(orig_shape).transpose(dim, -1).contiguous()\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.7229, "raw_speedup": 1.7229, "ref_ms": 0.617472, "cand_ms": 0.3584, "max_abs_diff": 0.00048828125, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.617472, "mean_ms": 0.6306, "min_ms": 0.523264, "max_ms": 0.93696, "std_ms": 0.09353}, "cand_stats": {"median_ms": 0.3584, "mean_ms": 0.378286, "min_ms": 0.264192, "max_ms": 0.581632, "std_ms": 0.078306}}, "audited_timestamp": "2026-12-01T23:31:43.460912+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 2.25, "raw_speedup": 2.25, "ref_ms": 0.479232, "cand_ms": 0.212992, "max_abs_diff": 0.00048828125, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.479232, "mean_ms": 0.482836, "min_ms": 0.477184, "max_ms": 0.535552, "std_ms": 0.012124}, "cand_stats": {"median_ms": 0.212992, "mean_ms": 0.218747, "min_ms": 0.210944, "max_ms": 0.26624, "std_ms": 0.015547}}} +{"timestamp": "2026-12-01T19:38:11.136205+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_096_huberloss", "source_kb_id": 96, "category": "loss_attention", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_096_huberloss.py", "reference_code": "\"\"\"Task kb1_096_huberloss (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_096_huberloss (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton Smooth L1 (Huber, beta=1.0) loss with block reduction.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef huber_partial_kernel(pred_ptr, tgt_ptr, partial_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n p = tl.load(pred_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n t = tl.load(tgt_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n diff = tl.abs(p - t)\n loss = tl.where(mask, tl.where(diff < 1.0, 0.5 * diff * diff, diff - 0.5), 0.0)\n tl.store(partial_ptr + pid, tl.sum(loss, axis=0))\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, predictions: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:\n p = predictions.contiguous()\n t = targets.contiguous()\n n_elements = p.numel()\n BLOCK_SIZE = 1024\n n_blocks = triton.cdiv(n_elements, BLOCK_SIZE)\n partial = torch.empty((n_blocks,), device=p.device, dtype=torch.float32)\n huber_partial_kernel[(n_blocks,)](p, t, partial, n_elements, BLOCK_SIZE=BLOCK_SIZE)\n return (partial.sum() / n_elements).to(p.dtype)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.7765, "raw_speedup": 1.7765, "ref_ms": 0.919552, "cand_ms": 0.517632, "max_abs_diff": 1.4901161193847656e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.919552, "mean_ms": 0.988119, "min_ms": 0.813056, "max_ms": 1.618944, "std_ms": 0.204055}, "cand_stats": {"median_ms": 0.517632, "mean_ms": 0.557036, "min_ms": 0.442368, "max_ms": 0.90624, "std_ms": 0.093944}}, "audited_timestamp": "2026-12-01T23:31:49.182114+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 2.0243, "raw_speedup": 2.0243, "ref_ms": 0.769024, "cand_ms": 0.379904, "max_abs_diff": 1.4901161193847656e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.769024, "mean_ms": 0.780227, "min_ms": 0.765952, "max_ms": 0.868352, "std_ms": 0.023674}, "cand_stats": {"median_ms": 0.379904, "mean_ms": 0.386662, "min_ms": 0.37888, "max_ms": 0.433152, "std_ms": 0.015981}}} +{"timestamp": "2026-12-01T19:38:15.865090+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_098_kldivloss", "source_kb_id": 98, "category": "loss_attention", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_098_kldivloss.py", "reference_code": "\"\"\"Task kb1_098_kldivloss (KernelBench Level 1 #98, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_098_kldivloss\"\nSOURCE_KB_ID = 98\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Kullback-Leibler Divergence for comparing two distributions.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.kl_div(torch.log(predictions), targets, reduction='batchmean')\n\nbatch_size = 8192 * 2\ninput_shape = (8192 * 2,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [(torch.rand(batch_size, *input_shape)*scale).softmax(dim=-1), torch.rand(batch_size, *input_shape).softmax(dim=-1)]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_098_kldivloss (KernelBench Level 1 #98, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_098_kldivloss\"\nSOURCE_KB_ID = 98\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Kullback-Leibler Divergence for comparing two distributions.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.kl_div(torch.log(predictions), targets, reduction='batchmean')\n\nbatch_size = 8192 * 2\ninput_shape = (8192 * 2,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [(torch.rand(batch_size, *input_shape)*scale).softmax(dim=-1), torch.rand(batch_size, *input_shape).softmax(dim=-1)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton KLDivLoss (batchmean): sum(target * (log(target) - log(pred))) / batch_size.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef kldiv_partial_kernel(pred_ptr, tgt_ptr, partial_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n p = tl.load(pred_ptr + offsets, mask=mask, other=1.0).to(tl.float32)\n t = tl.load(tgt_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n kl = tl.where(mask & (t > 0.0), t * (tl.log(t) - tl.log(p)), 0.0)\n tl.store(partial_ptr + pid, tl.sum(kl, axis=0))\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, predictions: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:\n p = predictions.contiguous()\n t = targets.contiguous()\n n_elements = p.numel()\n BLOCK_SIZE = 1024\n n_blocks = triton.cdiv(n_elements, BLOCK_SIZE)\n partial = torch.empty((n_blocks,), device=p.device, dtype=torch.float32)\n kldiv_partial_kernel[(n_blocks,)](p, t, partial, n_elements, BLOCK_SIZE=BLOCK_SIZE)\n return (partial.sum() / p.shape[0]).to(p.dtype)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 4.0142, "raw_speedup": 4.0142, "ref_ms": 2.316288, "cand_ms": 0.577024, "max_abs_diff": 3.725290298461914e-09, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.316288, "mean_ms": 2.463887, "min_ms": 2.16064, "max_ms": 3.262464, "std_ms": 0.331387}, "cand_stats": {"median_ms": 0.577024, "mean_ms": 0.659804, "min_ms": 0.45056, "max_ms": 1.6384, "std_ms": 0.204893}}, "audited_timestamp": "2026-12-01T23:31:56.322116+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 5.4805, "raw_speedup": 5.4805, "ref_ms": 2.084864, "cand_ms": 0.380416, "max_abs_diff": 3.725290298461914e-09, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.084864, "mean_ms": 2.105795, "min_ms": 2.07872, "max_ms": 2.433024, "std_ms": 0.057522}, "cand_stats": {"median_ms": 0.380416, "mean_ms": 0.384, "min_ms": 0.376832, "max_ms": 0.43008, "std_ms": 0.013244}}} +{"timestamp": "2026-12-01T19:38:20.548679+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_099_tripletmarginloss", "source_kb_id": 99, "category": "loss_attention", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_099_tripletmarginloss.py", "reference_code": "\"\"\"Task kb1_099_tripletmarginloss (KernelBench Level 1 #99, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_099_tripletmarginloss\"\nSOURCE_KB_ID = 99\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Triplet Margin Loss for metric learning tasks.\n\n Parameters:\n margin (float): The margin between the positive and negative samples.\n \"\"\"\n def __init__(self, margin=1.0):\n super(Model, self).__init__()\n self.loss_fn = torch.nn.TripletMarginLoss(margin=margin)\n\n def forward(self, anchor, positive, negative):\n return self.loss_fn(anchor, positive, negative)\n\nbatch_size = 32768\ninput_shape = (8192,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape), torch.rand(batch_size, *input_shape)]\n \ndef get_init_inputs():\n return [1.0] # Default margin"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_099_tripletmarginloss (KernelBench Level 1 #99, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_099_tripletmarginloss\"\nSOURCE_KB_ID = 99\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Triplet Margin Loss for metric learning tasks.\n\n Parameters:\n margin (float): The margin between the positive and negative samples.\n \"\"\"\n def __init__(self, margin=1.0):\n super(Model, self).__init__()\n self.loss_fn = torch.nn.TripletMarginLoss(margin=margin)\n\n def forward(self, anchor, positive, negative):\n return self.loss_fn(anchor, positive, negative)\n\nbatch_size = 32768\ninput_shape = (8192,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape), torch.rand(batch_size, *input_shape)]\n \ndef get_init_inputs():\n return [1.0] # Default margin\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused row-wise Triton TripletMarginLoss matching Model.__init__(margin=1.0).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef triplet_margin_kernel(a_ptr, p_ptr, n_ptr, out_ptr, stride_row, n_cols, margin, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n sum_ap = 0.0\n sum_an = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n a = tl.load(a_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n p = tl.load(p_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n n = tl.load(n_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n dap = a - p + 1e-6\n dan = a - n + 1e-6\n sum_ap += tl.sum(tl.where(mask, dap * dap, 0.0), axis=0)\n sum_an += tl.sum(tl.where(mask, dan * dan, 0.0), axis=0)\n tl.store(out_ptr + row, tl.maximum(tl.sqrt(sum_ap) - tl.sqrt(sum_an) + margin, 0.0))\n\nclass ModelNew(nn.Module):\n def __init__(self, margin=1.0):\n super().__init__()\n self.margin = float(margin)\n\n def forward(self, anchor: torch.Tensor, positive: torch.Tensor, negative: torch.Tensor) -> torch.Tensor:\n a = anchor.contiguous()\n p = positive.contiguous()\n n = negative.contiguous()\n n_rows, n_cols = a.shape\n per_row = torch.empty((n_rows,), device=a.device, dtype=torch.float32)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 2048)\n triplet_margin_kernel[(n_rows,)](a, p, n, per_row, a.stride(0), n_cols, self.margin, BLOCK_SIZE=BLOCK_SIZE)\n return per_row.mean().to(a.dtype)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 3.27, "raw_speedup": 3.27, "ref_ms": 1.382912, "cand_ms": 0.422912, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.382912, "mean_ms": 1.411236, "min_ms": 1.242112, "max_ms": 1.719296, "std_ms": 0.108016}, "cand_stats": {"median_ms": 0.422912, "mean_ms": 0.458424, "min_ms": 0.380928, "max_ms": 1.158144, "std_ms": 0.118342}}, "audited_timestamp": "2026-12-01T23:32:01.858677+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 3.965, "raw_speedup": 3.965, "ref_ms": 1.161216, "cand_ms": 0.292864, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.161216, "mean_ms": 1.181819, "min_ms": 1.156096, "max_ms": 1.368064, "std_ms": 0.048095}, "cand_stats": {"median_ms": 0.292864, "mean_ms": 0.317932, "min_ms": 0.285696, "max_ms": 0.407552, "std_ms": 0.036473}}} +{"timestamp": "2026-12-01T19:38:24.661044+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_100_hingeloss", "source_kb_id": 100, "category": "loss_attention", "dtype": "fp32", "variant": "base", "ref_path": "tasks/train/kb1_100_hingeloss.py", "reference_code": "\"\"\"Task kb1_100_hingeloss (KernelBench Level 1 #100, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_100_hingeloss\"\nSOURCE_KB_ID = 100\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Hinge Loss for binary classification tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.mean(torch.clamp(1 - predictions * targets, min=0))\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_100_hingeloss (KernelBench Level 1 #100, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_100_hingeloss\"\nSOURCE_KB_ID = 100\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Hinge Loss for binary classification tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.mean(torch.clamp(1 - predictions * targets, min=0))\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton HingeLoss: mean(clamp(1 - predictions * targets, min=0)).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef hinge_partial_kernel(pred_ptr, tgt_ptr, partial_ptr, n_elements, n_cols, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n col = offsets % n_cols\n p = tl.load(pred_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n t = tl.load(tgt_ptr + col, mask=mask, other=0.0).to(tl.float32)\n loss = tl.where(mask, tl.maximum(1.0 - p * t, 0.0), 0.0)\n tl.store(partial_ptr + pid, tl.sum(loss, axis=0))\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, predictions: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:\n p = predictions.contiguous()\n t = targets.contiguous()\n n_elements = p.numel()\n BLOCK_SIZE = 1024\n n_blocks = triton.cdiv(n_elements, BLOCK_SIZE)\n partial = torch.empty((n_blocks,), device=p.device, dtype=torch.float32)\n hinge_partial_kernel[(n_blocks,)](p, t, partial, n_elements, p.shape[-1], BLOCK_SIZE=BLOCK_SIZE)\n return (partial.sum() / n_elements).to(p.dtype)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 3.737, "raw_speedup": 3.737, "ref_ms": 0.771072, "cand_ms": 0.206336, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.771072, "mean_ms": 0.787046, "min_ms": 0.7168, "max_ms": 1.08544, "std_ms": 0.080828}, "cand_stats": {"median_ms": 0.206336, "mean_ms": 0.213729, "min_ms": 0.147456, "max_ms": 0.310272, "std_ms": 0.030907}}, "audited_timestamp": "2026-12-01T23:32:06.780161+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 6.0182, "raw_speedup": 6.0182, "ref_ms": 0.677888, "cand_ms": 0.11264, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.677888, "mean_ms": 0.698081, "min_ms": 0.673792, "max_ms": 0.791552, "std_ms": 0.033483}, "cand_stats": {"median_ms": 0.11264, "mean_ms": 0.116224, "min_ms": 0.111616, "max_ms": 0.159744, "std_ms": 0.011482}}} +{"timestamp": "2026-12-01T19:38:31.433411+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_002_standard_matrix_multiplication__bf16", "source_kb_id": 2, "category": "matmul", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_002_standard_matrix_multiplication__bf16.py", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication__bf16 (KernelBench Level 1 #2, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__bf16\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_002_standard_matrix_multiplication__bf16 (KernelBench Level 1 #2, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__bf16\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled 2D Triton matmul using tl.dot with IEEE fp32 precision and fp16/bf16 tensor-core accumulation.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.954, "raw_speedup": 0.954, "ref_ms": 0.456704, "cand_ms": 0.47872, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.456704, "mean_ms": 0.473702, "min_ms": 0.417792, "max_ms": 0.652288, "std_ms": 0.051853}, "cand_stats": {"median_ms": 0.47872, "mean_ms": 0.506307, "min_ms": 0.431104, "max_ms": 0.751616, "std_ms": 0.068958}}, "audited_timestamp": "2026-12-01T23:32:13.184364+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.7987, "raw_speedup": 0.7987, "ref_ms": 0.369664, "cand_ms": 0.462848, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.369664, "mean_ms": 0.396739, "min_ms": 0.367616, "max_ms": 0.550912, "std_ms": 0.04634}, "cand_stats": {"median_ms": 0.462848, "mean_ms": 0.473068, "min_ms": 0.342016, "max_ms": 0.608256, "std_ms": 0.044119}}} +{"timestamp": "2026-12-01T19:38:37.523392+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_006_matmul_with_large_k_dimension__bf16", "source_kb_id": 6, "category": "matmul", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_006_matmul_with_large_k_dimension__bf16.py", "reference_code": "\"\"\"Task kb1_006_matmul_with_large_k_dimension__bf16 (KernelBench Level 1 #6, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension__bf16\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_006_matmul_with_large_k_dimension__bf16 (KernelBench Level 1 #6, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension__bf16\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul for large K with fp32 accumulator and IEEE dot precision.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.7585, "raw_speedup": 0.7585, "ref_ms": 0.525824, "cand_ms": 0.693248, "max_abs_diff": 64.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.525824, "mean_ms": 0.546796, "min_ms": 0.4352, "max_ms": 0.800768, "std_ms": 0.081133}, "cand_stats": {"median_ms": 0.693248, "mean_ms": 0.742871, "min_ms": 0.636928, "max_ms": 1.247232, "std_ms": 0.129518}}, "audited_timestamp": "2026-12-01T23:32:20.438845+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.6589, "raw_speedup": 0.6589, "ref_ms": 0.375808, "cand_ms": 0.570368, "max_abs_diff": 64.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.375808, "mean_ms": 0.39252, "min_ms": 0.372736, "max_ms": 0.458752, "std_ms": 0.024823}, "cand_stats": {"median_ms": 0.570368, "mean_ms": 0.572375, "min_ms": 0.507904, "max_ms": 0.651264, "std_ms": 0.016876}}} +{"timestamp": "2026-12-01T19:38:42.971754+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_016_matmul_with_transposed_a__bf16", "source_kb_id": 16, "category": "matmul", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_016_matmul_with_transposed_a__bf16.py", "reference_code": "\"\"\"Task kb1_016_matmul_with_transposed_a__bf16 (KernelBench Level 1 #16, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a__bf16\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_016_matmul_with_transposed_a__bf16 (KernelBench Level 1 #16, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a__bf16\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul with transposed A (A.T @ B) via strided pointers.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A.T, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9119, "raw_speedup": 0.9119, "ref_ms": 0.461312, "cand_ms": 0.505856, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.461312, "mean_ms": 0.481894, "min_ms": 0.415744, "max_ms": 0.667648, "std_ms": 0.055062}, "cand_stats": {"median_ms": 0.505856, "mean_ms": 0.527278, "min_ms": 0.43008, "max_ms": 0.894976, "std_ms": 0.087245}}, "audited_timestamp": "2026-12-01T23:32:28.362210+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.1149, "raw_speedup": 1.1149, "ref_ms": 0.367616, "cand_ms": 0.329728, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.367616, "mean_ms": 0.372613, "min_ms": 0.365568, "max_ms": 0.47104, "std_ms": 0.017727}, "cand_stats": {"median_ms": 0.329728, "mean_ms": 0.332554, "min_ms": 0.326656, "max_ms": 0.37888, "std_ms": 0.011111}}} +{"timestamp": "2026-12-01T19:38:48.306379+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_018_matmul_with_transposed_both__bf16", "source_kb_id": 18, "category": "matmul", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_018_matmul_with_transposed_both__bf16.py", "reference_code": "\"\"\"Task kb1_018_matmul_with_transposed_both__bf16 (KernelBench Level 1 #18, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_018_matmul_with_transposed_both__bf16\"\nSOURCE_KB_ID = 18\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B.T)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(N, K)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_018_matmul_with_transposed_both__bf16 (KernelBench Level 1 #18, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_018_matmul_with_transposed_both__bf16\"\nSOURCE_KB_ID = 18\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B.T)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(N, K)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul with both A and B transposed (A.T @ B.T) via strided pointers.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A.T, B.T)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.0885, "raw_speedup": 1.0885, "ref_ms": 0.503808, "cand_ms": 0.462848, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.503808, "mean_ms": 0.512225, "min_ms": 0.427008, "max_ms": 0.739328, "std_ms": 0.071982}, "cand_stats": {"median_ms": 0.462848, "mean_ms": 0.498442, "min_ms": 0.411648, "max_ms": 0.802816, "std_ms": 0.081564}}, "audited_timestamp": "2026-12-01T23:32:35.482967+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.1051, "raw_speedup": 1.1051, "ref_ms": 0.398336, "cand_ms": 0.360448, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.398336, "mean_ms": 0.417116, "min_ms": 0.374784, "max_ms": 0.585728, "std_ms": 0.045787}, "cand_stats": {"median_ms": 0.360448, "mean_ms": 0.378675, "min_ms": 0.328704, "max_ms": 0.553984, "std_ms": 0.058276}}} +{"timestamp": "2026-12-01T19:38:52.774753+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_020_leakyrelu__bf16", "source_kb_id": 20, "category": "activation", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_020_leakyrelu__bf16.py", "reference_code": "\"\"\"Task kb1_020_leakyrelu__bf16 (KernelBench Level 1 #20, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu__bf16\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_020_leakyrelu__bf16 (KernelBench Level 1 #20, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu__bf16\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fuse LeakyReLU elementwise in Triton using tl.where(x >= 0, x, x * negative_slope), matching Model.__init__(negative_slope).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef leaky_relu_kernel(x_ptr, out_ptr, n_elements, negative_slope, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n out = tl.where(x >= 0, x, x * negative_slope)\n tl.store(out_ptr + offsets, out, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, negative_slope: float = 0.01):\n super().__init__()\n self.negative_slope = negative_slope\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n leaky_relu_kernel[grid](x, out, n_elements, self.negative_slope, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.1272, "raw_speedup": 1.1272, "ref_ms": 0.353792, "cand_ms": 0.313856, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.353792, "mean_ms": 0.358769, "min_ms": 0.268288, "max_ms": 0.492544, "std_ms": 0.050426}, "cand_stats": {"median_ms": 0.313856, "mean_ms": 0.337613, "min_ms": 0.24576, "max_ms": 0.626688, "std_ms": 0.07887}}, "audited_timestamp": "2026-12-01T23:32:40.827728+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0053, "raw_speedup": 1.0053, "ref_ms": 0.193536, "cand_ms": 0.192512, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.193536, "mean_ms": 0.194437, "min_ms": 0.191488, "max_ms": 0.21504, "std_ms": 0.003203}, "cand_stats": {"median_ms": 0.192512, "mean_ms": 0.205681, "min_ms": 0.190464, "max_ms": 0.36352, "std_ms": 0.033076}}} +{"timestamp": "2026-12-01T19:38:57.132381+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_021_sigmoid__bf16", "source_kb_id": 21, "category": "activation", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_021_sigmoid__bf16.py", "reference_code": "\"\"\"Task kb1_021_sigmoid__bf16 (KernelBench Level 1 #21, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid__bf16\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_021_sigmoid__bf16 (KernelBench Level 1 #21, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid__bf16\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise Sigmoid in Triton using tl.sigmoid in fp32.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef sigmoid_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n out = tl.sigmoid(x.to(tl.float32)).to(x.dtype)\n tl.store(out_ptr + offsets, out, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n sigmoid_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8342, "raw_speedup": 0.8342, "ref_ms": 0.244736, "cand_ms": 0.293376, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.244736, "mean_ms": 0.270602, "min_ms": 0.238592, "max_ms": 0.393216, "std_ms": 0.045035}, "cand_stats": {"median_ms": 0.293376, "mean_ms": 0.298086, "min_ms": 0.238592, "max_ms": 0.475136, "std_ms": 0.044655}}, "audited_timestamp": "2026-12-01T23:32:46.057512+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0106, "raw_speedup": 1.0106, "ref_ms": 0.19456, "cand_ms": 0.192512, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.19456, "mean_ms": 0.194109, "min_ms": 0.191488, "max_ms": 0.196608, "std_ms": 0.001117}, "cand_stats": {"median_ms": 0.192512, "mean_ms": 0.197878, "min_ms": 0.18944, "max_ms": 0.360448, "std_ms": 0.025458}}} +{"timestamp": "2026-12-01T19:39:02.540942+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_024_logsoftmax__bf16", "source_kb_id": 24, "category": "activation", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_024_logsoftmax__bf16.py", "reference_code": "\"\"\"Task kb1_024_logsoftmax__bf16 (KernelBench Level 1 #24, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax__bf16\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_024_logsoftmax__bf16 (KernelBench Level 1 #24, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax__bf16\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fuse numerically stable row-wise LogSoftmax in Triton supporting arbitrary dim via transpose.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef log_softmax_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n row_max = -float(\"inf\")\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=-float(\"inf\")).to(tl.float32)\n row_max = tl.maximum(row_max, tl.max(x, axis=0))\n sum_exp = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=-float(\"inf\")).to(tl.float32)\n sum_exp += tl.sum(tl.where(mask, tl.exp(x - row_max), 0.0), axis=0)\n lse = row_max + tl.log(sum_exp)\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0)\n tl.store(out_ptr + row * stride_row + cols, (x.to(tl.float32) - lse).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int = 1):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n dim = self.dim % x.ndim\n x_t = x.transpose(dim, -1).contiguous()\n orig_shape = x_t.shape\n x_2d = x_t.view(-1, orig_shape[-1])\n n_rows, n_cols = x_2d.shape\n out = torch.empty_like(x_2d)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 4096)\n log_softmax_kernel[(n_rows,)](x_2d, out, x_2d.stride(0), n_cols, BLOCK_SIZE=BLOCK_SIZE)\n return out.view(orig_shape).transpose(dim, -1).contiguous()\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9794, "raw_speedup": 0.9794, "ref_ms": 0.438272, "cand_ms": 0.447488, "max_abs_diff": 0.0625, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.438272, "mean_ms": 0.452895, "min_ms": 0.362496, "max_ms": 0.78848, "std_ms": 0.084504}, "cand_stats": {"median_ms": 0.447488, "mean_ms": 0.479764, "min_ms": 0.395264, "max_ms": 1.11616, "std_ms": 0.112759}}, "audited_timestamp": "2026-12-01T23:32:51.492794+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0403, "raw_speedup": 1.0403, "ref_ms": 0.31744, "cand_ms": 0.305152, "max_abs_diff": 0.0625, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.31744, "mean_ms": 0.319119, "min_ms": 0.313344, "max_ms": 0.416768, "std_ms": 0.014444}, "cand_stats": {"median_ms": 0.305152, "mean_ms": 0.305459, "min_ms": 0.300032, "max_ms": 0.346112, "std_ms": 0.006323}}} +{"timestamp": "2026-12-01T19:39:07.021117+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_027_selu__bf16", "source_kb_id": 27, "category": "activation", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_027_selu__bf16.py", "reference_code": "\"\"\"Task kb1_027_selu__bf16 (KernelBench Level 1 #27, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_027_selu__bf16\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_027_selu__bf16 (KernelBench Level 1 #27, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_027_selu__bf16\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise SELU in Triton with standard alpha and scale constants.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef selu_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = 1.0507009873554805 * tl.where(xf > 0.0, xf, 1.6732632423543772 * (tl.exp(xf) - 1.0))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n selu_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8235, "raw_speedup": 0.8235, "ref_ms": 0.243712, "cand_ms": 0.295936, "max_abs_diff": 1.52587890625e-05, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.243712, "mean_ms": 0.261939, "min_ms": 0.23552, "max_ms": 0.397312, "std_ms": 0.033679}, "cand_stats": {"median_ms": 0.295936, "mean_ms": 0.315474, "min_ms": 0.236544, "max_ms": 0.59392, "std_ms": 0.073801}}, "audited_timestamp": "2026-12-01T23:32:56.676653+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.008, "raw_speedup": 1.008, "ref_ms": 0.194048, "cand_ms": 0.192512, "max_abs_diff": 1.52587890625e-05, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.194048, "mean_ms": 0.19671, "min_ms": 0.192512, "max_ms": 0.262144, "std_ms": 0.011709}, "cand_stats": {"median_ms": 0.192512, "mean_ms": 0.216801, "min_ms": 0.191488, "max_ms": 0.32256, "std_ms": 0.036568}}} +{"timestamp": "2026-12-01T19:39:11.437996+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_033_batchnorm__bf16", "source_kb_id": 33, "category": "normalization", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_033_batchnorm__bf16.py", "reference_code": "\"\"\"Task kb1_033_batchnorm__bf16 (KernelBench Level 1 #33, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm__bf16\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_033_batchnorm__bf16 (KernelBench Level 1 #33, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm__bf16\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton BatchNorm2d inference kernel preserving self.bn = nn.BatchNorm2d(num_features).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef batchnorm2d_eval_kernel(\n x_ptr, out_ptr, w_ptr, b_ptr, mean_ptr, var_ptr,\n n_elements, C, HW, eps, BLOCK_SIZE: tl.constexpr,\n):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n c = (offsets // HW) % C\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n mean = tl.load(mean_ptr + c, mask=mask, other=0.0).to(tl.float32)\n var = tl.load(var_ptr + c, mask=mask, other=1.0).to(tl.float32)\n w = tl.load(w_ptr + c, mask=mask, other=1.0).to(tl.float32)\n b = tl.load(b_ptr + c, mask=mask, other=0.0).to(tl.float32)\n y = (x.to(tl.float32) - mean) * tl.rsqrt(var + eps) * w + b\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, num_features: int):\n super().__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, H, W = x.shape\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n batchnorm2d_eval_kernel[grid](\n x, out, self.bn.weight, self.bn.bias,\n self.bn.running_mean, self.bn.running_var,\n n_elements, C, H * W, self.bn.eps, BLOCK_SIZE=1024,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.0661, "raw_speedup": 1.0661, "ref_ms": 0.55296, "cand_ms": 0.518656, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.55296, "mean_ms": 0.594309, "min_ms": 0.467968, "max_ms": 1.106944, "std_ms": 0.132735}, "cand_stats": {"median_ms": 0.518656, "mean_ms": 0.557036, "min_ms": 0.433152, "max_ms": 0.83968, "std_ms": 0.10297}}, "audited_timestamp": "2026-12-01T23:33:02.210341+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0895, "raw_speedup": 1.0895, "ref_ms": 0.417792, "cand_ms": 0.383488, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.417792, "mean_ms": 0.433295, "min_ms": 0.415744, "max_ms": 0.54784, "std_ms": 0.035893}, "cand_stats": {"median_ms": 0.383488, "mean_ms": 0.405053, "min_ms": 0.376832, "max_ms": 0.494592, "std_ms": 0.031165}}} +{"timestamp": "2026-12-01T19:39:16.070283+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_035_groupnorm__bf16", "source_kb_id": 35, "category": "normalization", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_035_groupnorm__bf16.py", "reference_code": "\"\"\"Task kb1_035_groupnorm__bf16 (KernelBench Level 1 #35, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm__bf16\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_035_groupnorm__bf16 (KernelBench Level 1 #35, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm__bf16\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton GroupNorm kernel normalizing each (n, g) group with affine weight/bias from self.gn.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef groupnorm_kernel(x_ptr, out_ptr, w_ptr, b_ptr, C, G, HW, eps, BLOCK_SIZE: tl.constexpr):\n ng = tl.program_id(0)\n n = ng // G\n g = ng % G\n c_per_g = C // G\n group_size = c_per_g * HW\n base = (n * C + g * c_per_g) * HW\n sum_x = 0.0\n sum_x2 = 0.0\n for off in range(0, group_size, BLOCK_SIZE):\n idx = off + tl.arange(0, BLOCK_SIZE)\n mask = idx < group_size\n x = tl.load(x_ptr + base + idx, mask=mask, other=0.0).to(tl.float32)\n sum_x += tl.sum(x, axis=0)\n sum_x2 += tl.sum(x * x, axis=0)\n mean = sum_x / group_size\n var = tl.maximum(sum_x2 / group_size - mean * mean, 0.0)\n rstd = tl.rsqrt(var + eps)\n for off in range(0, group_size, BLOCK_SIZE):\n idx = off + tl.arange(0, BLOCK_SIZE)\n mask = idx < group_size\n c = g * c_per_g + (idx // HW)\n x = tl.load(x_ptr + base + idx, mask=mask, other=0.0)\n w = tl.load(w_ptr + c, mask=mask, other=1.0).to(tl.float32)\n b = tl.load(b_ptr + c, mask=mask, other=0.0).to(tl.float32)\n tl.store(out_ptr + base + idx, ((x.to(tl.float32) - mean) * rstd * w + b).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, num_features: int, num_groups: int):\n super().__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, H, W = x.shape\n G = self.gn.num_groups\n out = torch.empty_like(x)\n groupnorm_kernel[(N * G,)](x, out, self.gn.weight, self.gn.bias, C, G, H * W, self.gn.eps, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.1952, "raw_speedup": 1.1952, "ref_ms": 0.943616, "cand_ms": 0.789504, "max_abs_diff": 0.03125, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.943616, "mean_ms": 0.982774, "min_ms": 0.825344, "max_ms": 1.75104, "std_ms": 0.140145}, "cand_stats": {"median_ms": 0.789504, "mean_ms": 0.803901, "min_ms": 0.63488, "max_ms": 1.09056, "std_ms": 0.101359}}, "audited_timestamp": "2026-12-01T23:33:08.280430+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.3424, "raw_speedup": 1.3424, "ref_ms": 0.758784, "cand_ms": 0.565248, "max_abs_diff": 0.03125, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.758784, "mean_ms": 0.762409, "min_ms": 0.756736, "max_ms": 0.830464, "std_ms": 0.015337}, "cand_stats": {"median_ms": 0.565248, "mean_ms": 0.576143, "min_ms": 0.562176, "max_ms": 0.67584, "std_ms": 0.026403}}} +{"timestamp": "2026-12-01T19:39:20.244698+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_039_l2norm__bf16", "source_kb_id": 39, "category": "normalization", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_039_l2norm__bf16.py", "reference_code": "\"\"\"Task kb1_039_l2norm__bf16 (KernelBench Level 1 #39, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm__bf16\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_039_l2norm__bf16 (KernelBench Level 1 #39, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm__bf16\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused row-wise Triton L2 normalization: x / sqrt(sum(x^2, dim=1, keepdim=True)).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef l2_norm_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n sum_sq = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n sum_sq += tl.sum(x * x, axis=0)\n inv_norm = tl.rsqrt(sum_sq)\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0)\n tl.store(out_ptr + row * stride_row + cols, (x.to(tl.float32) * inv_norm).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n n_rows, n_cols = x.shape\n out = torch.empty_like(x)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 4096)\n l2_norm_kernel[(n_rows,)](x, out, x.stride(0), n_cols, BLOCK_SIZE=BLOCK_SIZE)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.0323, "raw_speedup": 1.0323, "ref_ms": 0.359936, "cand_ms": 0.348672, "max_abs_diff": 0.00048828125, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.359936, "mean_ms": 0.362148, "min_ms": 0.356352, "max_ms": 0.392192, "std_ms": 0.007204}, "cand_stats": {"median_ms": 0.348672, "mean_ms": 0.358175, "min_ms": 0.314368, "max_ms": 0.468992, "std_ms": 0.036102}}, "audited_timestamp": "2026-12-01T23:33:15.410887+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.1711, "raw_speedup": 1.1711, "ref_ms": 0.315392, "cand_ms": 0.269312, "max_abs_diff": 0.00048828125, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.315392, "mean_ms": 0.315515, "min_ms": 0.313344, "max_ms": 0.32256, "std_ms": 0.001286}, "cand_stats": {"median_ms": 0.269312, "mean_ms": 0.277258, "min_ms": 0.264192, "max_ms": 0.33792, "std_ms": 0.018799}}} +{"timestamp": "2026-12-01T19:39:24.322151+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_048_mean_reduction_over_a_dimension__bf16", "source_kb_id": 48, "category": "reduction_scan", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_048_mean_reduction_over_a_dimension__bf16.py", "reference_code": "\"\"\"Task kb1_048_mean_reduction_over_a_dimension__bf16 (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension__bf16\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_048_mean_reduction_over_a_dimension__bf16 (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension__bf16\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton mean reduction over arbitrary dim using strided outer/inner indexing.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef mean_reduce_kernel(x_ptr, out_ptr, reduce_size, inner_size, BLOCK_R: tl.constexpr):\n pid = tl.program_id(0)\n outer = pid // inner_size\n inner = pid % inner_size\n base = outer * reduce_size * inner_size + inner\n acc = 0.0\n for r_start in range(0, reduce_size, BLOCK_R):\n r = r_start + tl.arange(0, BLOCK_R)\n mask = r < reduce_size\n vals = tl.load(x_ptr + base + r * inner_size, mask=mask, other=0.0).to(tl.float32)\n acc += tl.sum(vals, axis=0)\n tl.store(out_ptr + pid, acc / reduce_size)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n dim = self.dim % x.ndim\n outer_size = 1\n for s in x.shape[:dim]:\n outer_size *= s\n reduce_size = x.shape[dim]\n inner_size = 1\n for s in x.shape[dim + 1:]:\n inner_size *= s\n out = torch.empty(x.shape[:dim] + x.shape[dim + 1:], device=x.device, dtype=x.dtype)\n BLOCK_R = min(triton.next_power_of_2(reduce_size), 1024)\n mean_reduce_kernel[(outer_size * inner_size,)](x, out, reduce_size, inner_size, BLOCK_R=BLOCK_R)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.2478, "raw_speedup": 0.2478, "ref_ms": 0.159744, "cand_ms": 0.644608, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.159744, "mean_ms": 0.181248, "min_ms": 0.150528, "max_ms": 0.272384, "std_ms": 0.033804}, "cand_stats": {"median_ms": 0.644608, "mean_ms": 0.657265, "min_ms": 0.500736, "max_ms": 0.970752, "std_ms": 0.089115}}, "audited_timestamp": "2026-12-01T23:33:20.428093+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.3134, "raw_speedup": 0.3134, "ref_ms": 0.153088, "cand_ms": 0.488448, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.153088, "mean_ms": 0.157921, "min_ms": 0.10752, "max_ms": 0.221184, "std_ms": 0.017475}, "cand_stats": {"median_ms": 0.488448, "mean_ms": 0.493609, "min_ms": 0.413696, "max_ms": 0.572416, "std_ms": 0.024092}}} +{"timestamp": "2026-12-01T19:39:30.158391+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16", "source_kb_id": 55, "category": "convolution", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16.py", "reference_code": "\"\"\"Task kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16 (KernelBench Level 1 #55, split=train, category=convolution, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16\"\nSOURCE_KB_ID = 55\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\n# smaller spatial dims\nheight = 512\nwidth = 1024\nin_channels = 64 # increased channels\nout_channels = 128\nkernel_size = 3\n# asymmetric input: make width considerably larger than height\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nheight = 128\nwidth = 256\nin_channels = 32\nout_channels = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16 (KernelBench Level 1 #55, split=train, category=convolution, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16\"\nSOURCE_KB_ID = 55\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\n# smaller spatial dims\nheight = 512\nwidth = 1024\nin_channels = 64 # increased channels\nout_channels = 128\nkernel_size = 3\n# asymmetric input: make width considerably larger than height\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nheight = 128\nwidth = 256\nin_channels = 32\nout_channels = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton direct Conv2D kernel preserving self.conv2d = nn.Conv2d(...) signature and weights.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef conv2d_kernel(x_ptr, w_ptr, out_ptr, C_in, H_in, W_in, C_out, H_out, W_out, K: tl.constexpr, stride, padding, dilation, BLOCK_HW: tl.constexpr):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n for ci in range(C_in):\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (co * C_in + ci) * K * K\n for kh in range(K):\n hi = ho * stride - padding + kh * dilation\n for kw in range(K):\n wi = wo * stride - padding + kw * dilation\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n acc += tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32) * tl.load(w_ptr + w_base + kh * K + kw).to(tl.float32)\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super().__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n self.kernel_size = kernel_size\n self.stride = stride\n self.padding = padding\n self.dilation = dilation\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n w = self.conv2d.weight.contiguous()\n N, C_in, H_in, W_in = x.shape\n C_out = w.shape[0]\n H_out = (H_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n W_out = (W_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x.device, dtype=x.dtype)\n BLOCK_HW = 256\n conv2d_kernel[(N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))](\n x, w, out, C_in, H_in, W_in, C_out, H_out, W_out,\n K=self.kernel_size, stride=self.stride, padding=self.padding, dilation=self.dilation, BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.0935, "raw_speedup": 0.0935, "ref_ms": 0.861184, "cand_ms": 9.211904, "max_abs_diff": 0.0078125, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.861184, "mean_ms": 0.901222, "min_ms": 0.687104, "max_ms": 1.288192, "std_ms": 0.132559}, "cand_stats": {"median_ms": 9.211904, "mean_ms": 9.619599, "min_ms": 8.726528, "max_ms": 11.826176, "std_ms": 0.780167}}, "audited_timestamp": "2026-12-01T23:33:27.567470+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.0919, "raw_speedup": 0.0919, "ref_ms": 0.816128, "cand_ms": 8.879616, "max_abs_diff": 0.0078125, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.816128, "mean_ms": 0.830075, "min_ms": 0.73728, "max_ms": 1.197056, "std_ms": 0.066103}, "cand_stats": {"median_ms": 8.879616, "mean_ms": 8.946074, "min_ms": 8.715264, "max_ms": 9.98912, "std_ms": 0.23057}}} +{"timestamp": "2026-12-01T19:39:35.782568+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_088_mingptnewgelu__bf16", "source_kb_id": 88, "category": "activation", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_088_mingptnewgelu__bf16.py", "reference_code": "\"\"\"Task kb1_088_mingptnewgelu__bf16 (KernelBench Level 1 #88, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu__bf16\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_088_mingptnewgelu__bf16 (KernelBench Level 1 #88, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu__bf16\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fuse MinGPT NewGELU (0.5*x*(1 + tanh(sqrt(2/pi)*(x + 0.044715*x^3)))) into a single Triton pass.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef new_gelu_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n inner = 0.7978845608028654 * (xf + 0.044715 * xf * xf * xf)\n tanh_val = 2.0 * tl.sigmoid(2.0 * inner) - 1.0\n y = 0.5 * xf * (1.0 + tanh_val)\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n new_gelu_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 5.0549, "raw_speedup": 5.0549, "ref_ms": 1.88416, "cand_ms": 0.372736, "max_abs_diff": 0.015625, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 1.88416, "mean_ms": 1.967247, "min_ms": 1.760256, "max_ms": 2.624512, "std_ms": 0.211634}, "cand_stats": {"median_ms": 0.372736, "mean_ms": 0.408248, "min_ms": 0.249856, "max_ms": 0.714752, "std_ms": 0.108953}}, "audited_timestamp": "2026-12-01T23:33:32.747659+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 8.8963, "raw_speedup": 8.8963, "ref_ms": 1.71264, "cand_ms": 0.192512, "max_abs_diff": 0.015625, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 1.71264, "mean_ms": 1.725563, "min_ms": 1.70496, "max_ms": 2.019328, "std_ms": 0.045672}, "cand_stats": {"median_ms": 0.192512, "mean_ms": 0.201708, "min_ms": 0.190464, "max_ms": 0.34816, "std_ms": 0.026269}}} +{"timestamp": "2026-12-01T19:39:40.418466+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_096_huberloss__bf16", "source_kb_id": 96, "category": "loss_attention", "dtype": "bf16", "variant": "bf16", "ref_path": "tasks/train/kb1_096_huberloss__bf16.py", "reference_code": "\"\"\"Task kb1_096_huberloss__bf16 (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss__bf16\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_096_huberloss__bf16 (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss__bf16\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton Smooth L1 (Huber, beta=1.0) loss with block reduction.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef huber_partial_kernel(pred_ptr, tgt_ptr, partial_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n p = tl.load(pred_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n t = tl.load(tgt_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n diff = tl.abs(p - t)\n loss = tl.where(mask, tl.where(diff < 1.0, 0.5 * diff * diff, diff - 0.5), 0.0)\n tl.store(partial_ptr + pid, tl.sum(loss, axis=0))\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, predictions: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:\n p = predictions.contiguous()\n t = targets.contiguous()\n n_elements = p.numel()\n BLOCK_SIZE = 1024\n n_blocks = triton.cdiv(n_elements, BLOCK_SIZE)\n partial = torch.empty((n_blocks,), device=p.device, dtype=torch.float32)\n huber_partial_kernel[(n_blocks,)](p, t, partial, n_elements, BLOCK_SIZE=BLOCK_SIZE)\n return (partial.sum() / n_elements).to(p.dtype)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.4041, "raw_speedup": 1.4041, "ref_ms": 0.494592, "cand_ms": 0.352256, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.494592, "mean_ms": 0.508989, "min_ms": 0.45056, "max_ms": 0.943104, "std_ms": 0.082342}, "cand_stats": {"median_ms": 0.352256, "mean_ms": 0.354324, "min_ms": 0.242688, "max_ms": 0.688128, "std_ms": 0.086881}}, "audited_timestamp": "2026-12-01T23:33:38.512137+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.4321, "raw_speedup": 1.4321, "ref_ms": 0.410624, "cand_ms": 0.28672, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "bfloat16", "error": null, "ref_stats": {"median_ms": 0.410624, "mean_ms": 0.446239, "min_ms": 0.406528, "max_ms": 1.007616, "std_ms": 0.089627}, "cand_stats": {"median_ms": 0.28672, "mean_ms": 0.306749, "min_ms": 0.264192, "max_ms": 0.523264, "std_ms": 0.053493}}} +{"timestamp": "2026-12-01T19:39:45.691585+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_002_standard_matrix_multiplication__fp16", "source_kb_id": 2, "category": "matmul", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_002_standard_matrix_multiplication__fp16.py", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication__fp16 (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__fp16\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_002_standard_matrix_multiplication__fp16 (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__fp16\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled 2D Triton matmul using tl.dot with IEEE fp32 precision and fp16/bf16 tensor-core accumulation.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9594, "raw_speedup": 0.9594, "ref_ms": 0.459264, "cand_ms": 0.47872, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.459264, "mean_ms": 0.471429, "min_ms": 0.41472, "max_ms": 0.56832, "std_ms": 0.034341}, "cand_stats": {"median_ms": 0.47872, "mean_ms": 0.505057, "min_ms": 0.416768, "max_ms": 0.9216, "std_ms": 0.090586}}, "audited_timestamp": "2026-12-01T23:33:45.187261+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0746, "raw_speedup": 1.0746, "ref_ms": 0.36864, "cand_ms": 0.34304, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.36864, "mean_ms": 0.37505, "min_ms": 0.366592, "max_ms": 0.514048, "std_ms": 0.024213}, "cand_stats": {"median_ms": 0.34304, "mean_ms": 0.345764, "min_ms": 0.321536, "max_ms": 0.431104, "std_ms": 0.021162}}} +{"timestamp": "2026-12-01T19:39:50.442231+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_005_matrix_scalar_multiplication__fp16", "source_kb_id": 5, "category": "matmul", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_005_matrix_scalar_multiplication__fp16.py", "reference_code": "\"\"\"Task kb1_005_matrix_scalar_multiplication__fp16 (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication__fp16\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_005_matrix_scalar_multiplication__fp16 (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication__fp16\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Elementwise Triton matrix-scalar multiplication C = A * s.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef mat_scalar_mul_kernel(a_ptr, out_ptr, s, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n a = tl.load(a_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, (a.to(tl.float32) * s).to(a.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n A = A.contiguous()\n out = torch.empty_like(A)\n n_elements = A.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n mat_scalar_mul_kernel[grid](A, out, float(s), n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9789, "raw_speedup": 0.9789, "ref_ms": 0.4992, "cand_ms": 0.509952, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.4992, "mean_ms": 0.502866, "min_ms": 0.43008, "max_ms": 0.657408, "std_ms": 0.053114}, "cand_stats": {"median_ms": 0.509952, "mean_ms": 0.531415, "min_ms": 0.45056, "max_ms": 0.823296, "std_ms": 0.070344}}, "audited_timestamp": "2026-12-01T23:33:50.855504+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0054, "raw_speedup": 1.0054, "ref_ms": 0.380928, "cand_ms": 0.37888, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.380928, "mean_ms": 0.383488, "min_ms": 0.377856, "max_ms": 0.425984, "std_ms": 0.009283}, "cand_stats": {"median_ms": 0.37888, "mean_ms": 0.382648, "min_ms": 0.375808, "max_ms": 0.434176, "std_ms": 0.013727}}} +{"timestamp": "2026-12-01T19:39:56.343509+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_008_matmul_with_irregular_shapes__fp16", "source_kb_id": 8, "category": "matmul", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_008_matmul_with_irregular_shapes__fp16.py", "reference_code": "\"\"\"Task kb1_008_matmul_with_irregular_shapes__fp16 (KernelBench Level 1 #8, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_008_matmul_with_irregular_shapes__fp16\"\nSOURCE_KB_ID = 8\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with irregular shapes\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor with shape (M, K).\n B: Input tensor with shape (K, N).\n\n Returns:\n C: Output tensor with shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 8205\nK = 2949\nN = 5921\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2051\nK = 1473\nN = 1973\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_008_matmul_with_irregular_shapes__fp16 (KernelBench Level 1 #8, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_008_matmul_with_irregular_shapes__fp16\"\nSOURCE_KB_ID = 8\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with irregular shapes\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor with shape (M, K).\n B: Input tensor with shape (K, N).\n\n Returns:\n C: Output tensor with shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 8205\nK = 2949\nN = 5921\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2051\nK = 1473\nN = 1973\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul with boundary masking for irregular shapes.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.5907, "raw_speedup": 0.5907, "ref_ms": 1.123328, "cand_ms": 1.901568, "max_abs_diff": 0.25, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 1.123328, "mean_ms": 1.151959, "min_ms": 1.005568, "max_ms": 1.686528, "std_ms": 0.130506}, "cand_stats": {"median_ms": 1.901568, "mean_ms": 1.99682, "min_ms": 1.6384, "max_ms": 3.122176, "std_ms": 0.318722}}, "audited_timestamp": "2026-12-01T23:33:57.663934+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.7237, "raw_speedup": 0.7237, "ref_ms": 1.060864, "cand_ms": 1.465856, "max_abs_diff": 0.25, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 1.060864, "mean_ms": 1.077105, "min_ms": 1.058816, "max_ms": 1.262592, "std_ms": 0.042326}, "cand_stats": {"median_ms": 1.465856, "mean_ms": 1.527562, "min_ms": 1.368064, "max_ms": 1.886208, "std_ms": 0.151658}}} +{"timestamp": "2026-12-01T19:40:01.925102+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_010_3d_tensor_matrix_multiplication__fp16", "source_kb_id": 10, "category": "matmul", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_010_3d_tensor_matrix_multiplication__fp16.py", "reference_code": "\"\"\"Task kb1_010_3d_tensor_matrix_multiplication__fp16 (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication__fp16\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_010_3d_tensor_matrix_multiplication__fp16 (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication__fp16\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "3D tensor-matrix multiplication (N, M, K) @ (K, L) flattened to 2D tiled Triton matmul.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n N, M, K = A.shape\n L = B.shape[1]\n return triton_matmul(A.contiguous().view(N * M, K), B.contiguous()).view(N, M, L)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.4372, "raw_speedup": 0.4372, "ref_ms": 0.641024, "cand_ms": 1.466368, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.641024, "mean_ms": 0.665539, "min_ms": 0.6144, "max_ms": 0.999424, "std_ms": 0.067172}, "cand_stats": {"median_ms": 1.466368, "mean_ms": 1.496781, "min_ms": 1.380352, "max_ms": 2.258944, "std_ms": 0.127389}}, "audited_timestamp": "2026-12-01T23:34:06.466373+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.4596, "raw_speedup": 0.4596, "ref_ms": 0.596992, "cand_ms": 1.298944, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.596992, "mean_ms": 0.6067, "min_ms": 0.595968, "max_ms": 0.714752, "std_ms": 0.025737}, "cand_stats": {"median_ms": 1.298944, "mean_ms": 1.336259, "min_ms": 1.25952, "max_ms": 2.049024, "std_ms": 0.120782}}} +{"timestamp": "2026-12-01T19:40:06.390880+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_022_tanh__fp16", "source_kb_id": 22, "category": "activation", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_022_tanh__fp16.py", "reference_code": "\"\"\"Task kb1_022_tanh__fp16 (KernelBench Level 1 #22, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh__fp16\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_022_tanh__fp16 (KernelBench Level 1 #22, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh__fp16\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise Tanh in Triton via 2*tl.sigmoid(2*x)-1 in fp32.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef tanh_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n out = (2.0 * tl.sigmoid(2.0 * xf) - 1.0).to(x.dtype)\n tl.store(out_ptr + offsets, out, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n tanh_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8271, "raw_speedup": 0.8271, "ref_ms": 0.249856, "cand_ms": 0.30208, "max_abs_diff": 0.0001220703125, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.249856, "mean_ms": 0.266547, "min_ms": 0.244736, "max_ms": 0.347136, "std_ms": 0.028756}, "cand_stats": {"median_ms": 0.30208, "mean_ms": 0.304579, "min_ms": 0.243712, "max_ms": 0.347136, "std_ms": 0.01423}}, "audited_timestamp": "2026-12-01T23:34:12.057705+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.7462, "raw_speedup": 0.7462, "ref_ms": 0.198656, "cand_ms": 0.26624, "max_abs_diff": 0.0001220703125, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.198656, "mean_ms": 0.210063, "min_ms": 0.192512, "max_ms": 0.260096, "std_ms": 0.021691}, "cand_stats": {"median_ms": 0.26624, "mean_ms": 0.267489, "min_ms": 0.191488, "max_ms": 0.375808, "std_ms": 0.029834}}} +{"timestamp": "2026-12-01T19:40:12.590515+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_028_hardsigmoid__fp16", "source_kb_id": 28, "category": "activation", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_028_hardsigmoid__fp16.py", "reference_code": "\"\"\"Task kb1_028_hardsigmoid__fp16 (KernelBench Level 1 #28, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_028_hardsigmoid__fp16\"\nSOURCE_KB_ID = 28\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardSigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardSigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardSigmoid applied, same shape as input.\n \"\"\"\n return torch.nn.functional.hardsigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_028_hardsigmoid__fp16 (KernelBench Level 1 #28, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_028_hardsigmoid__fp16\"\nSOURCE_KB_ID = 28\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardSigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardSigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardSigmoid applied, same shape as input.\n \"\"\"\n return torch.nn.functional.hardsigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise HardSigmoid in Triton: clamp((x + 3) / 6, 0, 1).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef hardsigmoid_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = tl.minimum(tl.maximum((xf + 3.0) / 6.0, 0.0), 1.0)\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n hardsigmoid_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9611, "raw_speedup": 0.9611, "ref_ms": 0.240128, "cand_ms": 0.249856, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.240128, "mean_ms": 0.240763, "min_ms": 0.237568, "max_ms": 0.252928, "std_ms": 0.002856}, "cand_stats": {"median_ms": 0.249856, "mean_ms": 0.264909, "min_ms": 0.241664, "max_ms": 0.334848, "std_ms": 0.025529}}, "audited_timestamp": "2026-12-01T23:34:17.083395+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0053, "raw_speedup": 1.0053, "ref_ms": 0.19456, "cand_ms": 0.193536, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.19456, "mean_ms": 0.20052, "min_ms": 0.191488, "max_ms": 0.328704, "std_ms": 0.02362}, "cand_stats": {"median_ms": 0.193536, "mean_ms": 0.211784, "min_ms": 0.190464, "max_ms": 0.346112, "std_ms": 0.037578}}} +{"timestamp": "2026-12-01T19:40:17.461961+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_029_softplus__fp16", "source_kb_id": 29, "category": "activation", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_029_softplus__fp16.py", "reference_code": "\"\"\"Task kb1_029_softplus__fp16 (KernelBench Level 1 #29, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus__fp16\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_029_softplus__fp16 (KernelBench Level 1 #29, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus__fp16\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement numerically stable Softplus in Triton: x when x > 20 else log(1 + exp(x)).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef softplus_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = tl.where(xf > 20.0, xf, tl.log(1.0 + tl.exp(xf)))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n softplus_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8027, "raw_speedup": 0.8027, "ref_ms": 0.247808, "cand_ms": 0.308736, "max_abs_diff": 0.001953125, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.247808, "mean_ms": 0.264458, "min_ms": 0.238592, "max_ms": 0.370688, "std_ms": 0.034042}, "cand_stats": {"median_ms": 0.308736, "mean_ms": 0.330547, "min_ms": 0.236544, "max_ms": 0.888832, "std_ms": 0.09913}}, "audited_timestamp": "2026-12-01T23:34:22.339160+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0053, "raw_speedup": 1.0053, "ref_ms": 0.193536, "cand_ms": 0.192512, "max_abs_diff": 0.001953125, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.193536, "mean_ms": 0.19671, "min_ms": 0.191488, "max_ms": 0.243712, "std_ms": 0.010926}, "cand_stats": {"median_ms": 0.192512, "mean_ms": 0.195666, "min_ms": 0.190464, "max_ms": 0.244736, "std_ms": 0.011566}}} +{"timestamp": "2026-12-01T19:40:22.322670+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_031_elu__fp16", "source_kb_id": 31, "category": "activation", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_031_elu__fp16.py", "reference_code": "\"\"\"Task kb1_031_elu__fp16 (KernelBench Level 1 #31, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_031_elu__fp16\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_031_elu__fp16 (KernelBench Level 1 #31, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_031_elu__fp16\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise ELU in Triton matching Model.__init__(alpha=1.0).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef elu_kernel(x_ptr, out_ptr, n_elements, alpha, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = tl.where(xf > 0.0, xf, alpha * (tl.exp(xf) - 1.0))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, alpha: float = 1.0):\n super().__init__()\n self.alpha = alpha\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n elu_kernel[grid](x, out, n_elements, self.alpha, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8669, "raw_speedup": 0.8669, "ref_ms": 0.246784, "cand_ms": 0.284672, "max_abs_diff": 0.000244140625, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.246784, "mean_ms": 0.261325, "min_ms": 0.237568, "max_ms": 0.516096, "std_ms": 0.042432}, "cand_stats": {"median_ms": 0.284672, "mean_ms": 0.280515, "min_ms": 0.237568, "max_ms": 0.3584, "std_ms": 0.035095}}, "audited_timestamp": "2026-12-01T23:34:27.485202+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0053, "raw_speedup": 1.0053, "ref_ms": 0.19456, "cand_ms": 0.193536, "max_abs_diff": 0.000244140625, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.19456, "mean_ms": 0.198164, "min_ms": 0.191488, "max_ms": 0.304128, "std_ms": 0.016162}, "cand_stats": {"median_ms": 0.193536, "mean_ms": 0.203325, "min_ms": 0.191488, "max_ms": 0.289792, "std_ms": 0.025177}}} +{"timestamp": "2026-12-01T19:40:27.772282+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_034_instancenorm__fp16", "source_kb_id": 34, "category": "normalization", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_034_instancenorm__fp16.py", "reference_code": "\"\"\"Task kb1_034_instancenorm__fp16 (KernelBench Level 1 #34, split=train, category=normalization, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_034_instancenorm__fp16\"\nSOURCE_KB_ID = 34\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Instance Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the InstanceNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.inorm = nn.InstanceNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Instance Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Instance Normalization applied, same shape as input.\n \"\"\"\n return self.inorm(x)\n\nbatch_size = 112 # heavier workload\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_034_instancenorm__fp16 (KernelBench Level 1 #34, split=train, category=normalization, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_034_instancenorm__fp16\"\nSOURCE_KB_ID = 34\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Instance Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the InstanceNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.inorm = nn.InstanceNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Instance Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Instance Normalization applied, same shape as input.\n \"\"\"\n return self.inorm(x)\n\nbatch_size = 112 # heavier workload\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton InstanceNorm2d kernel normalizing each (n, c) plane over H*W.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef instancenorm2d_kernel(x_ptr, out_ptr, HW, eps, BLOCK_SIZE: tl.constexpr):\n nc = tl.program_id(0)\n base = nc * HW\n sum_x = 0.0\n sum_x2 = 0.0\n for off in range(0, HW, BLOCK_SIZE):\n idx = off + tl.arange(0, BLOCK_SIZE)\n mask = idx < HW\n x = tl.load(x_ptr + base + idx, mask=mask, other=0.0).to(tl.float32)\n sum_x += tl.sum(x, axis=0)\n sum_x2 += tl.sum(x * x, axis=0)\n mean = sum_x / HW\n var = tl.maximum(sum_x2 / HW - mean * mean, 0.0)\n rstd = tl.rsqrt(var + eps)\n for off in range(0, HW, BLOCK_SIZE):\n idx = off + tl.arange(0, BLOCK_SIZE)\n mask = idx < HW\n x = tl.load(x_ptr + base + idx, mask=mask, other=0.0)\n tl.store(out_ptr + base + idx, ((x.to(tl.float32) - mean) * rstd).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, num_features: int):\n super().__init__()\n self.inorm = nn.InstanceNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, H, W = x.shape\n out = torch.empty_like(x)\n instancenorm2d_kernel[(N * C,)](x, out, H * W, self.inorm.eps, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.1448, "raw_speedup": 1.1448, "ref_ms": 0.829952, "cand_ms": 0.724992, "max_abs_diff": 0.00390625, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.829952, "mean_ms": 0.853381, "min_ms": 0.753664, "max_ms": 1.378304, "std_ms": 0.098476}, "cand_stats": {"median_ms": 0.724992, "mean_ms": 0.756859, "min_ms": 0.65024, "max_ms": 1.230848, "std_ms": 0.108435}}, "audited_timestamp": "2026-12-01T23:34:32.965487+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.1622, "raw_speedup": 1.1622, "ref_ms": 0.704512, "cand_ms": 0.606208, "max_abs_diff": 0.00390625, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.704512, "mean_ms": 0.727429, "min_ms": 0.697344, "max_ms": 0.920576, "std_ms": 0.047163}, "cand_stats": {"median_ms": 0.606208, "mean_ms": 0.655421, "min_ms": 0.560128, "max_ms": 1.61792, "std_ms": 0.169481}}} +{"timestamp": "2026-12-01T19:40:32.757986+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_038_l1norm__fp16", "source_kb_id": 38, "category": "normalization", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_038_l1norm__fp16.py", "reference_code": "\"\"\"Task kb1_038_l1norm__fp16 (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm__fp16\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_038_l1norm__fp16 (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm__fp16\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused row-wise Triton L1 normalization: x / mean(|x|, dim=1, keepdim=True).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef l1_norm_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n sum_abs = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n sum_abs += tl.sum(tl.abs(x), axis=0)\n inv_mean = n_cols / sum_abs\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0)\n tl.store(out_ptr + row * stride_row + cols, (x.to(tl.float32) * inv_mean).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n n_rows, n_cols = x.shape\n out = torch.empty_like(x)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 4096)\n l1_norm_kernel[(n_rows,)](x, out, x.stride(0), n_cols, BLOCK_SIZE=BLOCK_SIZE)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.4324, "raw_speedup": 1.4324, "ref_ms": 0.569856, "cand_ms": 0.397824, "max_abs_diff": 0.00390625, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.569856, "mean_ms": 0.602542, "min_ms": 0.546816, "max_ms": 0.963584, "std_ms": 0.079677}, "cand_stats": {"median_ms": 0.397824, "mean_ms": 0.42412, "min_ms": 0.346112, "max_ms": 0.679936, "std_ms": 0.076524}}, "audited_timestamp": "2026-12-01T23:34:39.305565+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.8992, "raw_speedup": 1.8992, "ref_ms": 0.511488, "cand_ms": 0.269312, "max_abs_diff": 0.00390625, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.511488, "mean_ms": 0.545853, "min_ms": 0.503808, "max_ms": 0.705536, "std_ms": 0.050434}, "cand_stats": {"median_ms": 0.269312, "mean_ms": 0.278835, "min_ms": 0.262144, "max_ms": 0.352256, "std_ms": 0.022222}}} +{"timestamp": "2026-12-01T19:40:37.804360+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_049_max_reduction_over_a_dimension__fp16", "source_kb_id": 49, "category": "reduction_scan", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_049_max_reduction_over_a_dimension__fp16.py", "reference_code": "\"\"\"Task kb1_049_max_reduction_over_a_dimension__fp16 (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension__fp16\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_049_max_reduction_over_a_dimension__fp16 (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension__fp16\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton max reduction over arbitrary dim using strided outer/inner indexing.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef max_reduce_kernel(x_ptr, out_ptr, reduce_size, inner_size, BLOCK_R: tl.constexpr):\n pid = tl.program_id(0)\n outer = pid // inner_size\n inner = pid % inner_size\n base = outer * reduce_size * inner_size + inner\n best = -float(\"inf\")\n for r_start in range(0, reduce_size, BLOCK_R):\n r = r_start + tl.arange(0, BLOCK_R)\n mask = r < reduce_size\n vals = tl.load(x_ptr + base + r * inner_size, mask=mask, other=-float(\"inf\")).to(tl.float32)\n best = tl.maximum(best, tl.max(vals, axis=0))\n tl.store(out_ptr + pid, best)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n dim = self.dim % x.ndim\n outer_size = 1\n for s in x.shape[:dim]:\n outer_size *= s\n reduce_size = x.shape[dim]\n inner_size = 1\n for s in x.shape[dim + 1:]:\n inner_size *= s\n out = torch.empty(x.shape[:dim] + x.shape[dim + 1:], device=x.device, dtype=x.dtype)\n BLOCK_R = min(triton.next_power_of_2(reduce_size), 1024)\n max_reduce_kernel[(outer_size * inner_size,)](x, out, reduce_size, inner_size, BLOCK_R=BLOCK_R)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.3037, "raw_speedup": 0.3037, "ref_ms": 0.165888, "cand_ms": 0.546304, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.165888, "mean_ms": 0.186245, "min_ms": 0.1536, "max_ms": 0.35328, "std_ms": 0.038899}, "cand_stats": {"median_ms": 0.546304, "mean_ms": 0.563446, "min_ms": 0.479232, "max_ms": 0.859136, "std_ms": 0.060108}}, "audited_timestamp": "2026-12-01T23:34:44.651136+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.3537, "raw_speedup": 0.3537, "ref_ms": 0.175104, "cand_ms": 0.495104, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.175104, "mean_ms": 0.178033, "min_ms": 0.116736, "max_ms": 0.254976, "std_ms": 0.029626}, "cand_stats": {"median_ms": 0.495104, "mean_ms": 0.490516, "min_ms": 0.4096, "max_ms": 0.63488, "std_ms": 0.049139}}} +{"timestamp": "2026-12-01T19:40:47.430982+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_086_conv_depthwise_separable_2d__fp16", "source_kb_id": 86, "category": "convolution", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_086_conv_depthwise_separable_2d__fp16.py", "reference_code": "\"\"\"Task kb1_086_conv_depthwise_separable_2d__fp16 (KernelBench Level 1 #86, split=train, category=convolution, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_086_conv_depthwise_separable_2d__fp16\"\nSOURCE_KB_ID = 86\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise-separable 2D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise-separable 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n x = self.depthwise(x)\n x = self.pointwise(x)\n return x\n\n# Test code\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 1\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_086_conv_depthwise_separable_2d__fp16 (KernelBench Level 1 #86, split=train, category=convolution, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_086_conv_depthwise_separable_2d__fp16\"\nSOURCE_KB_ID = 86\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise-separable 2D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise-separable 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n x = self.depthwise(x)\n x = self.pointwise(x)\n return x\n\n# Test code\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 1\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton depthwise-separable 2D conv (depthwise Triton kernel + 1x1 pointwise tiled Triton tl.dot kernel).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef dw_conv2d_dilated_kernel(x_ptr, w_ptr, out_ptr, C, H_in, W_in, H_out, W_out, K: tl.constexpr, stride, padding, dilation, BLOCK: tl.constexpr):\n nc = tl.program_id(0)\n c = nc % C\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n x_base = nc * H_in * W_in\n w_base = c * K * K\n for kh in range(K):\n hi = ho * stride - padding + kh * dilation\n for kw in range(K):\n wi = wo * stride - padding + kw * dilation\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n acc += tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32) * tl.load(w_ptr + w_base + kh * K + kw).to(tl.float32)\n tl.store(out_ptr + nc * HW_out + idx, acc, mask=out_mask)\n\n@triton.jit\ndef pointwise_mm_kernel(\n w_ptr, x_ptr, out_ptr, C_out, HW, C_in,\n stride_wc, stride_wk, stride_xn, stride_xk, stride_xhw, stride_on, stride_oc, stride_ohw,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr, USE_IEEE: tl.constexpr,\n):\n n = tl.program_id(2)\n offs_m = tl.program_id(0) * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = tl.program_id(1) * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, C_in, BLOCK_K):\n k_mask = (k_start + offs_k) < C_in\n w = tl.load(w_ptr + offs_m[:, None] * stride_wc + (k_start + offs_k)[None, :] * stride_wk, mask=(offs_m[:, None] < C_out) & k_mask[None, :], other=0.0)\n x = tl.load(x_ptr + n * stride_xn + (k_start + offs_k)[:, None] * stride_xk + offs_n[None, :] * stride_xhw, mask=k_mask[:, None] & (offs_n[None, :] < HW), other=0.0)\n if USE_IEEE:\n acc += tl.dot(w, x, input_precision=\"ieee\")\n else:\n acc += tl.dot(w, x)\n tl.store(out_ptr + n * stride_on + offs_m[:, None] * stride_oc + offs_n[None, :] * stride_ohw, acc, mask=(offs_m[:, None] < C_out) & (offs_n[None, :] < HW))\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super().__init__()\n self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias)\n self.kernel_size = kernel_size\n self.stride = stride\n self.padding = padding\n self.dilation = dilation\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C_in, H_in, W_in = x.shape\n H_out = (H_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n W_out = (W_in + 2 * self.padding - self.dilation * (self.kernel_size - 1) - 1) // self.stride + 1\n dw_out = torch.empty((N, C_in, H_out, W_out), device=x.device, dtype=x.dtype)\n BLOCK = 256\n dw_conv2d_dilated_kernel[(N * C_in, triton.cdiv(H_out * W_out, BLOCK))](\n x, self.depthwise.weight.contiguous(), dw_out,\n C_in, H_in, W_in, H_out, W_out, K=self.kernel_size, stride=self.stride, padding=self.padding, dilation=self.dilation, BLOCK=BLOCK,\n )\n C_out = self.pointwise.weight.shape[0]\n HW = H_out * W_out\n w_pw = self.pointwise.weight.contiguous().view(C_out, C_in)\n dw_flat = dw_out.view(N, C_in, HW)\n out = torch.empty((N, C_out, HW), device=x.device, dtype=x.dtype)\n BM, BN, BK = 32, 64, 32\n pointwise_mm_kernel[(triton.cdiv(C_out, BM), triton.cdiv(HW, BN), N)](\n w_pw, dw_flat, out, C_out, HW, C_in,\n w_pw.stride(0), w_pw.stride(1),\n dw_flat.stride(0), dw_flat.stride(1), dw_flat.stride(2),\n out.stride(0), out.stride(1), out.stride(2),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(x.dtype == torch.float32),\n )\n return out.view(N, C_out, H_out, W_out)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 10, "speedup": 0.8226, "raw_speedup": 0.8226, "ref_ms": 0.6528, "cand_ms": 0.7936, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.6528, "mean_ms": 0.664883, "min_ms": 0.586752, "max_ms": 0.859136, "std_ms": 0.063594}, "cand_stats": {"median_ms": 0.7936, "mean_ms": 0.814797, "min_ms": 0.70656, "max_ms": 1.032192, "std_ms": 0.089014}}, "audited_timestamp": "2026-12-01T23:34:53.214524+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.84, "raw_speedup": 0.84, "ref_ms": 0.507904, "cand_ms": 0.604672, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.507904, "mean_ms": 0.516608, "min_ms": 0.502784, "max_ms": 0.646144, "std_ms": 0.026472}, "cand_stats": {"median_ms": 0.604672, "mean_ms": 0.626688, "min_ms": 0.601088, "max_ms": 0.758784, "std_ms": 0.038107}}} +{"timestamp": "2026-12-01T19:40:52.287065+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_098_kldivloss__fp16", "source_kb_id": 98, "category": "loss_attention", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_098_kldivloss__fp16.py", "reference_code": "\"\"\"Task kb1_098_kldivloss__fp16 (KernelBench Level 1 #98, split=train, category=loss_attention, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_098_kldivloss__fp16\"\nSOURCE_KB_ID = 98\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Kullback-Leibler Divergence for comparing two distributions.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.kl_div(torch.log(predictions), targets, reduction='batchmean')\n\nbatch_size = 8192 * 2\ninput_shape = (8192 * 2,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [(torch.rand(batch_size, *input_shape)*scale).softmax(dim=-1), torch.rand(batch_size, *input_shape).softmax(dim=-1)]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_098_kldivloss__fp16 (KernelBench Level 1 #98, split=train, category=loss_attention, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_098_kldivloss__fp16\"\nSOURCE_KB_ID = 98\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Kullback-Leibler Divergence for comparing two distributions.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.kl_div(torch.log(predictions), targets, reduction='batchmean')\n\nbatch_size = 8192 * 2\ninput_shape = (8192 * 2,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [(torch.rand(batch_size, *input_shape)*scale).softmax(dim=-1), torch.rand(batch_size, *input_shape).softmax(dim=-1)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton KLDivLoss (batchmean): sum(target * (log(target) - log(pred))) / batch_size.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef kldiv_partial_kernel(pred_ptr, tgt_ptr, partial_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n p = tl.load(pred_ptr + offsets, mask=mask, other=1.0).to(tl.float32)\n t = tl.load(tgt_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n kl = tl.where(mask & (t > 0.0), t * (tl.log(t) - tl.log(p)), 0.0)\n tl.store(partial_ptr + pid, tl.sum(kl, axis=0))\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, predictions: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:\n p = predictions.contiguous()\n t = targets.contiguous()\n n_elements = p.numel()\n BLOCK_SIZE = 1024\n n_blocks = triton.cdiv(n_elements, BLOCK_SIZE)\n partial = torch.empty((n_blocks,), device=p.device, dtype=torch.float32)\n kldiv_partial_kernel[(n_blocks,)](p, t, partial, n_elements, BLOCK_SIZE=BLOCK_SIZE)\n return (partial.sum() / p.shape[0]).to(p.dtype)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 3.9107, "raw_speedup": 3.9107, "ref_ms": 1.12128, "cand_ms": 0.28672, "max_abs_diff": 0.002532958984375, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 1.12128, "mean_ms": 1.133466, "min_ms": 1.113088, "max_ms": 1.368064, "std_ms": 0.041353}, "cand_stats": {"median_ms": 0.28672, "mean_ms": 0.293233, "min_ms": 0.251904, "max_ms": 0.355328, "std_ms": 0.019002}}, "audited_timestamp": "2026-12-01T23:34:59.386411+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 3.7651, "raw_speedup": 3.7651, "ref_ms": 1.083392, "cand_ms": 0.287744, "max_abs_diff": 0.002532958984375, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 1.083392, "mean_ms": 1.115402, "min_ms": 1.072128, "max_ms": 1.301504, "std_ms": 0.053426}, "cand_stats": {"median_ms": 0.287744, "mean_ms": 0.296366, "min_ms": 0.252928, "max_ms": 0.437248, "std_ms": 0.025853}}} +{"timestamp": "2026-12-01T19:40:56.553657+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_100_hingeloss__fp16", "source_kb_id": 100, "category": "loss_attention", "dtype": "fp16", "variant": "fp16", "ref_path": "tasks/train/kb1_100_hingeloss__fp16.py", "reference_code": "\"\"\"Task kb1_100_hingeloss__fp16 (KernelBench Level 1 #100, split=train, category=loss_attention, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_100_hingeloss__fp16\"\nSOURCE_KB_ID = 100\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Hinge Loss for binary classification tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.mean(torch.clamp(1 - predictions * targets, min=0))\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_100_hingeloss__fp16 (KernelBench Level 1 #100, split=train, category=loss_attention, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_100_hingeloss__fp16\"\nSOURCE_KB_ID = 100\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Hinge Loss for binary classification tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.mean(torch.clamp(1 - predictions * targets, min=0))\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton HingeLoss: mean(clamp(1 - predictions * targets, min=0)).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef hinge_partial_kernel(pred_ptr, tgt_ptr, partial_ptr, n_elements, n_cols, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n col = offsets % n_cols\n p = tl.load(pred_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n t = tl.load(tgt_ptr + col, mask=mask, other=0.0).to(tl.float32)\n loss = tl.where(mask, tl.maximum(1.0 - p * t, 0.0), 0.0)\n tl.store(partial_ptr + pid, tl.sum(loss, axis=0))\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, predictions: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:\n p = predictions.contiguous()\n t = targets.contiguous()\n n_elements = p.numel()\n BLOCK_SIZE = 1024\n n_blocks = triton.cdiv(n_elements, BLOCK_SIZE)\n partial = torch.empty((n_blocks,), device=p.device, dtype=torch.float32)\n hinge_partial_kernel[(n_blocks,)](p, t, partial, n_elements, p.shape[-1], BLOCK_SIZE=BLOCK_SIZE)\n return (partial.sum() / n_elements).to(p.dtype)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 2.8066, "raw_speedup": 2.8066, "ref_ms": 0.520192, "cand_ms": 0.185344, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.520192, "mean_ms": 0.542945, "min_ms": 0.416768, "max_ms": 1.179648, "std_ms": 0.128473}, "cand_stats": {"median_ms": 0.185344, "mean_ms": 0.211046, "min_ms": 0.125952, "max_ms": 0.369664, "std_ms": 0.056044}}, "audited_timestamp": "2026-12-01T23:35:04.512992+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 5.1159, "raw_speedup": 5.1159, "ref_ms": 0.361472, "cand_ms": 0.070656, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.361472, "mean_ms": 0.372224, "min_ms": 0.3584, "max_ms": 0.785408, "std_ms": 0.060485}, "cand_stats": {"median_ms": 0.070656, "mean_ms": 0.077517, "min_ms": 0.068608, "max_ms": 0.131072, "std_ms": 0.016997}}} +{"timestamp": "2026-12-01T19:41:01.980422+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_002_standard_matrix_multiplication__shape_nonpow2", "source_kb_id": 2, "category": "matmul", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_002_standard_matrix_multiplication__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication__shape_nonpow2 (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__shape_nonpow2\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\nM = 768\nK = 1536\nN = 1280\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_002_standard_matrix_multiplication__shape_nonpow2 (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__shape_nonpow2\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\nM = 768\nK = 1536\nN = 1280\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled 2D Triton matmul using tl.dot with IEEE fp32 precision and fp16/bf16 tensor-core accumulation.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9024, "raw_speedup": 0.9024, "ref_ms": 0.723968, "cand_ms": 0.802304, "max_abs_diff": 0.001312255859375, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.723968, "mean_ms": 0.736297, "min_ms": 0.6912, "max_ms": 0.840704, "std_ms": 0.030693}, "cand_stats": {"median_ms": 0.802304, "mean_ms": 0.817766, "min_ms": 0.77312, "max_ms": 0.970752, "std_ms": 0.040847}}, "audited_timestamp": "2026-12-01T23:35:11.530890+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9289, "raw_speedup": 0.9289, "ref_ms": 0.682496, "cand_ms": 0.73472, "max_abs_diff": 0.001312255859375, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.682496, "mean_ms": 0.686633, "min_ms": 0.643072, "max_ms": 0.765952, "std_ms": 0.025847}, "cand_stats": {"median_ms": 0.73472, "mean_ms": 0.741335, "min_ms": 0.6656, "max_ms": 0.9216, "std_ms": 0.057556}}} +{"timestamp": "2026-12-01T19:41:07.881080+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_004_matrix_vector_multiplication__shape_wide", "source_kb_id": 4, "category": "matmul", "dtype": "fp32", "variant": "shape_wide", "ref_path": "tasks/train/kb1_004_matrix_vector_multiplication__shape_wide.py", "reference_code": "\"\"\"Task kb1_004_matrix_vector_multiplication__shape_wide (KernelBench Level 1 #4, split=train, category=matmul, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_004_matrix_vector_multiplication__shape_wide\"\nSOURCE_KB_ID = 4\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix-vector multiplication (C = A * B).\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix-vector multiplication.\n\n Args:\n A: Input matrix of shape (M, K).\n B: Input vector of shape (K, 1).\n\n Returns:\n Output vector of shape (M, 1).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256 * 8 # 2048\nK = 131072 * 8 # 1048576\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 16384\nM = 512\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, 1)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_004_matrix_vector_multiplication__shape_wide (KernelBench Level 1 #4, split=train, category=matmul, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_004_matrix_vector_multiplication__shape_wide\"\nSOURCE_KB_ID = 4\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix-vector multiplication (C = A * B).\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix-vector multiplication.\n\n Args:\n A: Input matrix of shape (M, K).\n B: Input vector of shape (K, 1).\n\n Returns:\n Output vector of shape (M, 1).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256 * 8 # 2048\nK = 131072 * 8 # 1048576\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 16384\nM = 512\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, 1)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Row-parallel Triton matrix-vector multiplication (M, K) @ (K, 1) accumulating in fp32.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matvec_kernel(a_ptr, b_ptr, c_ptr, M, K, stride_am, stride_ak, BLOCK_K: tl.constexpr):\n row = tl.program_id(0)\n acc = 0.0\n for k_start in range(0, K, BLOCK_K):\n offs_k = k_start + tl.arange(0, BLOCK_K)\n mask = offs_k < K\n a = tl.load(a_ptr + row * stride_am + offs_k * stride_ak, mask=mask, other=0.0).to(tl.float32)\n b = tl.load(b_ptr + offs_k, mask=mask, other=0.0).to(tl.float32)\n acc += tl.sum(a * b, axis=0)\n tl.store(c_ptr + row, acc)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n A = A.contiguous()\n b_vec = B.contiguous().view(-1)\n M, K = A.shape\n out = torch.empty((M, 1), device=A.device, dtype=A.dtype)\n matvec_kernel[(M,)](A, b_vec, out, M, K, A.stride(0), A.stride(1), BLOCK_K=1024, num_warps=4)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9175, "raw_speedup": 0.9175, "ref_ms": 0.45568, "cand_ms": 0.49664, "max_abs_diff": 0.0068359375, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.45568, "mean_ms": 0.455885, "min_ms": 0.422912, "max_ms": 0.526336, "std_ms": 0.019142}, "cand_stats": {"median_ms": 0.49664, "mean_ms": 0.502927, "min_ms": 0.470016, "max_ms": 0.658432, "std_ms": 0.027066}}, "audited_timestamp": "2026-12-01T23:35:18.427156+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0137, "raw_speedup": 1.0137, "ref_ms": 0.379904, "cand_ms": 0.374784, "max_abs_diff": 0.0068359375, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.379904, "mean_ms": 0.38058, "min_ms": 0.376832, "max_ms": 0.406528, "std_ms": 0.004238}, "cand_stats": {"median_ms": 0.374784, "mean_ms": 0.388219, "min_ms": 0.372736, "max_ms": 0.504832, "std_ms": 0.028962}}} +{"timestamp": "2026-12-01T19:41:12.327548+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_005_matrix_scalar_multiplication__shape_nonpow2", "source_kb_id": 5, "category": "matmul", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_005_matrix_scalar_multiplication__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_005_matrix_scalar_multiplication__shape_nonpow2 (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication__shape_nonpow2\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nM = 3000\nN = 2500\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_005_matrix_scalar_multiplication__shape_nonpow2 (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication__shape_nonpow2\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nM = 3000\nN = 2500\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Elementwise Triton matrix-scalar multiplication C = A * s.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef mat_scalar_mul_kernel(a_ptr, out_ptr, s, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n a = tl.load(a_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, (a.to(tl.float32) * s).to(a.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n A = A.contiguous()\n out = torch.empty_like(A)\n n_elements = A.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n mat_scalar_mul_kernel[grid](A, out, float(s), n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.0447, "raw_speedup": 1.0447, "ref_ms": 0.491008, "cand_ms": 0.470016, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.491008, "mean_ms": 0.492913, "min_ms": 0.382976, "max_ms": 0.594944, "std_ms": 0.042139}, "cand_stats": {"median_ms": 0.470016, "mean_ms": 0.483, "min_ms": 0.452608, "max_ms": 0.603136, "std_ms": 0.032851}}, "audited_timestamp": "2026-12-01T23:35:23.935776+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.997, "raw_speedup": 0.997, "ref_ms": 0.338944, "cand_ms": 0.339968, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.338944, "mean_ms": 0.35029, "min_ms": 0.336896, "max_ms": 0.41984, "std_ms": 0.023178}, "cand_stats": {"median_ms": 0.339968, "mean_ms": 0.347771, "min_ms": 0.33792, "max_ms": 0.407552, "std_ms": 0.018652}}} +{"timestamp": "2026-12-01T19:41:19.225648+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_006_matmul_with_large_k_dimension__shape_tall", "source_kb_id": 6, "category": "matmul", "dtype": "fp32", "variant": "shape_tall", "ref_path": "tasks/train/kb1_006_matmul_with_large_k_dimension__shape_tall.py", "reference_code": "\"\"\"Task kb1_006_matmul_with_large_k_dimension__shape_tall (KernelBench Level 1 #6, split=train, category=matmul, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension__shape_tall\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\nM = 512\nN = 128\nK = 16384\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_006_matmul_with_large_k_dimension__shape_tall (KernelBench Level 1 #6, split=train, category=matmul, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension__shape_tall\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\nM = 512\nN = 128\nK = 16384\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul for large K with fp32 accumulator and IEEE dot precision.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.7426, "raw_speedup": 0.7426, "ref_ms": 0.735744, "cand_ms": 0.99072, "max_abs_diff": 0.036865234375, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.735744, "mean_ms": 0.778895, "min_ms": 0.612352, "max_ms": 1.429504, "std_ms": 0.16808}, "cand_stats": {"median_ms": 0.99072, "mean_ms": 1.061478, "min_ms": 0.858112, "max_ms": 1.762304, "std_ms": 0.208045}}, "audited_timestamp": "2026-12-01T23:35:30.790399+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.7615, "raw_speedup": 0.7615, "ref_ms": 0.586752, "cand_ms": 0.77056, "max_abs_diff": 0.036865234375, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.586752, "mean_ms": 0.588145, "min_ms": 0.584704, "max_ms": 0.635904, "std_ms": 0.007243}, "cand_stats": {"median_ms": 0.77056, "mean_ms": 0.778445, "min_ms": 0.769024, "max_ms": 0.884736, "std_ms": 0.022489}}} +{"timestamp": "2026-12-01T19:41:24.310938+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_007_matmul_with_small_k_dimension__shape_rect", "source_kb_id": 7, "category": "matmul", "dtype": "fp32", "variant": "shape_rect", "ref_path": "tasks/train/kb1_007_matmul_with_small_k_dimension__shape_rect.py", "reference_code": "\"\"\"Task kb1_007_matmul_with_small_k_dimension__shape_rect (KernelBench Level 1 #7, split=train, category=matmul, dtype=fp32, variant=shape_rect).\"\"\"\nPROBLEM_ID = \"kb1_007_matmul_with_small_k_dimension__shape_rect\"\nSOURCE_KB_ID = 7\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_rect\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a small K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16384 * 2\nK = 32 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nK = 64\nM = 2048\nN = 3072\nK = 48\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_007_matmul_with_small_k_dimension__shape_rect (KernelBench Level 1 #7, split=train, category=matmul, dtype=fp32, variant=shape_rect).\"\"\"\nPROBLEM_ID = \"kb1_007_matmul_with_small_k_dimension__shape_rect\"\nSOURCE_KB_ID = 7\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_rect\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a small K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16384 * 2\nK = 32 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nK = 64\nM = 2048\nN = 3072\nK = 48\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul for small K with masked K-tile loads.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.7892, "raw_speedup": 0.7892, "ref_ms": 0.270336, "cand_ms": 0.342528, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.270336, "mean_ms": 0.293949, "min_ms": 0.248832, "max_ms": 0.535552, "std_ms": 0.049642}, "cand_stats": {"median_ms": 0.342528, "mean_ms": 0.35586, "min_ms": 0.290816, "max_ms": 0.477184, "std_ms": 0.040671}}, "audited_timestamp": "2026-12-01T23:35:37.115286+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.7053, "raw_speedup": 0.7053, "ref_ms": 0.218112, "cand_ms": 0.309248, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.218112, "mean_ms": 0.225526, "min_ms": 0.212992, "max_ms": 0.319488, "std_ms": 0.022222}, "cand_stats": {"median_ms": 0.309248, "mean_ms": 0.308654, "min_ms": 0.231424, "max_ms": 0.458752, "std_ms": 0.032995}}} +{"timestamp": "2026-12-01T19:41:29.826198+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_009_tall_skinny_matrix_multiplication__shape_skinny", "source_kb_id": 9, "category": "matmul", "dtype": "fp32", "variant": "shape_skinny", "ref_path": "tasks/train/kb1_009_tall_skinny_matrix_multiplication__shape_skinny.py", "reference_code": "\"\"\"Task kb1_009_tall_skinny_matrix_multiplication__shape_skinny (KernelBench Level 1 #9, split=train, category=matmul, dtype=fp32, variant=shape_skinny).\"\"\"\nPROBLEM_ID = \"kb1_009_tall_skinny_matrix_multiplication__shape_skinny\"\nSOURCE_KB_ID = 9\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_skinny\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) where one of the matrices is tall and skinny (M >> N or N >> M)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): Input matrix of shape (M, K) or (K, M) where M >> N or N >> M.\n B (torch.Tensor): Input matrix of shape (K, N) or (N, K) where M >> N or N >> M.\n\n Returns:\n torch.Tensor: Output matrix of shape (M, N) or (N, M)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 8192\nN = 64\nM = 4096\nN = 32\n\ndef get_inputs():\n A = torch.rand(M, N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_009_tall_skinny_matrix_multiplication__shape_skinny (KernelBench Level 1 #9, split=train, category=matmul, dtype=fp32, variant=shape_skinny).\"\"\"\nPROBLEM_ID = \"kb1_009_tall_skinny_matrix_multiplication__shape_skinny\"\nSOURCE_KB_ID = 9\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_skinny\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) where one of the matrices is tall and skinny (M >> N or N >> M)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): Input matrix of shape (M, K) or (K, M) where M >> N or N >> M.\n B (torch.Tensor): Input matrix of shape (K, N) or (N, K) where M >> N or N >> M.\n\n Returns:\n torch.Tensor: Output matrix of shape (M, N) or (N, M)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 8192\nN = 64\nM = 4096\nN = 32\n\ndef get_inputs():\n A = torch.rand(M, N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul for tall-skinny matrices.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9453, "raw_speedup": 0.9453, "ref_ms": 0.530432, "cand_ms": 0.561152, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.530432, "mean_ms": 0.552571, "min_ms": 0.494592, "max_ms": 0.774144, "std_ms": 0.054875}, "cand_stats": {"median_ms": 0.561152, "mean_ms": 0.600289, "min_ms": 0.487424, "max_ms": 0.9984, "std_ms": 0.099929}}, "audited_timestamp": "2026-12-01T23:35:45.059931+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.1127, "raw_speedup": 1.1127, "ref_ms": 0.475136, "cand_ms": 0.427008, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.475136, "mean_ms": 0.481772, "min_ms": 0.46592, "max_ms": 0.592896, "std_ms": 0.023099}, "cand_stats": {"median_ms": 0.427008, "mean_ms": 0.432783, "min_ms": 0.410624, "max_ms": 0.508928, "std_ms": 0.020843}}} +{"timestamp": "2026-12-01T19:41:35.150518+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_010_3d_tensor_matrix_multiplication__shape_large_batch", "source_kb_id": 10, "category": "matmul", "dtype": "fp32", "variant": "shape_large_batch", "ref_path": "tasks/train/kb1_010_3d_tensor_matrix_multiplication__shape_large_batch.py", "reference_code": "\"\"\"Task kb1_010_3d_tensor_matrix_multiplication__shape_large_batch (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp32, variant=shape_large_batch).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication__shape_large_batch\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_batch\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\nN = 32\nM = 256\nK = 512\nL = 768\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_010_3d_tensor_matrix_multiplication__shape_large_batch (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp32, variant=shape_large_batch).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication__shape_large_batch\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_batch\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\nN = 32\nM = 256\nK = 512\nL = 768\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "3D tensor-matrix multiplication (N, M, K) @ (K, L) flattened to 2D tiled Triton matmul.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n N, M, K = A.shape\n L = B.shape[1]\n return triton_matmul(A.contiguous().view(N * M, K), B.contiguous()).view(N, M, L)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8435, "raw_speedup": 0.8435, "ref_ms": 1.543168, "cand_ms": 1.829376, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.543168, "mean_ms": 1.614684, "min_ms": 1.248256, "max_ms": 2.486272, "std_ms": 0.21059}, "cand_stats": {"median_ms": 1.829376, "mean_ms": 1.886433, "min_ms": 1.497088, "max_ms": 2.597888, "std_ms": 0.242752}}, "audited_timestamp": "2026-12-01T23:35:51.809679+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0651, "raw_speedup": 1.0651, "ref_ms": 1.374208, "cand_ms": 1.29024, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.374208, "mean_ms": 1.373225, "min_ms": 1.178624, "max_ms": 1.549312, "std_ms": 0.075229}, "cand_stats": {"median_ms": 1.29024, "mean_ms": 1.327186, "min_ms": 1.271808, "max_ms": 1.533952, "std_ms": 0.069587}}} +{"timestamp": "2026-12-01T19:41:39.316624+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_012_matmul_with_diagonal_matrices__shape_rect", "source_kb_id": 12, "category": "matmul", "dtype": "fp32", "variant": "shape_rect", "ref_path": "tasks/train/kb1_012_matmul_with_diagonal_matrices__shape_rect.py", "reference_code": "\"\"\"Task kb1_012_matmul_with_diagonal_matrices__shape_rect (KernelBench Level 1 #12, split=train, category=matmul, dtype=fp32, variant=shape_rect).\"\"\"\nPROBLEM_ID = \"kb1_012_matmul_with_diagonal_matrices__shape_rect\"\nSOURCE_KB_ID = 12\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_rect\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication of a diagonal matrix with another matrix.\n C = diag(A) * B\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): A 1D tensor representing the diagonal of the diagonal matrix. Shape: (N,).\n B (torch.Tensor): A 2D tensor representing the second matrix. Shape: (N, M).\n\n Returns:\n torch.Tensor: The result of the matrix multiplication. Shape: (N, M).\n \"\"\"\n # Logically equivalent to torch.diag(A) @ B \n # more efficient as no need to materialize a full N\u00d7N matrix\n return A.unsqueeze(1) * B\n\nM = 4096\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2048\nN = 2048\nM = 1536\nN = 3072\n\ndef get_inputs():\n A = torch.rand(N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_012_matmul_with_diagonal_matrices__shape_rect (KernelBench Level 1 #12, split=train, category=matmul, dtype=fp32, variant=shape_rect).\"\"\"\nPROBLEM_ID = \"kb1_012_matmul_with_diagonal_matrices__shape_rect\"\nSOURCE_KB_ID = 12\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_rect\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication of a diagonal matrix with another matrix.\n C = diag(A) * B\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): A 1D tensor representing the diagonal of the diagonal matrix. Shape: (N,).\n B (torch.Tensor): A 2D tensor representing the second matrix. Shape: (N, M).\n\n Returns:\n torch.Tensor: The result of the matrix multiplication. Shape: (N, M).\n \"\"\"\n # Logically equivalent to torch.diag(A) @ B \n # more efficient as no need to materialize a full N\u00d7N matrix\n return A.unsqueeze(1) * B\n\nM = 4096\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2048\nN = 2048\nM = 1536\nN = 3072\n\ndef get_inputs():\n A = torch.rand(N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton diagonal-matrix multiplication C[r, c] = A[r] * B[r, c].", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef diag_matmul_kernel(a_ptr, b_ptr, c_ptr, N, M, stride_bn, stride_bm, BLOCK_M: tl.constexpr):\n row = tl.program_id(0)\n col_block = tl.program_id(1)\n cols = col_block * BLOCK_M + tl.arange(0, BLOCK_M)\n mask = cols < M\n a_val = tl.load(a_ptr + row)\n b_vals = tl.load(b_ptr + row * stride_bn + cols * stride_bm, mask=mask, other=0.0)\n tl.store(c_ptr + row * stride_bn + cols * stride_bm, a_val * b_vals, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n A = A.contiguous()\n B = B.contiguous()\n N, M = B.shape\n out = torch.empty_like(B)\n BLOCK_M = 1024\n diag_matmul_kernel[(N, triton.cdiv(M, BLOCK_M))](A, B, out, N, M, B.stride(0), B.stride(1), BLOCK_M=BLOCK_M)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8385, "raw_speedup": 0.8385, "ref_ms": 0.263168, "cand_ms": 0.313856, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.263168, "mean_ms": 0.296632, "min_ms": 0.258048, "max_ms": 0.817152, "std_ms": 0.087205}, "cand_stats": {"median_ms": 0.313856, "mean_ms": 0.331674, "min_ms": 0.26624, "max_ms": 0.555008, "std_ms": 0.05919}}, "audited_timestamp": "2026-12-01T23:35:56.833474+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9835, "raw_speedup": 0.9835, "ref_ms": 0.212992, "cand_ms": 0.216576, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.212992, "mean_ms": 0.217559, "min_ms": 0.212992, "max_ms": 0.269312, "std_ms": 0.013281}, "cand_stats": {"median_ms": 0.216576, "mean_ms": 0.218337, "min_ms": 0.214016, "max_ms": 0.256, "std_ms": 0.007182}}} +{"timestamp": "2026-12-01T19:41:44.484308+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_013_matmul_for_symmetric_matrices__shape_small", "source_kb_id": 13, "category": "matmul", "dtype": "fp32", "variant": "shape_small", "ref_path": "tasks/train/kb1_013_matmul_for_symmetric_matrices__shape_small.py", "reference_code": "\"\"\"Task kb1_013_matmul_for_symmetric_matrices__shape_small (KernelBench Level 1 #13, split=train, category=matmul, dtype=fp32, variant=shape_small).\"\"\"\nPROBLEM_ID = \"kb1_013_matmul_for_symmetric_matrices__shape_small\"\nSOURCE_KB_ID = 13\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_small\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with A and B being symmetric matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of two symmetric matrices.\n\n Args:\n A (torch.Tensor): Input matrix A, shape (N, N), symmetric.\n B (torch.Tensor): Input matrix B, shape (N, N), symmetric.\n\n Returns:\n torch.Tensor: Output matrix C, shape (N, N).\n \"\"\"\n return torch.matmul(A, B)\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\nN = 768\n\ndef get_inputs():\n \"\"\"\n Generates a pair of random symmetric matrices for testing.\n\n Returns:\n list: List containing two symmetric tensors A and B.\n \"\"\"\n A = torch.rand(N, N)\n A = (A + A.T) / 2 # Ensure symmetry\n B = torch.rand(N, N)\n B = (B + B.T) / 2 # Ensure symmetry\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs needed for this model.\n\n Returns:\n list: Empty list.\n \"\"\"\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_013_matmul_for_symmetric_matrices__shape_small (KernelBench Level 1 #13, split=train, category=matmul, dtype=fp32, variant=shape_small).\"\"\"\nPROBLEM_ID = \"kb1_013_matmul_for_symmetric_matrices__shape_small\"\nSOURCE_KB_ID = 13\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_small\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with A and B being symmetric matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of two symmetric matrices.\n\n Args:\n A (torch.Tensor): Input matrix A, shape (N, N), symmetric.\n B (torch.Tensor): Input matrix B, shape (N, N), symmetric.\n\n Returns:\n torch.Tensor: Output matrix C, shape (N, N).\n \"\"\"\n return torch.matmul(A, B)\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\nN = 768\n\ndef get_inputs():\n \"\"\"\n Generates a pair of random symmetric matrices for testing.\n\n Returns:\n list: List containing two symmetric tensors A and B.\n \"\"\"\n A = torch.rand(N, N)\n A = (A + A.T) / 2 # Ensure symmetry\n B = torch.rand(N, N)\n B = (B + B.T) / 2 # Ensure symmetry\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs needed for this model.\n\n Returns:\n list: Empty list.\n \"\"\"\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul for symmetric square matrices.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.7466, "raw_speedup": 0.7466, "ref_ms": 0.283648, "cand_ms": 0.379904, "max_abs_diff": 0.00042724609375, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.283648, "mean_ms": 0.295363, "min_ms": 0.275456, "max_ms": 0.431104, "std_ms": 0.030122}, "cand_stats": {"median_ms": 0.379904, "mean_ms": 0.4062, "min_ms": 0.277504, "max_ms": 0.683008, "std_ms": 0.092043}}, "audited_timestamp": "2026-12-01T23:36:02.434768+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9912, "raw_speedup": 0.9912, "ref_ms": 0.2304, "cand_ms": 0.232448, "max_abs_diff": 0.00042724609375, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.2304, "mean_ms": 0.240046, "min_ms": 0.229376, "max_ms": 0.36864, "std_ms": 0.029675}, "cand_stats": {"median_ms": 0.232448, "mean_ms": 0.246682, "min_ms": 0.2304, "max_ms": 0.310272, "std_ms": 0.023233}}} +{"timestamp": "2026-12-01T19:41:50.709127+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_016_matmul_with_transposed_a__shape_nonpow2", "source_kb_id": 16, "category": "matmul", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_016_matmul_with_transposed_a__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_016_matmul_with_transposed_a__shape_nonpow2 (KernelBench Level 1 #16, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a__shape_nonpow2\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\nM = 1536\nK = 1024\nN = 768\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_016_matmul_with_transposed_a__shape_nonpow2 (KernelBench Level 1 #16, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a__shape_nonpow2\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\nM = 1536\nK = 1024\nN = 768\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Tiled Triton matmul with transposed A (A.T @ B) via strided pointers.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef matmul_kernel(\n a_ptr, b_ptr, c_ptr,\n M, N, K,\n stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,\n BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr, BLOCK_K: tl.constexpr,\n USE_IEEE: tl.constexpr,\n):\n pid_m = tl.program_id(0)\n pid_n = tl.program_id(1)\n offs_m = pid_m * BLOCK_M + tl.arange(0, BLOCK_M)\n offs_n = pid_n * BLOCK_N + tl.arange(0, BLOCK_N)\n offs_k = tl.arange(0, BLOCK_K)\n a_ptrs = a_ptr + offs_m[:, None] * stride_am + offs_k[None, :] * stride_ak\n b_ptrs = b_ptr + offs_k[:, None] * stride_bk + offs_n[None, :] * stride_bn\n acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)\n for k_start in range(0, K, BLOCK_K):\n k_mask = (k_start + offs_k) < K\n a = tl.load(a_ptrs, mask=(offs_m[:, None] < M) & k_mask[None, :], other=0.0)\n b = tl.load(b_ptrs, mask=k_mask[:, None] & (offs_n[None, :] < N), other=0.0)\n if USE_IEEE:\n acc += tl.dot(a, b, input_precision=\"ieee\")\n else:\n acc += tl.dot(a, b)\n a_ptrs += BLOCK_K * stride_ak\n b_ptrs += BLOCK_K * stride_bk\n c_ptrs = c_ptr + offs_m[:, None] * stride_cm + offs_n[None, :] * stride_cn\n tl.store(c_ptrs, acc, mask=(offs_m[:, None] < M) & (offs_n[None, :] < N))\n\ndef triton_matmul(A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n M, K = A.shape\n K2, N = B.shape\n assert K == K2\n C = torch.empty((M, N), device=A.device, dtype=A.dtype)\n BM, BN, BK = 64, 64, 32\n grid = (triton.cdiv(M, BM), triton.cdiv(N, BN))\n matmul_kernel[grid](\n A, B, C, M, N, K,\n A.stride(0), A.stride(1), B.stride(0), B.stride(1), C.stride(0), C.stride(1),\n BLOCK_M=BM, BLOCK_N=BN, BLOCK_K=BK, USE_IEEE=(A.dtype == torch.float32), num_warps=4,\n )\n return C\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n return triton_matmul(A.T, B)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8005, "raw_speedup": 0.8005, "ref_ms": 0.65536, "cand_ms": 0.818688, "max_abs_diff": 0.00067138671875, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.65536, "mean_ms": 0.677745, "min_ms": 0.605184, "max_ms": 1.009664, "std_ms": 0.079723}, "cand_stats": {"median_ms": 0.818688, "mean_ms": 0.812298, "min_ms": 0.615424, "max_ms": 1.084416, "std_ms": 0.11404}}, "audited_timestamp": "2026-12-01T23:36:09.565376+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.8732, "raw_speedup": 0.8732, "ref_ms": 0.557056, "cand_ms": 0.637952, "max_abs_diff": 0.00067138671875, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.557056, "mean_ms": 0.582001, "min_ms": 0.553984, "max_ms": 0.795648, "std_ms": 0.052786}, "cand_stats": {"median_ms": 0.637952, "mean_ms": 0.657306, "min_ms": 0.529408, "max_ms": 0.86528, "std_ms": 0.061797}}} +{"timestamp": "2026-12-01T19:41:54.946373+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_020_leakyrelu__shape_wide", "source_kb_id": 20, "category": "activation", "dtype": "fp32", "variant": "shape_wide", "ref_path": "tasks/train/kb1_020_leakyrelu__shape_wide.py", "reference_code": "\"\"\"Task kb1_020_leakyrelu__shape_wide (KernelBench Level 1 #20, split=train, category=activation, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu__shape_wide\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 512\ndim = 12288\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_020_leakyrelu__shape_wide (KernelBench Level 1 #20, split=train, category=activation, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu__shape_wide\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 512\ndim = 12288\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fuse LeakyReLU elementwise in Triton using tl.where(x >= 0, x, x * negative_slope), matching Model.__init__(negative_slope).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef leaky_relu_kernel(x_ptr, out_ptr, n_elements, negative_slope, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n out = tl.where(x >= 0, x, x * negative_slope)\n tl.store(out_ptr + offsets, out, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, negative_slope: float = 0.01):\n super().__init__()\n self.negative_slope = negative_slope\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n leaky_relu_kernel[grid](x, out, n_elements, self.negative_slope, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8575, "raw_speedup": 0.8575, "ref_ms": 0.375808, "cand_ms": 0.438272, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.375808, "mean_ms": 0.392315, "min_ms": 0.330752, "max_ms": 0.602112, "std_ms": 0.064559}, "cand_stats": {"median_ms": 0.438272, "mean_ms": 0.466104, "min_ms": 0.380928, "max_ms": 0.713728, "std_ms": 0.071338}}, "audited_timestamp": "2026-12-01T23:36:14.684866+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9964, "raw_speedup": 0.9964, "ref_ms": 0.285696, "cand_ms": 0.28672, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.285696, "mean_ms": 0.290386, "min_ms": 0.283648, "max_ms": 0.422912, "std_ms": 0.021593}, "cand_stats": {"median_ms": 0.28672, "mean_ms": 0.304415, "min_ms": 0.283648, "max_ms": 0.606208, "std_ms": 0.058096}}} +{"timestamp": "2026-12-01T19:41:58.713472+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_021_sigmoid__shape_nonpow2", "source_kb_id": 21, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_021_sigmoid__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_021_sigmoid__shape_nonpow2 (KernelBench Level 1 #21, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid__shape_nonpow2\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1500\ndim = 3000\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_021_sigmoid__shape_nonpow2 (KernelBench Level 1 #21, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid__shape_nonpow2\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1500\ndim = 3000\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise Sigmoid in Triton using tl.sigmoid in fp32.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef sigmoid_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n out = tl.sigmoid(x.to(tl.float32)).to(x.dtype)\n tl.store(out_ptr + offsets, out, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n sigmoid_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9408, "raw_speedup": 0.9408, "ref_ms": 0.301056, "cand_ms": 0.32, "max_abs_diff": 1.7881393432617188e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.301056, "mean_ms": 0.304517, "min_ms": 0.259072, "max_ms": 0.427008, "std_ms": 0.04351}, "cand_stats": {"median_ms": 0.32, "mean_ms": 0.337613, "min_ms": 0.253952, "max_ms": 0.572416, "std_ms": 0.065304}}, "audited_timestamp": "2026-12-01T23:36:20.977347+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9926, "raw_speedup": 0.9926, "ref_ms": 0.206848, "cand_ms": 0.208384, "max_abs_diff": 1.7881393432617188e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.206848, "mean_ms": 0.211292, "min_ms": 0.2048, "max_ms": 0.259072, "std_ms": 0.011342}, "cand_stats": {"median_ms": 0.208384, "mean_ms": 0.219361, "min_ms": 0.2048, "max_ms": 0.318464, "std_ms": 0.02771}}} +{"timestamp": "2026-12-01T19:42:03.117664+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_022_tanh__shape_tall", "source_kb_id": 22, "category": "activation", "dtype": "fp32", "variant": "shape_tall", "ref_path": "tasks/train/kb1_022_tanh__shape_tall.py", "reference_code": "\"\"\"Task kb1_022_tanh__shape_tall (KernelBench Level 1 #22, split=train, category=activation, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh__shape_tall\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 8192\ndim = 1024\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_022_tanh__shape_tall (KernelBench Level 1 #22, split=train, category=activation, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh__shape_tall\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 8192\ndim = 1024\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise Tanh in Triton via 2*tl.sigmoid(2*x)-1 in fp32.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef tanh_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n out = (2.0 * tl.sigmoid(2.0 * xf) - 1.0).to(x.dtype)\n tl.store(out_ptr + offsets, out, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n tanh_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9541, "raw_speedup": 0.9541, "ref_ms": 0.531968, "cand_ms": 0.557568, "max_abs_diff": 2.384185791015625e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.531968, "mean_ms": 0.5521, "min_ms": 0.44032, "max_ms": 0.941056, "std_ms": 0.108038}, "cand_stats": {"median_ms": 0.557568, "mean_ms": 0.627876, "min_ms": 0.447488, "max_ms": 1.644544, "std_ms": 0.185073}}, "audited_timestamp": "2026-12-01T23:36:26.290526+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0, "raw_speedup": 1.0, "ref_ms": 0.379904, "cand_ms": 0.379904, "max_abs_diff": 2.384185791015625e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.379904, "mean_ms": 0.386888, "min_ms": 0.377856, "max_ms": 0.459776, "std_ms": 0.020385}, "cand_stats": {"median_ms": 0.379904, "mean_ms": 0.386212, "min_ms": 0.375808, "max_ms": 0.463872, "std_ms": 0.020822}}} +{"timestamp": "2026-12-01T19:42:07.288057+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_024_logsoftmax__shape_vocab", "source_kb_id": 24, "category": "activation", "dtype": "fp32", "variant": "shape_vocab", "ref_path": "tasks/train/kb1_024_logsoftmax__shape_vocab.py", "reference_code": "\"\"\"Task kb1_024_logsoftmax__shape_vocab (KernelBench Level 1 #24, split=train, category=activation, dtype=fp32, variant=shape_vocab).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax__shape_vocab\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_vocab\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 512\ndim = 16384\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_024_logsoftmax__shape_vocab (KernelBench Level 1 #24, split=train, category=activation, dtype=fp32, variant=shape_vocab).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax__shape_vocab\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_vocab\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 512\ndim = 16384\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fuse numerically stable row-wise LogSoftmax in Triton supporting arbitrary dim via transpose.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef log_softmax_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n row_max = -float(\"inf\")\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=-float(\"inf\")).to(tl.float32)\n row_max = tl.maximum(row_max, tl.max(x, axis=0))\n sum_exp = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=-float(\"inf\")).to(tl.float32)\n sum_exp += tl.sum(tl.where(mask, tl.exp(x - row_max), 0.0), axis=0)\n lse = row_max + tl.log(sum_exp)\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0)\n tl.store(out_ptr + row * stride_row + cols, (x.to(tl.float32) - lse).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int = 1):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n dim = self.dim % x.ndim\n x_t = x.transpose(dim, -1).contiguous()\n orig_shape = x_t.shape\n x_2d = x_t.view(-1, orig_shape[-1])\n n_rows, n_cols = x_2d.shape\n out = torch.empty_like(x_2d)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 4096)\n log_softmax_kernel[(n_rows,)](x_2d, out, x_2d.stride(0), n_cols, BLOCK_SIZE=BLOCK_SIZE)\n return out.view(orig_shape).transpose(dim, -1).contiguous()\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.6168, "raw_speedup": 0.6168, "ref_ms": 0.60416, "cand_ms": 0.979456, "max_abs_diff": 1.9073486328125e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.60416, "mean_ms": 0.64043, "min_ms": 0.503808, "max_ms": 1.073152, "std_ms": 0.127068}, "cand_stats": {"median_ms": 0.979456, "mean_ms": 1.071493, "min_ms": 0.805888, "max_ms": 2.354176, "std_ms": 0.287428}}, "audited_timestamp": "2026-12-01T23:36:32.015327+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.613, "raw_speedup": 0.613, "ref_ms": 0.452608, "cand_ms": 0.738304, "max_abs_diff": 1.9073486328125e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.452608, "mean_ms": 0.461169, "min_ms": 0.447488, "max_ms": 0.615424, "std_ms": 0.028813}, "cand_stats": {"median_ms": 0.738304, "mean_ms": 0.750592, "min_ms": 0.736256, "max_ms": 0.8704, "std_ms": 0.030926}}} +{"timestamp": "2026-12-01T19:42:11.342018+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_027_selu__shape_nonpow2", "source_kb_id": 27, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_027_selu__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_027_selu__shape_nonpow2 (KernelBench Level 1 #27, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_027_selu__shape_nonpow2\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 6144\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_027_selu__shape_nonpow2 (KernelBench Level 1 #27, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_027_selu__shape_nonpow2\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 6144\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise SELU in Triton with standard alpha and scale constants.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef selu_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = 1.0507009873554805 * tl.where(xf > 0.0, xf, 1.6732632423543772 * (tl.exp(xf) - 1.0))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n selu_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8791, "raw_speedup": 0.8791, "ref_ms": 0.357376, "cand_ms": 0.406528, "max_abs_diff": 3.5762786865234375e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.357376, "mean_ms": 0.36864, "min_ms": 0.329728, "max_ms": 0.498688, "std_ms": 0.04081}, "cand_stats": {"median_ms": 0.406528, "mean_ms": 0.410747, "min_ms": 0.333824, "max_ms": 0.559104, "std_ms": 0.045802}}, "audited_timestamp": "2026-12-01T23:36:37.296146+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9964, "raw_speedup": 0.9964, "ref_ms": 0.28672, "cand_ms": 0.287744, "max_abs_diff": 3.5762786865234375e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.28672, "mean_ms": 0.297533, "min_ms": 0.283648, "max_ms": 0.483328, "std_ms": 0.036004}, "cand_stats": {"median_ms": 0.287744, "mean_ms": 0.307814, "min_ms": 0.283648, "max_ms": 0.544768, "std_ms": 0.044284}}} +{"timestamp": "2026-12-01T19:42:15.631070+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_029_softplus__shape_wide", "source_kb_id": 29, "category": "activation", "dtype": "fp32", "variant": "shape_wide", "ref_path": "tasks/train/kb1_029_softplus__shape_wide.py", "reference_code": "\"\"\"Task kb1_029_softplus__shape_wide (KernelBench Level 1 #29, split=train, category=activation, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus__shape_wide\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 8192\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_029_softplus__shape_wide (KernelBench Level 1 #29, split=train, category=activation, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus__shape_wide\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 8192\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement numerically stable Softplus in Triton: x when x > 20 else log(1 + exp(x)).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef softplus_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = tl.where(xf > 20.0, xf, tl.log(1.0 + tl.exp(xf)))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n softplus_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9038, "raw_speedup": 0.9038, "ref_ms": 0.457216, "cand_ms": 0.505856, "max_abs_diff": 4.76837158203125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.457216, "mean_ms": 0.470528, "min_ms": 0.431104, "max_ms": 0.708608, "std_ms": 0.042732}, "cand_stats": {"median_ms": 0.505856, "mean_ms": 0.521892, "min_ms": 0.438272, "max_ms": 0.75264, "std_ms": 0.061171}}, "audited_timestamp": "2026-12-01T23:36:42.259721+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0, "raw_speedup": 1.0, "ref_ms": 0.380928, "cand_ms": 0.380928, "max_abs_diff": 4.76837158203125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.380928, "mean_ms": 0.390513, "min_ms": 0.376832, "max_ms": 0.492544, "std_ms": 0.022635}, "cand_stats": {"median_ms": 0.380928, "mean_ms": 0.405217, "min_ms": 0.376832, "max_ms": 0.802816, "std_ms": 0.064816}}} +{"timestamp": "2026-12-01T19:42:21.148945+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_030_softsign__shape_nonpow2", "source_kb_id": 30, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_030_softsign__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_030_softsign__shape_nonpow2 (KernelBench Level 1 #30, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_030_softsign__shape_nonpow2\"\nSOURCE_KB_ID = 30\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softsign activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softsign activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softsign applied, same shape as input.\n \"\"\"\n return x / (1 + torch.abs(x))\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 3000\ndim = 2000\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_030_softsign__shape_nonpow2 (KernelBench Level 1 #30, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_030_softsign__shape_nonpow2\"\nSOURCE_KB_ID = 30\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softsign activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softsign activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softsign applied, same shape as input.\n \"\"\"\n return x / (1 + torch.abs(x))\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 3000\ndim = 2000\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise Softsign in Triton: x / (1 + |x|).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef softsign_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = xf / (1.0 + tl.abs(xf))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n softsign_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 3.1907, "raw_speedup": 3.1907, "ref_ms": 1.088, "cand_ms": 0.340992, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.088, "mean_ms": 1.0897, "min_ms": 0.97792, "max_ms": 1.327104, "std_ms": 0.063697}, "cand_stats": {"median_ms": 0.340992, "mean_ms": 0.355697, "min_ms": 0.315392, "max_ms": 0.443392, "std_ms": 0.036433}}, "audited_timestamp": "2026-12-01T23:36:47.101702+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 3.4624, "raw_speedup": 3.4624, "ref_ms": 0.943104, "cand_ms": 0.272384, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.943104, "mean_ms": 0.946975, "min_ms": 0.939008, "max_ms": 1.002496, "std_ms": 0.012014}, "cand_stats": {"median_ms": 0.272384, "mean_ms": 0.276603, "min_ms": 0.270336, "max_ms": 0.349184, "std_ms": 0.013689}}} +{"timestamp": "2026-12-01T19:42:25.455530+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_031_elu__shape_tall", "source_kb_id": 31, "category": "activation", "dtype": "fp32", "variant": "shape_tall", "ref_path": "tasks/train/kb1_031_elu__shape_tall.py", "reference_code": "\"\"\"Task kb1_031_elu__shape_tall (KernelBench Level 1 #31, split=train, category=activation, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_031_elu__shape_tall\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 4096\ndim = 2048\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_031_elu__shape_tall (KernelBench Level 1 #31, split=train, category=activation, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_031_elu__shape_tall\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 4096\ndim = 2048\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise ELU in Triton matching Model.__init__(alpha=1.0).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef elu_kernel(x_ptr, out_ptr, n_elements, alpha, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = tl.where(xf > 0.0, xf, alpha * (tl.exp(xf) - 1.0))\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, alpha: float = 1.0):\n super().__init__()\n self.alpha = alpha\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n elu_kernel[grid](x, out, n_elements, self.alpha, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8917, "raw_speedup": 0.8917, "ref_ms": 0.459264, "cand_ms": 0.515072, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.459264, "mean_ms": 0.47362, "min_ms": 0.427008, "max_ms": 0.59392, "std_ms": 0.038739}, "cand_stats": {"median_ms": 0.515072, "mean_ms": 0.525435, "min_ms": 0.438272, "max_ms": 0.708608, "std_ms": 0.054967}}, "audited_timestamp": "2026-12-01T23:36:53.292673+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9973, "raw_speedup": 0.9973, "ref_ms": 0.37888, "cand_ms": 0.379904, "max_abs_diff": 1.1920928955078125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.37888, "mean_ms": 0.383508, "min_ms": 0.376832, "max_ms": 0.428032, "std_ms": 0.013254}, "cand_stats": {"median_ms": 0.379904, "mean_ms": 0.386765, "min_ms": 0.375808, "max_ms": 0.446464, "std_ms": 0.018668}}} +{"timestamp": "2026-12-01T19:42:29.517630+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_032_hardtanh__shape_nonpow2", "source_kb_id": 32, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_032_hardtanh__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_032_hardtanh__shape_nonpow2 (KernelBench Level 1 #32, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_032_hardtanh__shape_nonpow2\"\nSOURCE_KB_ID = 32\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardTanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardTanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardTanh applied, same shape as input.\n \"\"\"\n return F.hardtanh(x, min_val=-1., max_val=1.)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 2500\ndim = 3072\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_032_hardtanh__shape_nonpow2 (KernelBench Level 1 #32, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_032_hardtanh__shape_nonpow2\"\nSOURCE_KB_ID = 32\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardTanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardTanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardTanh applied, same shape as input.\n \"\"\"\n return F.hardtanh(x, min_val=-1., max_val=1.)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 2500\ndim = 3072\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Implement elementwise HardTanh in Triton: clamp(x, -1.0, 1.0).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef hardtanh_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n y = tl.minimum(tl.maximum(xf, -1.0), 1.0)\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n hardtanh_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8951, "raw_speedup": 0.8951, "ref_ms": 0.441344, "cand_ms": 0.493056, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.441344, "mean_ms": 0.458138, "min_ms": 0.39936, "max_ms": 0.590848, "std_ms": 0.04531}, "cand_stats": {"median_ms": 0.493056, "mean_ms": 0.506634, "min_ms": 0.423936, "max_ms": 0.663552, "std_ms": 0.055593}}, "audited_timestamp": "2026-12-01T23:36:58.204856+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.9971, "raw_speedup": 0.9971, "ref_ms": 0.347136, "cand_ms": 0.34816, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.347136, "mean_ms": 0.348324, "min_ms": 0.345088, "max_ms": 0.4096, "std_ms": 0.008918}, "cand_stats": {"median_ms": 0.34816, "mean_ms": 0.355103, "min_ms": 0.344064, "max_ms": 0.45568, "std_ms": 0.020264}}} +{"timestamp": "2026-12-01T19:42:33.774425+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_033_batchnorm__shape_spatial", "source_kb_id": 33, "category": "normalization", "dtype": "fp32", "variant": "shape_spatial", "ref_path": "tasks/train/kb1_033_batchnorm__shape_spatial.py", "reference_code": "\"\"\"Task kb1_033_batchnorm__shape_spatial (KernelBench Level 1 #33, split=train, category=normalization, dtype=fp32, variant=shape_spatial).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm__shape_spatial\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_spatial\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\nbatch_size = 8\nfeatures = 128\ndim1 = 64\ndim2 = 64\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_033_batchnorm__shape_spatial (KernelBench Level 1 #33, split=train, category=normalization, dtype=fp32, variant=shape_spatial).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm__shape_spatial\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_spatial\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\nbatch_size = 8\nfeatures = 128\ndim1 = 64\ndim2 = 64\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton BatchNorm2d inference kernel preserving self.bn = nn.BatchNorm2d(num_features).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef batchnorm2d_eval_kernel(\n x_ptr, out_ptr, w_ptr, b_ptr, mean_ptr, var_ptr,\n n_elements, C, HW, eps, BLOCK_SIZE: tl.constexpr,\n):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n c = (offsets // HW) % C\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n mean = tl.load(mean_ptr + c, mask=mask, other=0.0).to(tl.float32)\n var = tl.load(var_ptr + c, mask=mask, other=1.0).to(tl.float32)\n w = tl.load(w_ptr + c, mask=mask, other=1.0).to(tl.float32)\n b = tl.load(b_ptr + c, mask=mask, other=0.0).to(tl.float32)\n y = (x.to(tl.float32) - mean) * tl.rsqrt(var + eps) * w + b\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, num_features: int):\n super().__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, H, W = x.shape\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n batchnorm2d_eval_kernel[grid](\n x, out, self.bn.weight, self.bn.bias,\n self.bn.running_mean, self.bn.running_var,\n n_elements, C, H * W, self.bn.eps, BLOCK_SIZE=1024,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.234, "raw_speedup": 1.234, "ref_ms": 0.356352, "cand_ms": 0.288768, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.356352, "mean_ms": 0.342671, "min_ms": 0.243712, "max_ms": 0.475136, "std_ms": 0.056063}, "cand_stats": {"median_ms": 0.288768, "mean_ms": 0.291205, "min_ms": 0.24576, "max_ms": 0.34816, "std_ms": 0.013219}}, "audited_timestamp": "2026-12-01T23:37:03.001177+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0159, "raw_speedup": 1.0159, "ref_ms": 0.196608, "cand_ms": 0.193536, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.196608, "mean_ms": 0.208773, "min_ms": 0.193536, "max_ms": 0.328704, "std_ms": 0.027266}, "cand_stats": {"median_ms": 0.193536, "mean_ms": 0.209121, "min_ms": 0.191488, "max_ms": 0.382976, "std_ms": 0.041592}}} +{"timestamp": "2026-12-01T19:42:37.653220+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_035_groupnorm__shape_groups16", "source_kb_id": 35, "category": "normalization", "dtype": "fp32", "variant": "shape_groups16", "ref_path": "tasks/train/kb1_035_groupnorm__shape_groups16.py", "reference_code": "\"\"\"Task kb1_035_groupnorm__shape_groups16 (KernelBench Level 1 #35, split=train, category=normalization, dtype=fp32, variant=shape_groups16).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm__shape_groups16\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_groups16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\nbatch_size = 8\nfeatures = 128\nnum_groups = 16\ndim1 = 64\ndim2 = 64\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_035_groupnorm__shape_groups16 (KernelBench Level 1 #35, split=train, category=normalization, dtype=fp32, variant=shape_groups16).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm__shape_groups16\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_groups16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\nbatch_size = 8\nfeatures = 128\nnum_groups = 16\ndim1 = 64\ndim2 = 64\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton GroupNorm kernel normalizing each (n, g) group with affine weight/bias from self.gn.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef groupnorm_kernel(x_ptr, out_ptr, w_ptr, b_ptr, C, G, HW, eps, BLOCK_SIZE: tl.constexpr):\n ng = tl.program_id(0)\n n = ng // G\n g = ng % G\n c_per_g = C // G\n group_size = c_per_g * HW\n base = (n * C + g * c_per_g) * HW\n sum_x = 0.0\n sum_x2 = 0.0\n for off in range(0, group_size, BLOCK_SIZE):\n idx = off + tl.arange(0, BLOCK_SIZE)\n mask = idx < group_size\n x = tl.load(x_ptr + base + idx, mask=mask, other=0.0).to(tl.float32)\n sum_x += tl.sum(x, axis=0)\n sum_x2 += tl.sum(x * x, axis=0)\n mean = sum_x / group_size\n var = tl.maximum(sum_x2 / group_size - mean * mean, 0.0)\n rstd = tl.rsqrt(var + eps)\n for off in range(0, group_size, BLOCK_SIZE):\n idx = off + tl.arange(0, BLOCK_SIZE)\n mask = idx < group_size\n c = g * c_per_g + (idx // HW)\n x = tl.load(x_ptr + base + idx, mask=mask, other=0.0)\n w = tl.load(w_ptr + c, mask=mask, other=1.0).to(tl.float32)\n b = tl.load(b_ptr + c, mask=mask, other=0.0).to(tl.float32)\n tl.store(out_ptr + base + idx, ((x.to(tl.float32) - mean) * rstd * w + b).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, num_features: int, num_groups: int):\n super().__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n N, C, H, W = x.shape\n G = self.gn.num_groups\n out = torch.empty_like(x)\n groupnorm_kernel[(N * G,)](x, out, self.gn.weight, self.gn.bias, C, G, H * W, self.gn.eps, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.9351, "raw_speedup": 0.9351, "ref_ms": 0.383488, "cand_ms": 0.410112, "max_abs_diff": 9.5367431640625e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.383488, "mean_ms": 0.400671, "min_ms": 0.366592, "max_ms": 0.503808, "std_ms": 0.034322}, "cand_stats": {"median_ms": 0.410112, "mean_ms": 0.422707, "min_ms": 0.33792, "max_ms": 0.666624, "std_ms": 0.051327}}, "audited_timestamp": "2026-12-01T23:37:07.611433+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0245, "raw_speedup": 1.0245, "ref_ms": 0.386048, "cand_ms": 0.376832, "max_abs_diff": 9.5367431640625e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.386048, "mean_ms": 0.382464, "min_ms": 0.32256, "max_ms": 0.510976, "std_ms": 0.043141}, "cand_stats": {"median_ms": 0.376832, "mean_ms": 0.380908, "min_ms": 0.340992, "max_ms": 0.434176, "std_ms": 0.02222}}} +{"timestamp": "2026-12-01T19:42:41.963336+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_038_l1norm__shape_nonpow2", "source_kb_id": 38, "category": "normalization", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_038_l1norm__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_038_l1norm__shape_nonpow2 (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm__shape_nonpow2\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1536\ndim = 5120\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_038_l1norm__shape_nonpow2 (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm__shape_nonpow2\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1536\ndim = 5120\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused row-wise Triton L1 normalization: x / mean(|x|, dim=1, keepdim=True).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef l1_norm_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n sum_abs = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n sum_abs += tl.sum(tl.abs(x), axis=0)\n inv_mean = n_cols / sum_abs\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0)\n tl.store(out_ptr + row * stride_row + cols, (x.to(tl.float32) * inv_mean).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n n_rows, n_cols = x.shape\n out = torch.empty_like(x)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 4096)\n l1_norm_kernel[(n_rows,)](x, out, x.stride(0), n_cols, BLOCK_SIZE=BLOCK_SIZE)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.506, "raw_speedup": 1.506, "ref_ms": 1.025536, "cand_ms": 0.68096, "max_abs_diff": 1.430511474609375e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.025536, "mean_ms": 1.033646, "min_ms": 0.953344, "max_ms": 1.278976, "std_ms": 0.062733}, "cand_stats": {"median_ms": 0.68096, "mean_ms": 0.708301, "min_ms": 0.591872, "max_ms": 1.043456, "std_ms": 0.095189}}, "audited_timestamp": "2026-12-01T23:37:12.757582+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.5337, "raw_speedup": 1.5337, "ref_ms": 0.907776, "cand_ms": 0.591872, "max_abs_diff": 1.430511474609375e-06, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.907776, "mean_ms": 0.911483, "min_ms": 0.87552, "max_ms": 1.0752, "std_ms": 0.036753}, "cand_stats": {"median_ms": 0.591872, "mean_ms": 0.597115, "min_ms": 0.524288, "max_ms": 1.036288, "std_ms": 0.078077}}} +{"timestamp": "2026-12-01T19:42:46.521550+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_039_l2norm__shape_wide", "source_kb_id": 39, "category": "normalization", "dtype": "fp32", "variant": "shape_wide", "ref_path": "tasks/train/kb1_039_l2norm__shape_wide.py", "reference_code": "\"\"\"Task kb1_039_l2norm__shape_wide (KernelBench Level 1 #39, split=train, category=normalization, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm__shape_wide\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 8192\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_039_l2norm__shape_wide (KernelBench Level 1 #39, split=train, category=normalization, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm__shape_wide\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 8192\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused row-wise Triton L2 normalization: x / sqrt(sum(x^2, dim=1, keepdim=True)).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef l2_norm_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n sum_sq = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n sum_sq += tl.sum(x * x, axis=0)\n inv_norm = tl.rsqrt(sum_sq)\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0)\n tl.store(out_ptr + row * stride_row + cols, (x.to(tl.float32) * inv_norm).to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n n_rows, n_cols = x.shape\n out = torch.empty_like(x)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 4096)\n l2_norm_kernel[(n_rows,)](x, out, x.stride(0), n_cols, BLOCK_SIZE=BLOCK_SIZE)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.8992, "raw_speedup": 0.8992, "ref_ms": 0.653312, "cand_ms": 0.726528, "max_abs_diff": 1.1175870895385742e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.653312, "mean_ms": 0.677089, "min_ms": 0.607232, "max_ms": 0.859136, "std_ms": 0.055858}, "cand_stats": {"median_ms": 0.726528, "mean_ms": 0.745001, "min_ms": 0.622592, "max_ms": 1.281024, "std_ms": 0.100409}}, "audited_timestamp": "2026-12-01T23:37:17.744152+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.0878, "raw_speedup": 1.0878, "ref_ms": 0.615424, "cand_ms": 0.56576, "max_abs_diff": 1.1175870895385742e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.615424, "mean_ms": 0.617042, "min_ms": 0.559104, "max_ms": 1.134592, "std_ms": 0.087995}, "cand_stats": {"median_ms": 0.56576, "mean_ms": 0.609546, "min_ms": 0.557056, "max_ms": 1.024, "std_ms": 0.082279}}} +{"timestamp": "2026-12-01T19:42:51.688303+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_048_mean_reduction_over_a_dimension__shape_large_reduce", "source_kb_id": 48, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_large_reduce", "ref_path": "tasks/train/kb1_048_mean_reduction_over_a_dimension__shape_large_reduce.py", "reference_code": "\"\"\"Task kb1_048_mean_reduction_over_a_dimension__shape_large_reduce (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=fp32, variant=shape_large_reduce).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension__shape_large_reduce\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_reduce\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 64\ndim1 = 256\ndim2 = 1023\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_048_mean_reduction_over_a_dimension__shape_large_reduce (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=fp32, variant=shape_large_reduce).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension__shape_large_reduce\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_reduce\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 64\ndim1 = 256\ndim2 = 1023\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton mean reduction over arbitrary dim using strided outer/inner indexing.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef mean_reduce_kernel(x_ptr, out_ptr, reduce_size, inner_size, BLOCK_R: tl.constexpr):\n pid = tl.program_id(0)\n outer = pid // inner_size\n inner = pid % inner_size\n base = outer * reduce_size * inner_size + inner\n acc = 0.0\n for r_start in range(0, reduce_size, BLOCK_R):\n r = r_start + tl.arange(0, BLOCK_R)\n mask = r < reduce_size\n vals = tl.load(x_ptr + base + r * inner_size, mask=mask, other=0.0).to(tl.float32)\n acc += tl.sum(vals, axis=0)\n tl.store(out_ptr + pid, acc / reduce_size)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n dim = self.dim % x.ndim\n outer_size = 1\n for s in x.shape[:dim]:\n outer_size *= s\n reduce_size = x.shape[dim]\n inner_size = 1\n for s in x.shape[dim + 1:]:\n inner_size *= s\n out = torch.empty(x.shape[:dim] + x.shape[dim + 1:], device=x.device, dtype=x.dtype)\n BLOCK_R = min(triton.next_power_of_2(reduce_size), 1024)\n mean_reduce_kernel[(outer_size * inner_size,)](x, out, reduce_size, inner_size, BLOCK_R=BLOCK_R)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.3978, "raw_speedup": 0.3978, "ref_ms": 0.518144, "cand_ms": 1.302528, "max_abs_diff": 3.166496753692627e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.518144, "mean_ms": 0.509952, "min_ms": 0.427008, "max_ms": 0.569344, "std_ms": 0.033468}, "cand_stats": {"median_ms": 1.302528, "mean_ms": 1.328558, "min_ms": 1.09056, "max_ms": 2.096128, "std_ms": 0.188114}}, "audited_timestamp": "2026-12-01T23:37:23.207800+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.3486, "raw_speedup": 0.3486, "ref_ms": 0.376832, "cand_ms": 1.080832, "max_abs_diff": 3.166496753692627e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.376832, "mean_ms": 0.378511, "min_ms": 0.375808, "max_ms": 0.4352, "std_ms": 0.009027}, "cand_stats": {"median_ms": 1.080832, "mean_ms": 1.075732, "min_ms": 1.014784, "max_ms": 1.243136, "std_ms": 0.04524}}} +{"timestamp": "2026-12-01T19:42:57.562449+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_049_max_reduction_over_a_dimension__shape_large_reduce", "source_kb_id": 49, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_large_reduce", "ref_path": "tasks/train/kb1_049_max_reduction_over_a_dimension__shape_large_reduce.py", "reference_code": "\"\"\"Task kb1_049_max_reduction_over_a_dimension__shape_large_reduce (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp32, variant=shape_large_reduce).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension__shape_large_reduce\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_reduce\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 64\ndim1 = 256\ndim2 = 1023\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_049_max_reduction_over_a_dimension__shape_large_reduce (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp32, variant=shape_large_reduce).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension__shape_large_reduce\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_reduce\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 64\ndim1 = 256\ndim2 = 1023\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton max reduction over arbitrary dim using strided outer/inner indexing.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef max_reduce_kernel(x_ptr, out_ptr, reduce_size, inner_size, BLOCK_R: tl.constexpr):\n pid = tl.program_id(0)\n outer = pid // inner_size\n inner = pid % inner_size\n base = outer * reduce_size * inner_size + inner\n best = -float(\"inf\")\n for r_start in range(0, reduce_size, BLOCK_R):\n r = r_start + tl.arange(0, BLOCK_R)\n mask = r < reduce_size\n vals = tl.load(x_ptr + base + r * inner_size, mask=mask, other=-float(\"inf\")).to(tl.float32)\n best = tl.maximum(best, tl.max(vals, axis=0))\n tl.store(out_ptr + pid, best)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n dim = self.dim % x.ndim\n outer_size = 1\n for s in x.shape[:dim]:\n outer_size *= s\n reduce_size = x.shape[dim]\n inner_size = 1\n for s in x.shape[dim + 1:]:\n inner_size *= s\n out = torch.empty(x.shape[:dim] + x.shape[dim + 1:], device=x.device, dtype=x.dtype)\n BLOCK_R = min(triton.next_power_of_2(reduce_size), 1024)\n max_reduce_kernel[(outer_size * inner_size,)](x, out, reduce_size, inner_size, BLOCK_R=BLOCK_R)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.3591, "raw_speedup": 0.3591, "ref_ms": 0.464384, "cand_ms": 1.293312, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.464384, "mean_ms": 0.48468, "min_ms": 0.432128, "max_ms": 0.658432, "std_ms": 0.048908}, "cand_stats": {"median_ms": 1.293312, "mean_ms": 1.297367, "min_ms": 1.108992, "max_ms": 1.86368, "std_ms": 0.136187}}, "audited_timestamp": "2026-12-01T23:37:29.965442+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.3676, "raw_speedup": 0.3676, "ref_ms": 0.384, "cand_ms": 1.04448, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.384, "mean_ms": 0.390164, "min_ms": 0.382976, "max_ms": 0.475136, "std_ms": 0.019209}, "cand_stats": {"median_ms": 1.04448, "mean_ms": 1.109135, "min_ms": 1.040384, "max_ms": 2.028544, "std_ms": 0.158128}}} +{"timestamp": "2026-12-01T19:43:02.084371+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_053_min_reduction_over_a_dimension__shape_nonpow2", "source_kb_id": 53, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_053_min_reduction_over_a_dimension__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_053_min_reduction_over_a_dimension__shape_nonpow2 (KernelBench Level 1 #53, split=train, category=reduction_scan, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_053_min_reduction_over_a_dimension__shape_nonpow2\"\nSOURCE_KB_ID = 53\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs min reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies min reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after min reduction over the specified dimension.\n \"\"\"\n return torch.min(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 48\ndim1 = 384\ndim2 = 768\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_053_min_reduction_over_a_dimension__shape_nonpow2 (KernelBench Level 1 #53, split=train, category=reduction_scan, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_053_min_reduction_over_a_dimension__shape_nonpow2\"\nSOURCE_KB_ID = 53\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs min reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies min reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after min reduction over the specified dimension.\n \"\"\"\n return torch.min(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 48\ndim1 = 384\ndim2 = 768\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Triton min reduction over arbitrary dim using strided outer/inner indexing.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef min_reduce_kernel(x_ptr, out_ptr, reduce_size, inner_size, BLOCK_R: tl.constexpr):\n pid = tl.program_id(0)\n outer = pid // inner_size\n inner = pid % inner_size\n base = outer * reduce_size * inner_size + inner\n best = float(\"inf\")\n for r_start in range(0, reduce_size, BLOCK_R):\n r = r_start + tl.arange(0, BLOCK_R)\n mask = r < reduce_size\n vals = tl.load(x_ptr + base + r * inner_size, mask=mask, other=float(\"inf\")).to(tl.float32)\n best = tl.minimum(best, tl.min(vals, axis=0))\n tl.store(out_ptr + pid, best)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim: int):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n dim = self.dim % x.ndim\n outer_size = 1\n for s in x.shape[:dim]:\n outer_size *= s\n reduce_size = x.shape[dim]\n inner_size = 1\n for s in x.shape[dim + 1:]:\n inner_size *= s\n out = torch.empty(x.shape[:dim] + x.shape[dim + 1:], device=x.device, dtype=x.dtype)\n BLOCK_R = min(triton.next_power_of_2(reduce_size), 1024)\n min_reduce_kernel[(outer_size * inner_size,)](x, out, reduce_size, inner_size, BLOCK_R=BLOCK_R)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 0.4015, "raw_speedup": 0.4015, "ref_ms": 0.448512, "cand_ms": 1.117184, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.448512, "mean_ms": 0.459796, "min_ms": 0.374784, "max_ms": 0.833536, "std_ms": 0.08138}, "cand_stats": {"median_ms": 1.117184, "mean_ms": 1.177354, "min_ms": 0.96256, "max_ms": 2.2784, "std_ms": 0.21387}}, "audited_timestamp": "2026-12-01T23:37:35.062842+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 0.3395, "raw_speedup": 0.3395, "ref_ms": 0.32768, "cand_ms": 0.96512, "max_abs_diff": 0.0, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.32768, "mean_ms": 0.333988, "min_ms": 0.323584, "max_ms": 0.400384, "std_ms": 0.018248}, "cand_stats": {"median_ms": 0.96512, "mean_ms": 0.959447, "min_ms": 0.898048, "max_ms": 1.079296, "std_ms": 0.049414}}} +{"timestamp": "2026-12-01T19:43:06.329154+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_088_mingptnewgelu__shape_nonpow2", "source_kb_id": 88, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_088_mingptnewgelu__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_088_mingptnewgelu__shape_nonpow2 (KernelBench Level 1 #88, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu__shape_nonpow2\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1536\ndim = 5120\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_088_mingptnewgelu__shape_nonpow2 (KernelBench Level 1 #88, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu__shape_nonpow2\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1536\ndim = 5120\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fuse MinGPT NewGELU (0.5*x*(1 + tanh(sqrt(2/pi)*(x + 0.044715*x^3)))) into a single Triton pass.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef new_gelu_kernel(x_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n xf = x.to(tl.float32)\n inner = 0.7978845608028654 * (xf + 0.044715 * xf * xf * xf)\n tanh_val = 2.0 * tl.sigmoid(2.0 * inner) - 1.0\n y = 0.5 * xf * (1.0 + tanh_val)\n tl.store(out_ptr + offsets, y.to(x.dtype), mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n x = x.contiguous()\n out = torch.empty_like(x)\n n_elements = x.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n new_gelu_kernel[grid](x, out, n_elements, BLOCK_SIZE=1024)\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 6.4406, "raw_speedup": 6.4406, "ref_ms": 3.495424, "cand_ms": 0.54272, "max_abs_diff": 4.76837158203125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 3.495424, "mean_ms": 3.614495, "min_ms": 3.243008, "max_ms": 4.396032, "std_ms": 0.298469}, "cand_stats": {"median_ms": 0.54272, "mean_ms": 0.567255, "min_ms": 0.431104, "max_ms": 0.841728, "std_ms": 0.1014}}, "audited_timestamp": "2026-12-01T23:37:40.017877+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 8.9251, "raw_speedup": 8.9251, "ref_ms": 3.171328, "cand_ms": 0.355328, "max_abs_diff": 4.76837158203125e-07, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 3.171328, "mean_ms": 3.184947, "min_ms": 3.156992, "max_ms": 3.355648, "std_ms": 0.038011}, "cand_stats": {"median_ms": 0.355328, "mean_ms": 0.360899, "min_ms": 0.352256, "max_ms": 0.421888, "std_ms": 0.016359}}} +{"timestamp": "2026-12-01T19:43:10.420579+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_091_cumsum_reverse__shape_wide", "source_kb_id": 91, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_wide", "ref_path": "tasks/train/kb1_091_cumsum_reverse__shape_wide.py", "reference_code": "\"\"\"Task kb1_091_cumsum_reverse__shape_wide (KernelBench Level 1 #91, split=train, category=reduction_scan, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_091_cumsum_reverse__shape_wide\"\nSOURCE_KB_ID = 91\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a reverse cumulative sum operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the reverse cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n return torch.cumsum(x.flip(self.dim), dim=self.dim).flip(self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\nbatch_size = 1024\ninput_shape = (4096,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_091_cumsum_reverse__shape_wide (KernelBench Level 1 #91, split=train, category=reduction_scan, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_091_cumsum_reverse__shape_wide\"\nSOURCE_KB_ID = 91\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a reverse cumulative sum operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the reverse cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n return torch.cumsum(x.flip(self.dim), dim=self.dim).flip(self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\nbatch_size = 1024\ninput_shape = (4096,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Row-wise Triton reverse cumsum using tl.cumsum(..., reverse=True).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef cumsum_reverse_kernel(x_ptr, out_ptr, stride_row, n_cols, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n cols = tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n x = tl.load(x_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n y = tl.cumsum(x, axis=0, reverse=True)\n tl.store(out_ptr + row * stride_row + cols, y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self, dim):\n super().__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n dim = self.dim % x.ndim\n x_t = x.transpose(dim, -1).contiguous()\n orig_shape = x_t.shape\n x_2d = x_t.view(-1, orig_shape[-1])\n n_rows, n_cols = x_2d.shape\n out = torch.empty_like(x_2d)\n cumsum_reverse_kernel[(n_rows,)](x_2d, out, x_2d.stride(0), n_cols, BLOCK_SIZE=triton.next_power_of_2(n_cols))\n return out.view(orig_shape).transpose(dim, -1).contiguous()\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 2.4824, "raw_speedup": 2.4824, "ref_ms": 0.758784, "cand_ms": 0.305664, "max_abs_diff": 0.00244140625, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.758784, "mean_ms": 0.762532, "min_ms": 0.694272, "max_ms": 0.958464, "std_ms": 0.056415}, "cand_stats": {"median_ms": 0.305664, "mean_ms": 0.332431, "min_ms": 0.265216, "max_ms": 0.613376, "std_ms": 0.062904}}, "audited_timestamp": "2026-12-01T23:37:44.931226+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 3.3421, "raw_speedup": 3.3421, "ref_ms": 0.65024, "cand_ms": 0.19456, "max_abs_diff": 0.00244140625, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.65024, "mean_ms": 0.65577, "min_ms": 0.647168, "max_ms": 0.825344, "std_ms": 0.026976}, "cand_stats": {"median_ms": 0.19456, "mean_ms": 0.197673, "min_ms": 0.191488, "max_ms": 0.300032, "std_ms": 0.016407}}} +{"timestamp": "2026-12-01T19:43:14.715486+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_096_huberloss__shape_nonpow2", "source_kb_id": 96, "category": "loss_attention", "dtype": "fp32", "variant": "shape_nonpow2", "ref_path": "tasks/train/kb1_096_huberloss__shape_nonpow2.py", "reference_code": "\"\"\"Task kb1_096_huberloss__shape_nonpow2 (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss__shape_nonpow2\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\nbatch_size = 1500\ninput_shape = (3000,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_096_huberloss__shape_nonpow2 (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss__shape_nonpow2\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\nbatch_size = 1500\ninput_shape = (3000,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused Triton Smooth L1 (Huber, beta=1.0) loss with block reduction.", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef huber_partial_kernel(pred_ptr, tgt_ptr, partial_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n p = tl.load(pred_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n t = tl.load(tgt_ptr + offsets, mask=mask, other=0.0).to(tl.float32)\n diff = tl.abs(p - t)\n loss = tl.where(mask, tl.where(diff < 1.0, 0.5 * diff * diff, diff - 0.5), 0.0)\n tl.store(partial_ptr + pid, tl.sum(loss, axis=0))\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, predictions: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:\n p = predictions.contiguous()\n t = targets.contiguous()\n n_elements = p.numel()\n BLOCK_SIZE = 1024\n n_blocks = triton.cdiv(n_elements, BLOCK_SIZE)\n partial = torch.empty((n_blocks,), device=p.device, dtype=torch.float32)\n huber_partial_kernel[(n_blocks,)](p, t, partial, n_elements, BLOCK_SIZE=BLOCK_SIZE)\n return (partial.sum() / n_elements).to(p.dtype)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 1.2554, "raw_speedup": 1.2554, "ref_ms": 0.478208, "cand_ms": 0.380928, "max_abs_diff": 7.450580596923828e-09, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.478208, "mean_ms": 0.490476, "min_ms": 0.457728, "max_ms": 0.550912, "std_ms": 0.030696}, "cand_stats": {"median_ms": 0.380928, "mean_ms": 0.405012, "min_ms": 0.36864, "max_ms": 0.769024, "std_ms": 0.075216}}, "audited_timestamp": "2026-12-01T23:37:49.811822+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 1.6486, "raw_speedup": 1.6486, "ref_ms": 0.482816, "cand_ms": 0.292864, "max_abs_diff": 7.450580596923828e-09, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.482816, "mean_ms": 0.487281, "min_ms": 0.415744, "max_ms": 0.567296, "std_ms": 0.030231}, "cand_stats": {"median_ms": 0.292864, "mean_ms": 0.30636, "min_ms": 0.28672, "max_ms": 0.52736, "std_ms": 0.037424}}} +{"timestamp": "2026-12-01T19:43:18.864955+00:00", "run_id": "teacher_traces", "model": "teacher_triton_handcrafted", "problem": {"problem_id": "kb1_099_tripletmarginloss__shape_wide", "source_kb_id": 99, "category": "loss_attention", "dtype": "fp32", "variant": "shape_wide", "ref_path": "tasks/train/kb1_099_tripletmarginloss__shape_wide.py", "reference_code": "\"\"\"Task kb1_099_tripletmarginloss__shape_wide (KernelBench Level 1 #99, split=train, category=loss_attention, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_099_tripletmarginloss__shape_wide\"\nSOURCE_KB_ID = 99\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Triplet Margin Loss for metric learning tasks.\n\n Parameters:\n margin (float): The margin between the positive and negative samples.\n \"\"\"\n def __init__(self, margin=1.0):\n super(Model, self).__init__()\n self.loss_fn = torch.nn.TripletMarginLoss(margin=margin)\n\n def forward(self, anchor, positive, negative):\n return self.loss_fn(anchor, positive, negative)\n\nbatch_size = 32768\ninput_shape = (8192,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\nbatch_size = 1024\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape), torch.rand(batch_size, *input_shape)]\n \ndef get_init_inputs():\n return [1.0] # Default margin"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_099_tripletmarginloss__shape_wide (KernelBench Level 1 #99, split=train, category=loss_attention, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_099_tripletmarginloss__shape_wide\"\nSOURCE_KB_ID = 99\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Triplet Margin Loss for metric learning tasks.\n\n Parameters:\n margin (float): The margin between the positive and negative samples.\n \"\"\"\n def __init__(self, margin=1.0):\n super(Model, self).__init__()\n self.loss_fn = torch.nn.TripletMarginLoss(margin=margin)\n\n def forward(self, anchor, positive, negative):\n return self.loss_fn(anchor, positive, negative)\n\nbatch_size = 32768\ninput_shape = (8192,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\nbatch_size = 1024\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape), torch.rand(batch_size, *input_shape)]\n \ndef get_init_inputs():\n return [1.0] # Default margin\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "reasoning": "Fused row-wise Triton TripletMarginLoss matching Model.__init__(margin=1.0).", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef triplet_margin_kernel(a_ptr, p_ptr, n_ptr, out_ptr, stride_row, n_cols, margin, BLOCK_SIZE: tl.constexpr):\n row = tl.program_id(0)\n sum_ap = 0.0\n sum_an = 0.0\n for col_start in range(0, n_cols, BLOCK_SIZE):\n cols = col_start + tl.arange(0, BLOCK_SIZE)\n mask = cols < n_cols\n a = tl.load(a_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n p = tl.load(p_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n n = tl.load(n_ptr + row * stride_row + cols, mask=mask, other=0.0).to(tl.float32)\n dap = a - p + 1e-6\n dan = a - n + 1e-6\n sum_ap += tl.sum(tl.where(mask, dap * dap, 0.0), axis=0)\n sum_an += tl.sum(tl.where(mask, dan * dan, 0.0), axis=0)\n tl.store(out_ptr + row, tl.maximum(tl.sqrt(sum_ap) - tl.sqrt(sum_an) + margin, 0.0))\n\nclass ModelNew(nn.Module):\n def __init__(self, margin=1.0):\n super().__init__()\n self.margin = float(margin)\n\n def forward(self, anchor: torch.Tensor, positive: torch.Tensor, negative: torch.Tensor) -> torch.Tensor:\n a = anchor.contiguous()\n p = positive.contiguous()\n n = negative.contiguous()\n n_rows, n_cols = a.shape\n per_row = torch.empty((n_rows,), device=a.device, dtype=torch.float32)\n BLOCK_SIZE = min(triton.next_power_of_2(n_cols), 2048)\n triplet_margin_kernel[(n_rows,)](a, p, n, per_row, a.stride(0), n_cols, self.margin, BLOCK_SIZE=BLOCK_SIZE)\n return per_row.mean().to(a.dtype)\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 5, "speedup": 3.3507, "raw_speedup": 3.3507, "ref_ms": 1.379328, "cand_ms": 0.411648, "max_abs_diff": 5.960464477539063e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.379328, "mean_ms": 1.406239, "min_ms": 1.3056, "max_ms": 1.559552, "std_ms": 0.074248}, "cand_stats": {"median_ms": 0.411648, "mean_ms": 0.415437, "min_ms": 0.329728, "max_ms": 0.553984, "std_ms": 0.038115}}, "audited_timestamp": "2026-12-01T23:37:54.815821+00:00", "verifier_result_v1": {"status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "speedup": 4.0986, "raw_speedup": 4.0986, "ref_ms": 1.170944, "cand_ms": 0.285696, "max_abs_diff": 5.960464477539063e-08, "trials_passed": 5, "trials_total": 5, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.170944, "mean_ms": 1.186918, "min_ms": 1.164288, "max_ms": 1.301504, "std_ms": 0.032427}, "cand_stats": {"median_ms": 0.285696, "mean_ms": 0.289567, "min_ms": 0.284672, "max_ms": 0.330752, "std_ms": 0.010808}}} +{"timestamp": "2026-12-02T14:33:06.477646+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_050_conv_standard_2d_square_input_square_kernel", "source_kb_id": 50, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_050_conv_standard_2d_square_input_square_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_050_conv_standard_2d_square_input_square_kernel (KernelBench Level 1 #50, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_050_conv_standard_2d_square_input_square_kernel\"\nSOURCE_KB_ID = 50\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n def __init__(self, num_classes=1000):\n super(Model, self).__init__()\n self.conv1 = nn.Conv2d(in_channels=3, out_channels=96, kernel_size=11, stride=4, padding=2)\n \n def forward(self, x):\n x = self.conv1(x)\n return x\n\n# Test code\nbatch_size = 256\nnum_classes = 1000\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\n\ndef get_inputs():\n return [torch.rand(batch_size, 3, 224, 224)]\n\ndef get_init_inputs():\n return [num_classes]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (co * C_in_g + ci_l) * KH * KW\n for kh in tl.static_range(KH):\n hi = ho * SH - PH + kh * DH\n for kw in tl.static_range(KW):\n wi = wo * SW - PW + kw * DW\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, num_classes=1000):\n super(ModelNew, self).__init__()\n self.conv1 = nn.Conv2d(in_channels=3, out_channels=96, kernel_size=11, stride=4, padding=2)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv1\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n C_out, C_in_g, KH, KW = w_c.shape\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n groups = conv.groups\n C_out_g = C_out // groups\n H_out = (H_in + 2 * PH - DH * (KH - 1) - 1) // SH + 1\n W_out = (W_in + 2 * PW - DW * (KW - 1) - 1) // SW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.116, "raw_speedup": 0.116, "ref_ms": 2.372608, "cand_ms": 20.44928, "max_abs_diff": 8.344650268554688e-07, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.372608, "mean_ms": 2.445517, "min_ms": 2.241536, "max_ms": 2.88256, "std_ms": 0.168318}, "cand_stats": {"median_ms": 20.44928, "mean_ms": 20.51625, "min_ms": 20.230145, "max_ms": 21.37088, "std_ms": 0.273656}}} +{"timestamp": "2026-12-02T14:33:14.400428+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_054_conv_standard_3d_square_input_square_kernel", "source_kb_id": 54, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_054_conv_standard_3d_square_input_square_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_054_conv_standard_3d_square_input_square_kernel (KernelBench Level 1 #54, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_054_conv_standard_3d_square_input_square_kernel\"\nSOURCE_KB_ID = 54\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with square input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, (kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, width, height).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, width_out, height_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 3\nout_channels = 64\nkernel_size = 3\ndepth = 64\nwidth = 64\nheight = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\ndepth = 32\nwidth = 32\nheight = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, width, height)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (co * C_in_g + ci_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n di = do * SD - PD + kd * DD\n for kh in tl.static_range(KH):\n hi = ho * SH - PH + kh * DH\n for kw in tl.static_range(KW):\n wi = wo * SW - PW + kw * DW\n m = out_mask & (di >= 0) & (di < D_in) & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, (kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n C_out, C_in_g, KD, KH, KW = w_c.shape\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n groups = conv.groups\n C_out_g = C_out // groups\n D_out = (D_in + 2 * PD - DD * (KD - 1) - 1) // SD + 1\n H_out = (H_in + 2 * PH - DH * (KH - 1) - 1) // SH + 1\n W_out = (W_in + 2 * PW - DW * (KW - 1) - 1) // SW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.5539, "raw_speedup": 0.5539, "ref_ms": 1.576448, "cand_ms": 2.846208, "max_abs_diff": 0.0004966259002685547, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.576448, "mean_ms": 1.69769, "min_ms": 1.4592, "max_ms": 2.323456, "std_ms": 0.263486}, "cand_stats": {"median_ms": 2.846208, "mean_ms": 2.864435, "min_ms": 2.736128, "max_ms": 3.100672, "std_ms": 0.110968}}} +{"timestamp": "2026-12-02T14:33:20.640201+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel", "source_kb_id": 56, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #56, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 56\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with asymmetric input and kernel sizes.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Tuple of two integers representing the height and width of the convolution kernel.\n stride (tuple, optional): Tuple of two integers representing the stride in the height and width dimensions. Defaults to (1, 1).\n padding (tuple, optional): Tuple of two integers representing the padding in the height and width dimensions. Defaults to (0, 0).\n dilation (tuple, optional): Tuple of two integers representing the dilation in the height and width dimensions. Defaults to (1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nkernel_size = (5, 7)\nheight = 512\nwidth = 256\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nheight = 128\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (co * C_in_g + ci_l) * KH * KW\n for kh in tl.static_range(KH):\n hi = ho * SH - PH + kh * DH\n for kw in tl.static_range(KW):\n wi = wo * SW - PW + kw * DW\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n C_out, C_in_g, KH, KW = w_c.shape\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n groups = conv.groups\n C_out_g = C_out // groups\n H_out = (H_in + 2 * PH - DH * (KH - 1) - 1) // SH + 1\n W_out = (W_in + 2 * PW - DW * (KW - 1) - 1) // SW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.0825, "raw_speedup": 0.0825, "ref_ms": 0.77056, "cand_ms": 9.344, "max_abs_diff": 0.0004590582102537155, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.77056, "mean_ms": 0.808704, "min_ms": 0.715776, "max_ms": 1.132544, "std_ms": 0.114722}, "cand_stats": {"median_ms": 9.344, "mean_ms": 8.861389, "min_ms": 7.29088, "max_ms": 9.6256, "std_ms": 0.91159}}} +{"timestamp": "2026-12-02T14:33:31.097195+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_057_conv_transposed_2d_square_input_square_kernel", "source_kb_id": 57, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_057_conv_transposed_2d_square_input_square_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_057_conv_transposed_2d_square_input_square_kernel (KernelBench Level 1 #57, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_057_conv_transposed_2d_square_input_square_kernel\"\nSOURCE_KB_ID = 57\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution with square input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 64 # double channels for heavier compute\nout_channels = 64\nkernel_size = 3\n# larger square input\nheight = 1024\nwidth = 1024\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nheight = 256\nwidth = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KH * KW\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = out_mask & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n _, C_out_g, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n OPH, OPW = conv.output_padding\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv_transpose2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.1502, "raw_speedup": 0.1502, "ref_ms": 1.385472, "cand_ms": 9.221632, "max_abs_diff": 1.1324882507324219e-06, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.385472, "mean_ms": 1.41184, "min_ms": 1.31072, "max_ms": 1.783808, "std_ms": 0.111042}, "cand_stats": {"median_ms": 9.221632, "mean_ms": 9.828301, "min_ms": 8.75008, "max_ms": 11.71456, "std_ms": 1.068919}}} +{"timestamp": "2026-12-02T14:33:40.100817+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel", "source_kb_id": 58, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #58, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 58\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution operation with asymmetric input and kernel sizes.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Tuple of 3 integers representing the kernel size in the form (depth, height, width).\n stride (tuple, optional): Tuple of 3 integers representing the stride in the form (depth, height, width). Defaults to (1, 1, 1).\n padding (tuple, optional): Tuple of 3 integers representing the padding in the form (depth, height, width). Defaults to (0, 0, 0).\n output_padding (tuple, optional): Tuple of 3 integers representing the output padding in the form (depth, height, width). Defaults to (0, 0, 0).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth_in, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 16\nkernel_size = (3, 5, 7) # Asymmetric kernel size\ndepth_in = 16\nheight_in = 32\nwidth_in = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 16\nout_channels = 16\ndepth_in = 8\nheight_in = 16\nwidth_in = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth_in, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n nd = do + PD - kd * DD\n vd = out_mask & (nd >= 0) & ((nd % SD) == 0)\n di = nd // SD\n vd = vd & (di < D_in)\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = vd & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n _, C_out_g, KD, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n OPD, OPH, OPW = conv.output_padding\n D_out = (D_in - 1) * SD - 2 * PD + DD * (KD - 1) + OPD + 1\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv_transpose3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.1951, "raw_speedup": 0.1951, "ref_ms": 1.84576, "cand_ms": 9.461248, "max_abs_diff": 0.0004212399944663048, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.84576, "mean_ms": 1.853389, "min_ms": 1.762304, "max_ms": 2.035712, "std_ms": 0.073809}, "cand_stats": {"median_ms": 9.461248, "mean_ms": 8.012493, "min_ms": 4.146176, "max_ms": 9.951232, "std_ms": 2.448187}}} +{"timestamp": "2026-12-02T14:33:46.660252+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_059_conv_standard_3d_asymmetric_input_square_kernel", "source_kb_id": 59, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_059_conv_standard_3d_asymmetric_input_square_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_059_conv_standard_3d_asymmetric_input_square_kernel (KernelBench Level 1 #59, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_059_conv_standard_3d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 59\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel (kernel_size x kernel_size).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, (kernel_size, kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width, depth).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out, depth_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 3\nout_channels = 64\nkernel_size = 3\nwidth = 256\nheight = 256\ndepth = 10\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nwidth = 64\nheight = 64\ndepth = 8\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width, depth)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (co * C_in_g + ci_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n di = do * SD - PD + kd * DD\n for kh in tl.static_range(KH):\n hi = ho * SH - PH + kh * DH\n for kw in tl.static_range(KW):\n wi = wo * SW - PW + kw * DW\n m = out_mask & (di >= 0) & (di < D_in) & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, (kernel_size, kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n C_out, C_in_g, KD, KH, KW = w_c.shape\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n groups = conv.groups\n C_out_g = C_out // groups\n D_out = (D_in + 2 * PD - DD * (KD - 1) - 1) // SD + 1\n H_out = (H_in + 2 * PH - DH * (KH - 1) - 1) // SH + 1\n W_out = (W_in + 2 * PW - DW * (KW - 1) - 1) // SW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 1.4924, "raw_speedup": 1.4924, "ref_ms": 2.021888, "cand_ms": 1.354752, "max_abs_diff": 0.0004996880888938904, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 2.021888, "mean_ms": 2.014106, "min_ms": 1.937408, "max_ms": 2.05312, "std_ms": 0.032973}, "cand_stats": {"median_ms": 1.354752, "mean_ms": 1.361306, "min_ms": 1.25952, "max_ms": 1.5104, "std_ms": 0.066629}}} +{"timestamp": "2026-12-02T14:33:56.089228+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_060_conv_standard_3d_square_input_asymmetric_kernel", "source_kb_id": 60, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_060_conv_standard_3d_square_input_asymmetric_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_060_conv_standard_3d_square_input_asymmetric_kernel (KernelBench Level 1 #60, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_060_conv_standard_3d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 60\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (kernel_width, kernel_height, kernel_depth).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, width, height, depth).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, width_out, height_out, depth_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 3\nout_channels = 64\nkernel_size = (3, 5, 7) # Asymmetric kernel\nwidth = 64\nheight = 64\ndepth = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nwidth = 32\nheight = 32\ndepth = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, width, height, depth)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (co * C_in_g + ci_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n di = do * SD - PD + kd * DD\n for kh in tl.static_range(KH):\n hi = ho * SH - PH + kh * DH\n for kw in tl.static_range(KW):\n wi = wo * SW - PW + kw * DW\n m = out_mask & (di >= 0) & (di < D_in) & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n C_out, C_in_g, KD, KH, KW = w_c.shape\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n groups = conv.groups\n C_out_g = C_out // groups\n D_out = (D_in + 2 * PD - DD * (KD - 1) - 1) // SD + 1\n H_out = (H_in + 2 * PH - DH * (KH - 1) - 1) // SH + 1\n W_out = (W_in + 2 * PW - DW * (KW - 1) - 1) // SW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.4523, "raw_speedup": 0.4523, "ref_ms": 4.611072, "cand_ms": 10.194432, "max_abs_diff": 0.00048495829105377197, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 4.611072, "mean_ms": 4.786381, "min_ms": 4.447232, "max_ms": 6.07744, "std_ms": 0.446348}, "cand_stats": {"median_ms": 10.194432, "mean_ms": 9.510195, "min_ms": 7.8336, "max_ms": 11.264, "std_ms": 1.161083}}} +{"timestamp": "2026-12-02T14:34:05.796987+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_061_conv_transposed_3d_square_input_square_kernel", "source_kb_id": 61, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_061_conv_transposed_3d_square_input_square_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_061_conv_transposed_3d_square_input_square_kernel (KernelBench Level 1 #61, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_061_conv_transposed_3d_square_input_square_kernel\"\nSOURCE_KB_ID = 61\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution with square input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 48\nout_channels = 48\nkernel_size = 3\ndepth = 64\nheight = 64\nwidth = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 16\nheight = 16\nwidth = 16\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n nd = do + PD - kd * DD\n vd = out_mask & (nd >= 0) & ((nd % SD) == 0)\n di = nd // SD\n vd = vd & (di < D_in)\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = vd & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n _, C_out_g, KD, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n OPD, OPH, OPW = conv.output_padding\n D_out = (D_in - 1) * SD - 2 * PD + DD * (KD - 1) + OPD + 1\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv_transpose3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.6941, "raw_speedup": 0.6941, "ref_ms": 0.328704, "cand_ms": 0.4736, "max_abs_diff": 0.0004893243312835693, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.328704, "mean_ms": 0.336026, "min_ms": 0.290816, "max_ms": 0.443392, "std_ms": 0.039707}, "cand_stats": {"median_ms": 0.4736, "mean_ms": 0.470221, "min_ms": 0.422912, "max_ms": 0.550912, "std_ms": 0.025551}}} +{"timestamp": "2026-12-02T14:34:12.378061+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_062_conv_standard_2d_square_input_asymmetric_kernel", "source_kb_id": 62, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_062_conv_standard_2d_square_input_asymmetric_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_062_conv_standard_2d_square_input_asymmetric_kernel (KernelBench Level 1 #62, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_062_conv_standard_2d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 62\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 64\nkernel_size = (5, 9)\nwidth = 512\nheight = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (co * C_in_g + ci_l) * KH * KW\n for kh in tl.static_range(KH):\n hi = ho * SH - PH + kh * DH\n for kw in tl.static_range(KW):\n wi = wo * SW - PW + kw * DW\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n C_out, C_in_g, KH, KW = w_c.shape\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n groups = conv.groups\n C_out_g = C_out // groups\n H_out = (H_in + 2 * PH - DH * (KH - 1) - 1) // SH + 1\n W_out = (W_in + 2 * PW - DW * (KW - 1) - 1) // SW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.0855, "raw_speedup": 0.0855, "ref_ms": 1.634304, "cand_ms": 19.121664, "max_abs_diff": 0.0004825890064239502, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.634304, "mean_ms": 1.643162, "min_ms": 1.62304, "max_ms": 1.696768, "std_ms": 0.02005}, "cand_stats": {"median_ms": 19.121664, "mean_ms": 19.134976, "min_ms": 18.958336, "max_ms": 19.539968, "std_ms": 0.147049}}} +{"timestamp": "2026-12-02T14:34:19.375261+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_064_conv_transposed_1d", "source_kb_id": 64, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_064_conv_transposed_1d.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_064_conv_transposed_1d (KernelBench Level 1 #64, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_064_conv_transposed_1d\"\nSOURCE_KB_ID = 64\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 64\nin_channels = 128\nout_channels = 128\nkernel_size = 3\n# much larger signal length for heavier workload\nlength = 65536\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\nout_channels = 64\nlength = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose1d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, L_in, C_out, L_out,\n C_in_g, C_out_g,\n K: tl.constexpr, S, P, D,\n BLOCK_L: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n lo = tl.program_id(1) * BLOCK_L + tl.arange(0, BLOCK_L)\n out_mask = lo < L_out\n acc = tl.zeros((BLOCK_L,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * L_in\n w_base = (ci * C_out_g + co_l) * K\n for k in tl.static_range(K):\n num = lo + P - k * D\n valid = out_mask & (num >= 0) & ((num % S) == 0)\n li = num // S\n m = valid & (li < L_in)\n xv = tl.load(x_ptr + x_base + li, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + k).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * L_out + lo, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv1d_transpose\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, L_in = x_c.shape\n _, C_out_g, K = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n (S,) = conv.stride\n (P,) = conv.padding\n (D,) = conv.dilation\n (OP,) = conv.output_padding\n L_out = (L_in - 1) * S - 2 * P + D * (K - 1) + OP + 1\n out = torch.empty((N, C_out, L_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_L = 256\n grid = (N * C_out, triton.cdiv(L_out, BLOCK_L))\n conv_transpose1d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, L_in, C_out, L_out,\n C_in_g, C_out_g,\n K, S, P, D,\n BLOCK_L=BLOCK_L,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.2061, "raw_speedup": 0.2061, "ref_ms": 0.987648, "cand_ms": 4.79232, "max_abs_diff": 0.0, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.987648, "mean_ms": 1.002394, "min_ms": 0.91648, "max_ms": 1.148928, "std_ms": 0.059025}, "cand_stats": {"median_ms": 4.79232, "mean_ms": 4.962509, "min_ms": 4.596736, "max_ms": 5.866496, "std_ms": 0.371125}}} +{"timestamp": "2026-12-02T14:34:26.776259+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_065_conv_transposed_2d_square_input_asymmetric_kernel", "source_kb_id": 65, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_065_conv_transposed_2d_square_input_asymmetric_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_065_conv_transposed_2d_square_input_asymmetric_kernel (KernelBench Level 1 #65, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_065_conv_transposed_2d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 65\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n output_padding (int or tuple, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 64\nout_channels = 64\nkernel_size = (3, 7) # larger asymmetric kernel\nwidth = 512\nheight = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KH * KW\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = out_mask & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n _, C_out_g, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n OPH, OPW = conv.output_padding\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv_transpose2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.1582, "raw_speedup": 0.1582, "ref_ms": 1.101312, "cand_ms": 6.962688, "max_abs_diff": 0.00046694278717041016, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.101312, "mean_ms": 1.104282, "min_ms": 0.984064, "max_ms": 1.260544, "std_ms": 0.066961}, "cand_stats": {"median_ms": 6.962688, "mean_ms": 7.088742, "min_ms": 6.75328, "max_ms": 8.041472, "std_ms": 0.331646}}} +{"timestamp": "2026-12-02T14:34:38.815511+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel", "source_kb_id": 66, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #66, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 66\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with asymmetric input and kernel sizes.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel in the form (kernel_size_d, kernel_size_h, kernel_size_w).\n stride (tuple, optional): Stride of the convolution in the form (stride_d, stride_h, stride_w). Defaults to (1, 1, 1).\n padding (tuple, optional): Padding applied to the input in the form (padding_d, padding_h, padding_w). Defaults to (0, 0, 0).\n dilation (tuple, optional): Spacing between kernel elements in the form (dilation_d, dilation_h, dilation_w). Defaults to (1, 1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), dilation: tuple = (1, 1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 3\nout_channels = 64\nkernel_size = (3, 5, 7) # Asymmetric kernel size\ndepth = 16\nheight = 128\nwidth = 128\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\ndepth = 8\nheight = 64\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (co * C_in_g + ci_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n di = do * SD - PD + kd * DD\n for kh in tl.static_range(KH):\n hi = ho * SH - PH + kh * DH\n for kw in tl.static_range(KW):\n wi = wo * SW - PW + kw * DW\n m = out_mask & (di >= 0) & (di < D_in) & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), dilation: tuple = (1, 1, 1), groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n C_out, C_in_g, KD, KH, KW = w_c.shape\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n groups = conv.groups\n C_out_g = C_out // groups\n D_out = (D_in + 2 * PD - DD * (KD - 1) - 1) // SD + 1\n H_out = (H_in + 2 * PH - DH * (KH - 1) - 1) // SH + 1\n W_out = (W_in + 2 * PW - DW * (KW - 1) - 1) // SW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.4658, "raw_speedup": 0.4658, "ref_ms": 4.530176, "cand_ms": 9.724928, "max_abs_diff": 0.0004901960492134094, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 4.530176, "mean_ms": 4.654131, "min_ms": 4.240384, "max_ms": 5.48352, "std_ms": 0.339107}, "cand_stats": {"median_ms": 9.724928, "mean_ms": 9.320909, "min_ms": 7.778304, "max_ms": 10.03008, "std_ms": 0.810251}}} +{"timestamp": "2026-12-02T14:34:46.319814+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_068_conv_transposed_3d_square_input_asymmetric_kernel", "source_kb_id": 68, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_068_conv_transposed_3d_square_input_asymmetric_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_068_conv_transposed_3d_square_input_asymmetric_kernel (KernelBench Level 1 #68, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_068_conv_transposed_3d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 68\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (kernel_depth, kernel_width, kernel_height), \n where kernel_width == kernel_height.\n stride (tuple, optional): Stride of the convolution. Defaults to (1, 1, 1).\n padding (tuple, optional): Padding applied to the input. Defaults to (0, 0, 0).\n output_padding (tuple, optional): Additional size added to one side of the output shape. Defaults to (0, 0, 0).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, width, height).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, width_out, height_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_depth = 3\nkernel_width = 5\nkernel_height = 5\ndepth = 64\nwidth = 64\nheight = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 16\nout_channels = 32\ndepth = 16\nwidth = 16\nheight = 16\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, width, height)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, (kernel_depth, kernel_width, kernel_height)] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n nd = do + PD - kd * DD\n vd = out_mask & (nd >= 0) & ((nd % SD) == 0)\n di = nd // SD\n vd = vd & (di < D_in)\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = vd & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n _, C_out_g, KD, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n OPD, OPH, OPW = conv.output_padding\n D_out = (D_in - 1) * SD - 2 * PD + DD * (KD - 1) + OPD + 1\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv_transpose3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.2036, "raw_speedup": 0.2036, "ref_ms": 1.088, "cand_ms": 5.34272, "max_abs_diff": 0.0003692135214805603, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.088, "mean_ms": 1.088307, "min_ms": 1.04448, "max_ms": 1.120256, "std_ms": 0.021113}, "cand_stats": {"median_ms": 5.34272, "mean_ms": 4.919091, "min_ms": 4.145152, "max_ms": 5.41184, "std_ms": 0.580481}}} +{"timestamp": "2026-12-02T14:34:53.503225+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel", "source_kb_id": 69, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #69, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 69\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution operation with asymmetric input and kernel size.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Tuple of integers representing the kernel size (height, width).\n stride (tuple, optional): Tuple of integers representing the stride of the convolution. Defaults to (1, 1).\n padding (tuple, optional): Tuple of integers representing the padding applied to the input. Defaults to (0, 0).\n output_padding (tuple, optional): Tuple of integers representing the additional size added to one side of the output shape. Defaults to (0, 0).\n dilation (tuple, optional): Tuple of integers representing the spacing between kernel elements. Defaults to (1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), output_padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 64\nout_channels = 128\nkernel_size = (3, 5)\nheight_in = 128\nwidth_in = 256\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 32\nout_channels = 64\nheight_in = 64\nwidth_in = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KH * KW\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = out_mask & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), output_padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, dilation=dilation, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n _, C_out_g, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n OPH, OPW = conv.output_padding\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv_transpose2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.1014, "raw_speedup": 0.1014, "ref_ms": 0.97024, "cand_ms": 9.570304, "max_abs_diff": 0.00034043192863464355, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.97024, "mean_ms": 1.018573, "min_ms": 0.932864, "max_ms": 1.723392, "std_ms": 0.172414}, "cand_stats": {"median_ms": 9.570304, "mean_ms": 9.118208, "min_ms": 7.564288, "max_ms": 10.426368, "std_ms": 0.930348}}} +{"timestamp": "2026-12-02T14:35:00.444495+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_070_conv_transposed_3d_asymmetric_input_square_kernel", "source_kb_id": 70, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_070_conv_transposed_3d_asymmetric_input_square_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_070_conv_transposed_3d_asymmetric_input_square_kernel (KernelBench Level 1 #70, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_070_conv_transposed_3d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 70\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution operation with asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int or tuple, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n output_padding (int or tuple, optional): Additional size added to one side of each dimension in the output shape. \n Defaults to 0.\n dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, \n dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, (kernel_size, kernel_size, kernel_size), \n stride=stride, padding=padding, output_padding=output_padding, \n dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 48\nout_channels = 24\nkernel_size = 3\ndepth = 96\nheight = 96\nwidth = 96\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 24\nheight = 24\nwidth = 24\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n nd = do + PD - kd * DD\n vd = out_mask & (nd >= 0) & ((nd % SD) == 0)\n di = nd // SD\n vd = vd & (di < D_in)\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = vd & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, \n dilation: int = 1, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, (kernel_size, kernel_size, kernel_size), \n stride=stride, padding=padding, output_padding=output_padding, \n dilation=dilation, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n _, C_out_g, KD, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n OPD, OPH, OPW = conv.output_padding\n D_out = (D_in - 1) * SD - 2 * PD + DD * (KD - 1) + OPD + 1\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv_transpose3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.6504, "raw_speedup": 0.6504, "ref_ms": 0.765952, "cand_ms": 1.1776, "max_abs_diff": 0.0005140900611877441, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.765952, "mean_ms": 0.801331, "min_ms": 0.740352, "max_ms": 1.235968, "std_ms": 0.1106}, "cand_stats": {"median_ms": 1.1776, "mean_ms": 1.20919, "min_ms": 1.13664, "max_ms": 1.511424, "std_ms": 0.090748}}} +{"timestamp": "2026-12-02T14:35:07.790355+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_071_conv_transposed_2d_asymmetric_input_square_kernel", "source_kb_id": 71, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_071_conv_transposed_2d_asymmetric_input_square_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_071_conv_transposed_2d_asymmetric_input_square_kernel (KernelBench Level 1 #71, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_071_conv_transposed_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 71\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution with asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 32\nkernel_size = 3\n# large asymmetric input\nheight_in = 512\nwidth_in = 1024\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nheight_in = 128\nwidth_in = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KH * KW\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = out_mask & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n _, C_out_g, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n OPH, OPW = conv.output_padding\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv_transpose2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.1333, "raw_speedup": 0.1333, "ref_ms": 0.741888, "cand_ms": 5.56544, "max_abs_diff": 1.0728836059570312e-06, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.741888, "mean_ms": 0.762419, "min_ms": 0.677888, "max_ms": 1.061888, "std_ms": 0.09123}, "cand_stats": {"median_ms": 5.56544, "mean_ms": 5.562522, "min_ms": 5.389312, "max_ms": 5.756928, "std_ms": 0.118428}}} +{"timestamp": "2026-12-02T14:35:18.176797+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped", "source_kb_id": 72, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped (KernelBench Level 1 #72, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped\"\nSOURCE_KB_ID = 72\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 3D transposed convolution operation with asymmetric input and kernel, and optional stride.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple of ints): Size of the convolution kernel in the form (kernel_size_depth, kernel_size_height, kernel_size_width).\n stride (tuple of ints, optional): Stride of the convolution in the form (stride_depth, stride_height, stride_width). Defaults to (1, 1, 1).\n padding (tuple of ints, optional): Padding applied to the input in the form (padding_depth, padding_height, padding_width). Defaults to (0, 0, 0).\n output_padding (tuple of ints, optional): Additional size added to one side of the output shape. Defaults to (0, 0, 0).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 32\nkernel_size = (3, 5, 7)\ndepth = 12\nheight = 24\nwidth = 48\nstride = (2, 2, 2)\npadding = (1, 2, 3)\noutput_padding = (1, 1, 1)\ngroups = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 8\nheight = 12\nwidth = 24\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, output_padding, groups]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n nd = do + PD - kd * DD\n vd = out_mask & (nd >= 0) & ((nd % SD) == 0)\n di = nd // SD\n vd = vd & (di < D_in)\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = vd & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n _, C_out_g, KD, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n OPD, OPH, OPW = conv.output_padding\n D_out = (D_in - 1) * SD - 2 * PD + DD * (KD - 1) + OPD + 1\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv_transpose3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.4167, "raw_speedup": 0.4167, "ref_ms": 0.58368, "cand_ms": 1.400832, "max_abs_diff": 2.980232238769531e-07, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.58368, "mean_ms": 0.5888, "min_ms": 0.55808, "max_ms": 0.661504, "std_ms": 0.02431}, "cand_stats": {"median_ms": 1.400832, "mean_ms": 1.403853, "min_ms": 1.26976, "max_ms": 1.616896, "std_ms": 0.099432}}} +{"timestamp": "2026-12-02T14:35:24.300054+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped", "source_kb_id": 73, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped (KernelBench Level 1 #73, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped\"\nSOURCE_KB_ID = 73\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 3D transposed convolution operation with asymmetric input and square kernel.\n The input is padded before the convolution.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nkernel_size = 3\ndepth = 32\nheight = 64\nwidth = 128\nstride = 2\npadding = 1\ngroups = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 12\nheight = 24\nwidth = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, groups]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n nd = do + PD - kd * DD\n vd = out_mask & (nd >= 0) & ((nd % SD) == 0)\n di = nd // SD\n vd = vd & (di < D_in)\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = vd & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n _, C_out_g, KD, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n OPD, OPH, OPW = conv.output_padding\n D_out = (D_in - 1) * SD - 2 * PD + DD * (KD - 1) + OPD + 1\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv_transpose3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.172, "raw_speedup": 0.172, "ref_ms": 0.813568, "cand_ms": 4.728832, "max_abs_diff": 5.364418029785156e-07, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.813568, "mean_ms": 0.81065, "min_ms": 0.751616, "max_ms": 0.857088, "std_ms": 0.03395}, "cand_stats": {"median_ms": 4.728832, "mean_ms": 4.448819, "min_ms": 3.825664, "max_ms": 4.980736, "std_ms": 0.438169}}} +{"timestamp": "2026-12-02T14:35:31.532291+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_074_conv_transposed_1d_dilated", "source_kb_id": 74, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_074_conv_transposed_1d_dilated.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_074_conv_transposed_1d_dilated (KernelBench Level 1 #74, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_074_conv_transposed_1d_dilated\"\nSOURCE_KB_ID = 74\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation with square input and asymmetric kernel, optionally with dilation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 32\nin_channels = 32\nout_channels = 64\nkernel_size = 5\nlength = 131072\nstride = 1\npadding = 0\ndilation = 3\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nlength = 16384\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose1d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, L_in, C_out, L_out,\n C_in_g, C_out_g,\n K: tl.constexpr, S, P, D,\n BLOCK_L: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n lo = tl.program_id(1) * BLOCK_L + tl.arange(0, BLOCK_L)\n out_mask = lo < L_out\n acc = tl.zeros((BLOCK_L,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * L_in\n w_base = (ci * C_out_g + co_l) * K\n for k in tl.static_range(K):\n num = lo + P - k * D\n valid = out_mask & (num >= 0) & ((num % S) == 0)\n li = num // S\n m = valid & (li < L_in)\n xv = tl.load(x_ptr + x_base + li, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + k).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * L_out + lo, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv1d_transpose\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, L_in = x_c.shape\n _, C_out_g, K = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n (S,) = conv.stride\n (P,) = conv.padding\n (D,) = conv.dilation\n (OP,) = conv.output_padding\n L_out = (L_in - 1) * S - 2 * P + D * (K - 1) + OP + 1\n out = torch.empty((N, C_out, L_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_L = 256\n grid = (N * C_out, triton.cdiv(L_out, BLOCK_L))\n conv_transpose1d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, L_in, C_out, L_out,\n C_in_g, C_out_g,\n K, S, P, D,\n BLOCK_L=BLOCK_L,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.1839, "raw_speedup": 0.1839, "ref_ms": 1.460736, "cand_ms": 7.943168, "max_abs_diff": 0.0, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.460736, "mean_ms": 1.608397, "min_ms": 1.374208, "max_ms": 2.41152, "std_ms": 0.317633}, "cand_stats": {"median_ms": 7.943168, "mean_ms": 8.273818, "min_ms": 7.354368, "max_ms": 9.321472, "std_ms": 0.815153}}} +{"timestamp": "2026-12-02T14:35:39.197291+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated", "source_kb_id": 75, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated (KernelBench Level 1 #75, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated\"\nSOURCE_KB_ID = 75\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 2D transposed convolution operation with asymmetric input, asymmetric kernel, \n grouped, padded, and dilated.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (tuple, optional): Stride of the convolution (height, width). Defaults to (1, 1).\n padding (tuple, optional): Padding applied to the input (height, width). Defaults to (0, 0).\n dilation (tuple, optional): Spacing between kernel elements (height, width). Defaults to (1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = (3, 5)\nheight = 128\nwidth = 256\nstride = (2, 3)\npadding = (1, 2)\ndilation = (2, 1)\ngroups = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nheight = 64\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation, groups]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KH * KW\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = out_mask & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n _, C_out_g, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n OPH, OPW = conv.output_padding\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv_transpose2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.2832, "raw_speedup": 0.2832, "ref_ms": 1.437184, "cand_ms": 5.074944, "max_abs_diff": 2.980232238769531e-07, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.437184, "mean_ms": 1.471437, "min_ms": 1.364992, "max_ms": 1.767424, "std_ms": 0.105974}, "cand_stats": {"median_ms": 5.074944, "mean_ms": 4.973312, "min_ms": 3.979264, "max_ms": 5.684224, "std_ms": 0.470839}}} +{"timestamp": "2026-12-02T14:35:48.193453+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided", "source_kb_id": 77, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided (KernelBench Level 1 #77, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided\"\nSOURCE_KB_ID = 77\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 3D transposed convolution operation with square input and square kernel,\n and supports padding, dilation, and stride.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel (square kernel, so only one value needed).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = 3\ndepth = 16\nheight = 32\nwidth = 32\nstride = 2\npadding = 1\ndilation = 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 32\ndepth = 8\nheight = 16\nwidth = 16\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose3d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD: tl.constexpr, KH: tl.constexpr, KW: tl.constexpr,\n SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n DHW_out = D_out * H_out * W_out\n idx = tl.program_id(1) * BLOCK + tl.arange(0, BLOCK)\n out_mask = idx < DHW_out\n wo = idx % W_out\n tmp = idx // W_out\n ho = tmp % H_out\n do = tmp // H_out\n acc = tl.zeros((BLOCK,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * D_in * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KD * KH * KW\n for kd in tl.static_range(KD):\n nd = do + PD - kd * DD\n vd = out_mask & (nd >= 0) & ((nd % SD) == 0)\n di = nd // SD\n vd = vd & (di < D_in)\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = vd & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + (di * H_in + hi) * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + (kd * KH + kh) * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * DHW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose3d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, D_in, H_in, W_in = x_c.shape\n _, C_out_g, KD, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SD, SH, SW = conv.stride\n PD, PH, PW = conv.padding\n DD, DH, DW = conv.dilation\n OPD, OPH, OPW = conv.output_padding\n D_out = (D_in - 1) * SD - 2 * PD + DD * (KD - 1) + OPD + 1\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, D_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK = 128\n grid = (N * C_out, triton.cdiv(D_out * H_out * W_out, BLOCK))\n conv_transpose3d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, D_in, H_in, W_in, C_out, D_out, H_out, W_out,\n C_in_g, C_out_g,\n KD, KH, KW, SD, SH, SW, PD, PH, PW, DD, DH, DW,\n BLOCK=BLOCK,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.1272, "raw_speedup": 0.1272, "ref_ms": 0.342528, "cand_ms": 2.692096, "max_abs_diff": 0.00028628110885620117, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 0.342528, "mean_ms": 0.346982, "min_ms": 0.31232, "max_ms": 0.436224, "std_ms": 0.028557}, "cand_stats": {"median_ms": 2.692096, "mean_ms": 2.687334, "min_ms": 2.6368, "max_ms": 2.721792, "std_ms": 0.022203}}} +{"timestamp": "2026-12-02T14:35:55.387900+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded", "source_kb_id": 78, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded (KernelBench Level 1 #78, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded\"\nSOURCE_KB_ID = 78\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 2D transposed convolution operation with asymmetric input and kernel, with optional padding.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (tuple, optional): Stride of the convolution (height, width). Defaults to (1, 1).\n padding (tuple, optional): Padding applied to the input (height, width). Defaults to (0, 0).\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 32\nkernel_size = (3, 7)\nheight = 512\nwidth = 1024\nstride = (1, 1)\npadding = (1, 3)\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nheight = 128\nwidth = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KH * KW\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = out_mask & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n _, C_out_g, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n OPH, OPW = conv.output_padding\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv_transpose2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.1633, "raw_speedup": 0.1633, "ref_ms": 1.993216, "cand_ms": 12.205056, "max_abs_diff": 0.00045368075370788574, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.993216, "mean_ms": 2.023373, "min_ms": 1.801216, "max_ms": 2.57024, "std_ms": 0.195303}, "cand_stats": {"median_ms": 12.205056, "mean_ms": 11.290829, "min_ms": 9.654272, "max_ms": 12.496896, "std_ms": 1.221164}}} +{"timestamp": "2026-12-02T14:36:01.714660+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated", "source_kb_id": 79, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated (KernelBench Level 1 #79, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated\"\nSOURCE_KB_ID = 79\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation with asymmetric input and square kernel.\n Supports padding, striding, and dilation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = 3\n# long sequence\nlength = 131072\nstride = 2\npadding = 1\ndilation = 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nlength = 16384\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose1d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, L_in, C_out, L_out,\n C_in_g, C_out_g,\n K: tl.constexpr, S, P, D,\n BLOCK_L: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n lo = tl.program_id(1) * BLOCK_L + tl.arange(0, BLOCK_L)\n out_mask = lo < L_out\n acc = tl.zeros((BLOCK_L,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * L_in\n w_base = (ci * C_out_g + co_l) * K\n for k in tl.static_range(K):\n num = lo + P - k * D\n valid = out_mask & (num >= 0) & ((num % S) == 0)\n li = num // S\n m = valid & (li < L_in)\n xv = tl.load(x_ptr + x_base + li, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + k).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * L_out + lo, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv1d_transpose\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, L_in = x_c.shape\n _, C_out_g, K = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n (S,) = conv.stride\n (P,) = conv.padding\n (D,) = conv.dilation\n (OP,) = conv.output_padding\n L_out = (L_in - 1) * S - 2 * P + D * (K - 1) + OP + 1\n out = torch.empty((N, C_out, L_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_L = 256\n grid = (N * C_out, triton.cdiv(L_out, BLOCK_L))\n conv_transpose1d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, L_in, C_out, L_out,\n C_in_g, C_out_g,\n K, S, P, D,\n BLOCK_L=BLOCK_L,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.2799, "raw_speedup": 0.2799, "ref_ms": 3.750912, "cand_ms": 13.401088, "max_abs_diff": 0.0004226416349411011, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 3.750912, "mean_ms": 3.775283, "min_ms": 3.663872, "max_ms": 4.007936, "std_ms": 0.072265}, "cand_stats": {"median_ms": 13.401088, "mean_ms": 13.487616, "min_ms": 13.275136, "max_ms": 14.132224, "std_ms": 0.266715}}} +{"timestamp": "2026-12-02T14:36:07.960632+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded", "source_kb_id": 80, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded (KernelBench Level 1 #80, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded\"\nSOURCE_KB_ID = 80\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with square input and asymmetric kernel, with dilation and padding.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width). \n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (tuple, optional): Padding applied to the input (top/bottom, left/right). Defaults to (0, 0).\n dilation (tuple, optional): Spacing between kernel elements (height, width). Defaults to (1, 1).\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: tuple = (0, 0), dilation: tuple = (1, 1), bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 64\nkernel_size = (5, 9)\nwidth = 512\nheight = 512\nstride = 1\npadding = (2, 4)\ndilation = (2, 3)\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (co * C_in_g + ci_l) * KH * KW\n for kh in tl.static_range(KH):\n hi = ho * SH - PH + kh * DH\n for kw in tl.static_range(KW):\n wi = wo * SW - PW + kw * DW\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: tuple = (0, 0), dilation: tuple = (1, 1), bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n C_out, C_in_g, KH, KW = w_c.shape\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n groups = conv.groups\n C_out_g = C_out // groups\n H_out = (H_in + 2 * PH - DH * (KH - 1) - 1) // SH + 1\n W_out = (W_in + 2 * PW - DW * (KW - 1) - 1) // SW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.0913, "raw_speedup": 0.0913, "ref_ms": 1.622016, "cand_ms": 17.75616, "max_abs_diff": 0.00046882033348083496, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.622016, "mean_ms": 1.728973, "min_ms": 1.47968, "max_ms": 2.612224, "std_ms": 0.271781}, "cand_stats": {"median_ms": 17.75616, "mean_ms": 17.913549, "min_ms": 17.439745, "max_ms": 19.391487, "std_ms": 0.520312}}} +{"timestamp": "2026-12-02T14:36:14.394222+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided", "source_kb_id": 81, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided (KernelBench Level 1 #81, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided\"\nSOURCE_KB_ID = 81\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 2D transposed convolution operation with asymmetric input and square kernel, supporting dilation, padding, and stride.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel (square, e.g., 3 for a 3x3 kernel).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in). \n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = 3\nheight_in = 64\nwidth_in = 128\nstride = 5\npadding = 1\ndilation = 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nheight_in = 32\nwidth_in = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (ci * C_out_g + co_l) * KH * KW\n for kh in tl.static_range(KH):\n nh = ho + PH - kh * DH\n vh = out_mask & (nh >= 0) & ((nh % SH) == 0)\n hi = nh // SH\n vh = vh & (hi < H_in)\n for kw in tl.static_range(KW):\n nw = wo + PW - kw * DW\n vw = vh & (nw >= 0) & ((nw % SW) == 0)\n wi = nw // SW\n m = vw & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv_transpose2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n _, C_out_g, KH, KW = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n OPH, OPW = conv.output_padding\n H_out = (H_in - 1) * SH - 2 * PH + DH * (KH - 1) + OPH + 1\n W_out = (W_in - 1) * SW - 2 * PW + DW * (KW - 1) + OPW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv_transpose2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.0867, "raw_speedup": 0.0867, "ref_ms": 1.25952, "cand_ms": 14.526464, "max_abs_diff": 0.00012637116014957428, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.25952, "mean_ms": 1.272115, "min_ms": 1.196032, "max_ms": 1.381376, "std_ms": 0.061327}, "cand_stats": {"median_ms": 14.526464, "mean_ms": 14.54039, "min_ms": 14.409728, "max_ms": 15.077376, "std_ms": 0.138757}}} +{"timestamp": "2026-12-02T14:36:21.515857+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel", "source_kb_id": 85, "category": "convolution", "dtype": "fp32", "ref_path": "tasks/train/kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #85, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 85\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with asymmetric input and asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size_h (int): Height of the convolution kernel.\n kernel_size_w (int): Width of the convolution kernel.\n stride_h (int, optional): Stride of the convolution in height dimension. Defaults to 1.\n stride_w (int, optional): Stride of the convolution in width dimension. Defaults to 1.\n padding_h (int, optional): Padding applied to the input in height dimension. Defaults to 0.\n padding_w (int, optional): Padding applied to the input in width dimension. Defaults to 0.\n dilation_h (int, optional): Spacing between kernel elements in height dimension. Defaults to 1.\n dilation_w (int, optional): Spacing between kernel elements in width dimension. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size_h: int, kernel_size_w: int, stride_h: int = 1, stride_w: int = 1, padding_h: int = 0, padding_w: int = 0, dilation_h: int = 1, dilation_w: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, in_channels, (kernel_size_h, kernel_size_w), stride=(stride_h, stride_w), padding=(padding_h, padding_w), dilation=(dilation_h, dilation_w), groups=in_channels, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 32\nin_channels = 128\nout_channels = 128\nkernel_size_h = 3\nkernel_size_w = 7\nwidth = 256\nheight = 128\nstride_h = 1\nstride_w = 1\npadding_h = 0\npadding_w = 0\ndilation_h = 1\ndilation_w = 1\ngroups = in_channels\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 64\ngroups = in_channels\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size_h, kernel_size_w, stride_h, stride_w, padding_h, padding_w, dilation_h, dilation_w, groups]\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv2d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH: tl.constexpr, KW: tl.constexpr,\n SH, SW, PH, PW, DH, DW,\n BLOCK_HW: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n ci_start = g * C_in_g\n HW_out = H_out * W_out\n idx = tl.program_id(1) * BLOCK_HW + tl.arange(0, BLOCK_HW)\n out_mask = idx < HW_out\n wo = idx % W_out\n ho = idx // W_out\n acc = tl.zeros((BLOCK_HW,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * H_in * W_in\n w_base = (co * C_in_g + ci_l) * KH * KW\n for kh in tl.static_range(KH):\n hi = ho * SH - PH + kh * DH\n for kw in tl.static_range(KW):\n wi = wo * SW - PW + kw * DW\n m = out_mask & (hi >= 0) & (hi < H_in) & (wi >= 0) & (wi < W_in)\n xv = tl.load(x_ptr + x_base + hi * W_in + wi, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + kh * KW + kw).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * HW_out + idx, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size_h: int, kernel_size_w: int, stride_h: int = 1, stride_w: int = 1, padding_h: int = 0, padding_w: int = 0, dilation_h: int = 1, dilation_w: int = 1, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, in_channels, (kernel_size_h, kernel_size_w), stride=(stride_h, stride_w), padding=(padding_h, padding_w), dilation=(dilation_h, dilation_w), groups=in_channels, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv2d\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, H_in, W_in = x_c.shape\n C_out, C_in_g, KH, KW = w_c.shape\n SH, SW = conv.stride\n PH, PW = conv.padding\n DH, DW = conv.dilation\n groups = conv.groups\n C_out_g = C_out // groups\n H_out = (H_in + 2 * PH - DH * (KH - 1) - 1) // SH + 1\n W_out = (W_in + 2 * PW - DW * (KW - 1) - 1) // SW + 1\n out = torch.empty((N, C_out, H_out, W_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_HW = 128\n grid = (N * C_out, triton.cdiv(H_out * W_out, BLOCK_HW))\n conv2d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, H_in, W_in, C_out, H_out, W_out,\n C_in_g, C_out_g,\n KH, KW, SH, SW, PH, PW, DH, DW,\n BLOCK_HW=BLOCK_HW,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 1.6489, "raw_speedup": 1.6489, "ref_ms": 1.57952, "cand_ms": 0.957952, "max_abs_diff": 0.0, "trials_passed": 3, "trials_total": 3, "dtype": "float32", "error": null, "ref_stats": {"median_ms": 1.57952, "mean_ms": 1.579315, "min_ms": 1.503232, "max_ms": 1.649664, "std_ms": 0.02558}, "cand_stats": {"median_ms": 0.957952, "mean_ms": 0.950733, "min_ms": 0.896, "max_ms": 1.001472, "std_ms": 0.026053}}} +{"timestamp": "2026-12-02T14:36:28.492316+00:00", "run_id": "teacher_expand_conv_v2", "verifier_version": "v2", "problem": {"problem_id": "kb1_064_conv_transposed_1d__fp16", "source_kb_id": 64, "category": "convolution", "dtype": "fp16", "ref_path": "tasks/train/kb1_064_conv_transposed_1d__fp16.py"}, "prompt": "### Reference PyTorch Model\n```python\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n return a + b\n\ndef get_inputs():\n return [torch.randn(1024, 1024), torch.randn(1024, 1024)]\n\ndef get_init_inputs():\n return []\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\nimport torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n@triton.jit\ndef add_kernel(x_ptr, y_ptr, out_ptr, n_elements, BLOCK_SIZE: tl.constexpr):\n pid = tl.program_id(0)\n offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)\n mask = offsets < n_elements\n x = tl.load(x_ptr + offsets, mask=mask, other=0.0)\n y = tl.load(y_ptr + offsets, mask=mask, other=0.0)\n tl.store(out_ptr + offsets, x + y, mask=mask)\n\nclass ModelNew(nn.Module):\n def __init__(self):\n super().__init__()\n\n def forward(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:\n a = a.contiguous()\n b = b.contiguous()\n out = torch.empty_like(a)\n n_elements = a.numel()\n grid = lambda meta: ((n_elements + meta[\"BLOCK_SIZE\"] - 1) // meta[\"BLOCK_SIZE\"],)\n add_kernel[grid](a, b, out, n_elements, BLOCK_SIZE=1024)\n return out\n```\n\n### Reference PyTorch Model\n```python\n\"\"\"Task kb1_064_conv_transposed_1d__fp16 (KernelBench Level 1 #64, split=train, category=convolution, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_064_conv_transposed_1d__fp16\"\nSOURCE_KB_ID = 64\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 64\nin_channels = 128\nout_channels = 128\nkernel_size = 3\n# much larger signal length for heavier workload\nlength = 65536\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\nout_channels = 64\nlength = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\n```\n\n### Triton Kernel Implementation (ModelNew)\n```python\n", "generated_kernel": "import torch\nimport torch.nn as nn\nimport triton\nimport triton.language as tl\n\n\n@triton.jit\ndef conv_transpose1d_kernel(\n x_ptr, w_ptr, b_ptr, out_ptr,\n HAS_BIAS: tl.constexpr,\n C_in, L_in, C_out, L_out,\n C_in_g, C_out_g,\n K: tl.constexpr, S, P, D,\n BLOCK_L: tl.constexpr,\n):\n nc_out = tl.program_id(0)\n n = nc_out // C_out\n co = nc_out % C_out\n g = co // C_out_g\n co_l = co % C_out_g\n ci_start = g * C_in_g\n lo = tl.program_id(1) * BLOCK_L + tl.arange(0, BLOCK_L)\n out_mask = lo < L_out\n acc = tl.zeros((BLOCK_L,), dtype=tl.float32)\n if HAS_BIAS:\n acc += tl.load(b_ptr + co).to(tl.float32)\n for ci_l in range(C_in_g):\n ci = ci_start + ci_l\n x_base = (n * C_in + ci) * L_in\n w_base = (ci * C_out_g + co_l) * K\n for k in tl.static_range(K):\n num = lo + P - k * D\n valid = out_mask & (num >= 0) & ((num % S) == 0)\n li = num // S\n m = valid & (li < L_in)\n xv = tl.load(x_ptr + x_base + li, mask=m, other=0.0).to(tl.float32)\n wv = tl.load(w_ptr + w_base + k).to(tl.float32)\n acc += xv * wv\n tl.store(out_ptr + nc_out * L_out + lo, acc, mask=out_mask)\n\n\nclass ModelNew(nn.Module):\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(ModelNew, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n conv = self.conv1d_transpose\n x_c = x.contiguous()\n w_c = conv.weight.contiguous()\n b_c = conv.bias.contiguous() if conv.bias is not None else w_c\n N, C_in, L_in = x_c.shape\n _, C_out_g, K = w_c.shape\n groups = conv.groups\n C_in_g = C_in // groups\n C_out = C_out_g * groups\n (S,) = conv.stride\n (P,) = conv.padding\n (D,) = conv.dilation\n (OP,) = conv.output_padding\n L_out = (L_in - 1) * S - 2 * P + D * (K - 1) + OP + 1\n out = torch.empty((N, C_out, L_out), device=x_c.device, dtype=x_c.dtype)\n BLOCK_L = 256\n grid = (N * C_out, triton.cdiv(L_out, BLOCK_L))\n conv_transpose1d_kernel[grid](\n x_c, w_c, b_c, out,\n conv.bias is not None,\n C_in, L_in, C_out, L_out,\n C_in_g, C_out_g,\n K, S, P, D,\n BLOCK_L=BLOCK_L,\n )\n return out\n", "verifier_result": {"verifier_version": "v2", "status": "PASS", "compiled": true, "correct": true, "uses_triton": true, "triton_launched": true, "triton_launch_count": 3, "speedup": 0.1715, "raw_speedup": 0.1715, "ref_ms": 0.838656, "cand_ms": 4.890112, "max_abs_diff": 0.0009765625, "trials_passed": 3, "trials_total": 3, "dtype": "float16", "error": null, "ref_stats": {"median_ms": 0.838656, "mean_ms": 0.850995, "min_ms": 0.765952, "max_ms": 0.98304, "std_ms": 0.051059}, "cand_stats": {"median_ms": 4.890112, "mean_ms": 5.098394, "min_ms": 4.507648, "max_ms": 5.946368, "std_ms": 0.517604}}} diff --git a/train_problems.jsonl b/train_problems.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..744cd801378e6bc5c5806aaae757407abd45ae74 --- /dev/null +++ b/train_problems.jsonl @@ -0,0 +1,140 @@ +{"problem_id": "kb1_002_standard_matrix_multiplication", "source_kb_id": 2, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_004_matrix_vector_multiplication", "source_kb_id": 4, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_004_matrix_vector_multiplication (KernelBench Level 1 #4, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_004_matrix_vector_multiplication\"\nSOURCE_KB_ID = 4\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix-vector multiplication (C = A * B).\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix-vector multiplication.\n\n Args:\n A: Input matrix of shape (M, K).\n B: Input vector of shape (K, 1).\n\n Returns:\n Output vector of shape (M, 1).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256 * 8 # 2048\nK = 131072 * 8 # 1048576\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 16384\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, 1)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_005_matrix_scalar_multiplication", "source_kb_id": 5, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_005_matrix_scalar_multiplication (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_006_matmul_with_large_k_dimension", "source_kb_id": 6, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_006_matmul_with_large_k_dimension (KernelBench Level 1 #6, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_007_matmul_with_small_k_dimension", "source_kb_id": 7, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_007_matmul_with_small_k_dimension (KernelBench Level 1 #7, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_007_matmul_with_small_k_dimension\"\nSOURCE_KB_ID = 7\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a small K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16384 * 2\nK = 32 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nK = 64\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_008_matmul_with_irregular_shapes", "source_kb_id": 8, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_008_matmul_with_irregular_shapes (KernelBench Level 1 #8, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_008_matmul_with_irregular_shapes\"\nSOURCE_KB_ID = 8\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with irregular shapes\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor with shape (M, K).\n B: Input tensor with shape (K, N).\n\n Returns:\n C: Output tensor with shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 8205\nK = 2949\nN = 5921\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2051\nK = 1473\nN = 1973\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_009_tall_skinny_matrix_multiplication", "source_kb_id": 9, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_009_tall_skinny_matrix_multiplication (KernelBench Level 1 #9, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_009_tall_skinny_matrix_multiplication\"\nSOURCE_KB_ID = 9\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) where one of the matrices is tall and skinny (M >> N or N >> M)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): Input matrix of shape (M, K) or (K, M) where M >> N or N >> M.\n B (torch.Tensor): Input matrix of shape (K, N) or (N, K) where M >> N or N >> M.\n\n Returns:\n torch.Tensor: Output matrix of shape (M, N) or (N, M)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 8192\nN = 64\n\ndef get_inputs():\n A = torch.rand(M, N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_010_3d_tensor_matrix_multiplication", "source_kb_id": 10, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_010_3d_tensor_matrix_multiplication (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_011_4d_tensor_matrix_multiplication", "source_kb_id": 11, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_011_4d_tensor_matrix_multiplication (KernelBench Level 1 #11, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_011_4d_tensor_matrix_multiplication\"\nSOURCE_KB_ID = 11\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 4D tensor-matrix multiplication: \n C[b, i, j, k] = sum_l A[b, i, j, l] * B[l, k]\n\n Args:\n A (torch.Tensor): Input 4D tensor of shape (b, i, j, l)\n B (torch.Tensor): Input matrix of shape (l, k)\n\n Returns:\n torch.Tensor: Output 4D tensor of shape (b, i, j, k)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, A, B):\n \"\"\"\n Performs the 4D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 4D tensor of shape (b, i, j, l)\n B (torch.Tensor): Input matrix of shape (l, k)\n\n Returns:\n torch.Tensor: Output 4D tensor of shape (b, i, j, k)\n \"\"\"\n return torch.einsum(\"bijl,lk->bijk\", A, B)\n\n# Test code\nb = 8\ni = 256\nj = 512\nl = 256\nk = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nb = 4\ni = 128\nj = 256\nl = 128\nk = 256\n\ndef get_inputs():\n A = torch.rand(b, i, j, l)\n B = torch.rand(l, k)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_012_matmul_with_diagonal_matrices", "source_kb_id": 12, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_012_matmul_with_diagonal_matrices (KernelBench Level 1 #12, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_012_matmul_with_diagonal_matrices\"\nSOURCE_KB_ID = 12\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication of a diagonal matrix with another matrix.\n C = diag(A) * B\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): A 1D tensor representing the diagonal of the diagonal matrix. Shape: (N,).\n B (torch.Tensor): A 2D tensor representing the second matrix. Shape: (N, M).\n\n Returns:\n torch.Tensor: The result of the matrix multiplication. Shape: (N, M).\n \"\"\"\n # Logically equivalent to torch.diag(A) @ B \n # more efficient as no need to materialize a full N\u00d7N matrix\n return A.unsqueeze(1) * B\n\nM = 4096\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2048\nN = 2048\n\ndef get_inputs():\n A = torch.rand(N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_013_matmul_for_symmetric_matrices", "source_kb_id": 13, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_013_matmul_for_symmetric_matrices (KernelBench Level 1 #13, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_013_matmul_for_symmetric_matrices\"\nSOURCE_KB_ID = 13\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with A and B being symmetric matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of two symmetric matrices.\n\n Args:\n A (torch.Tensor): Input matrix A, shape (N, N), symmetric.\n B (torch.Tensor): Input matrix B, shape (N, N), symmetric.\n\n Returns:\n torch.Tensor: Output matrix C, shape (N, N).\n \"\"\"\n return torch.matmul(A, B)\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\n\ndef get_inputs():\n \"\"\"\n Generates a pair of random symmetric matrices for testing.\n\n Returns:\n list: List containing two symmetric tensors A and B.\n \"\"\"\n A = torch.rand(N, N)\n A = (A + A.T) / 2 # Ensure symmetry\n B = torch.rand(N, N)\n B = (B + B.T) / 2 # Ensure symmetry\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs needed for this model.\n\n Returns:\n list: Empty list.\n \"\"\"\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_014_matmul_for_upper_triangular_matrices", "source_kb_id": 14, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_014_matmul_for_upper_triangular_matrices (KernelBench Level 1 #14, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_014_matmul_for_upper_triangular_matrices\"\nSOURCE_KB_ID = 14\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix multiplication (C = A * B) for upper triangular matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication for upper triangular matrices.\n\n Args:\n A (torch.Tensor): Upper triangular matrix of shape (N, N).\n B (torch.Tensor): Upper triangular matrix of shape (N, N).\n\n Returns:\n torch.Tensor: The product of A and B, also an upper triangular matrix of shape (N, N).\n \"\"\"\n return torch.triu(torch.matmul(A, B))\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\n\ndef get_inputs():\n \"\"\"\n Generates upper triangular matrices for testing.\n\n Returns:\n list: A list containing two upper triangular matrices of shape (N, N).\n \"\"\"\n A = torch.triu(torch.rand(N, N))\n B = torch.triu(torch.rand(N, N))\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs are needed for this model.\n\n Returns:\n list: An empty list.\n \"\"\"\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_015_matmul_for_lower_triangular_matrices", "source_kb_id": 15, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_015_matmul_for_lower_triangular_matrices (KernelBench Level 1 #15, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_015_matmul_for_lower_triangular_matrices\"\nSOURCE_KB_ID = 15\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication (C = A * B) where A and B are lower triangular matrices. \n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of lower triangular matrices A and B.\n\n Args:\n A (torch.Tensor): Lower triangular matrix of shape (N, N).\n B (torch.Tensor): Lower triangular matrix of shape (N, N).\n\n Returns:\n torch.Tensor: The result of matrix multiplication C of shape (N, N).\n \"\"\"\n return torch.tril(torch.matmul(A, B))\n\nM = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\n\ndef get_inputs():\n A = torch.rand(M, M)\n B = torch.rand(M, M)\n A = torch.tril(A)\n B = torch.tril(B)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_016_matmul_with_transposed_a", "source_kb_id": 16, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_016_matmul_with_transposed_a (KernelBench Level 1 #16, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_018_matmul_with_transposed_both", "source_kb_id": 18, "category": "matmul", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_018_matmul_with_transposed_both (KernelBench Level 1 #18, split=train, category=matmul, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_018_matmul_with_transposed_both\"\nSOURCE_KB_ID = 18\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B.T)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(N, K)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_020_leakyrelu", "source_kb_id": 20, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_020_leakyrelu (KernelBench Level 1 #20, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_021_sigmoid", "source_kb_id": 21, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_021_sigmoid (KernelBench Level 1 #21, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_022_tanh", "source_kb_id": 22, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_022_tanh (KernelBench Level 1 #22, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_024_logsoftmax", "source_kb_id": 24, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_024_logsoftmax (KernelBench Level 1 #24, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_027_selu", "source_kb_id": 27, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_027_selu (KernelBench Level 1 #27, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_027_selu\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_028_hardsigmoid", "source_kb_id": 28, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_028_hardsigmoid (KernelBench Level 1 #28, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_028_hardsigmoid\"\nSOURCE_KB_ID = 28\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardSigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardSigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardSigmoid applied, same shape as input.\n \"\"\"\n return torch.nn.functional.hardsigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_029_softplus", "source_kb_id": 29, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_029_softplus (KernelBench Level 1 #29, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_030_softsign", "source_kb_id": 30, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_030_softsign (KernelBench Level 1 #30, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_030_softsign\"\nSOURCE_KB_ID = 30\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softsign activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softsign activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softsign applied, same shape as input.\n \"\"\"\n return x / (1 + torch.abs(x))\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_031_elu", "source_kb_id": 31, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_031_elu (KernelBench Level 1 #31, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_031_elu\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_032_hardtanh", "source_kb_id": 32, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_032_hardtanh (KernelBench Level 1 #32, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_032_hardtanh\"\nSOURCE_KB_ID = 32\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardTanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardTanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardTanh applied, same shape as input.\n \"\"\"\n return F.hardtanh(x, min_val=-1., max_val=1.)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_033_batchnorm", "source_kb_id": 33, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_033_batchnorm (KernelBench Level 1 #33, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_034_instancenorm", "source_kb_id": 34, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_034_instancenorm (KernelBench Level 1 #34, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_034_instancenorm\"\nSOURCE_KB_ID = 34\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Instance Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the InstanceNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.inorm = nn.InstanceNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Instance Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Instance Normalization applied, same shape as input.\n \"\"\"\n return self.inorm(x)\n\nbatch_size = 112 # heavier workload\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_035_groupnorm", "source_kb_id": 35, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_035_groupnorm (KernelBench Level 1 #35, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_037_frobeniusnorm", "source_kb_id": 37, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_037_frobeniusnorm (KernelBench Level 1 #37, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_037_frobeniusnorm\"\nSOURCE_KB_ID = 37\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Frobenius norm normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the Frobenius norm normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Frobenius norm normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with Frobenius norm normalization applied, same shape as input.\n \"\"\"\n norm = torch.norm(x, p='fro')\n return x / norm\n\nbatch_size = 112\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_038_l1norm", "source_kb_id": 38, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_038_l1norm (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_039_l2norm", "source_kb_id": 39, "category": "normalization", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_039_l2norm (KernelBench Level 1 #39, split=train, category=normalization, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_041_max_pooling_1d", "source_kb_id": 41, "category": "pooling", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_041_max_pooling_1d (KernelBench Level 1 #41, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_041_max_pooling_1d\"\nSOURCE_KB_ID = 41\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max Pooling 1D.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False):\n \"\"\"\n Initializes the Max Pooling 1D layer.\n\n Args:\n kernel_size (int): Size of the window to take a max over.\n stride (int, optional): Stride of the window. Defaults to None (same as kernel_size).\n padding (int, optional): Implicit zero padding to be added on both sides. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n return_indices (bool, optional): Whether to return the indices of the maximum values. Defaults to False.\n \"\"\"\n super(Model, self).__init__()\n self.maxpool = nn.MaxPool1d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max Pooling 1D to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, sequence_length).\n\n Returns:\n torch.Tensor: Output tensor with Max Pooling 1D applied, shape (batch_size, num_features, output_sequence_length).\n \"\"\"\n return self.maxpool(x)\n\nbatch_size = 64\nfeatures = 192\nsequence_length = 65536\n\nkernel_size = 8\nstride = 1\npadding = 4\ndilation = 3 \n\nreturn_indices = False\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nsequence_length = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, features, sequence_length)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding, dilation, return_indices]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_043_max_pooling_3d", "source_kb_id": 43, "category": "pooling", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_043_max_pooling_3d (KernelBench Level 1 #43, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_043_max_pooling_3d\"\nSOURCE_KB_ID = 43\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max Pooling 3D.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False, ceil_mode: bool = False):\n \"\"\"\n Initializes the Max Pooling 3D layer.\n\n Args:\n kernel_size (int): Size of the kernel for the max pooling operation.\n stride (int, optional): Stride of the pooling operation. Defaults to None, which means stride is equal to kernel_size.\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n return_indices (bool, optional): Whether to return indices of the maximum values. Defaults to False.\n ceil_mode (bool, optional): When True, the output size is ceil(input_size / stride) instead of floor. Defaults to False.\n \"\"\"\n super(Model, self).__init__()\n self.maxpool = nn.MaxPool3d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices, ceil_mode=ceil_mode)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max Pooling 3D to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, dim1, dim2, dim3).\n\n Returns:\n torch.Tensor: Output tensor with Max Pooling 3D applied.\n \"\"\"\n return self.maxpool(x)\n\nbatch_size = 16\nchannels = 32\ndim1 = 128\ndim2 = 128\ndim3 = 128\nkernel_size = 3\nstride = 2\npadding = 1\ndilation = 3\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nchannels = 16\ndim1 = 32\ndim2 = 32\ndim3 = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, dim1, dim2, dim3)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_044_average_pooling_1d", "source_kb_id": 44, "category": "pooling", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_044_average_pooling_1d (KernelBench Level 1 #44, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_044_average_pooling_1d\"\nSOURCE_KB_ID = 44\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 1D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = 1, padding: int = 0):\n \"\"\"\n Initializes the 1D Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the pooling window.\n stride (int, optional): Stride of the pooling operation. Defaults to 1.\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool1d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies 1D Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, input_length).\n\n Returns:\n torch.Tensor: Output tensor with 1D Average Pooling applied, shape (batch_size, in_channels, output_length).\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 64\nin_channels = 128\ninput_length = 65536\nkernel_size = 8\nstride = 1\npadding = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\ninput_length = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, input_length)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_045_average_pooling_2d", "source_kb_id": 45, "category": "pooling", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_045_average_pooling_2d (KernelBench Level 1 #45, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_045_average_pooling_2d\"\nSOURCE_KB_ID = 45\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 2D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):\n \"\"\"\n Initializes the Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the pooling window.\n stride (int, optional): Stride of the pooling operation. Defaults to None (same as kernel_size).\n padding (int, optional): Padding applied to the input tensor. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool2d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies 2D Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Average Pooling applied.\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 16\nchannels = 64\nheight = 2048\nwidth = 2048\nkernel_size = 11\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nchannels = 64\nheight = 256\nwidth = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_046_average_pooling_3d", "source_kb_id": 46, "category": "pooling", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_046_average_pooling_3d (KernelBench Level 1 #46, split=train, category=pooling, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_046_average_pooling_3d\"\nSOURCE_KB_ID = 46\nCATEGORY = \"pooling\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs 3D Average Pooling.\n \"\"\"\n def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):\n \"\"\"\n Initializes the Average Pooling layer.\n\n Args:\n kernel_size (int): Size of the kernel to apply pooling.\n stride (int, optional): Stride of the pooling operation. Defaults to None, which uses the kernel size.\n padding (int, optional): Padding to apply before pooling. Defaults to 0.\n \"\"\"\n super(Model, self).__init__()\n self.avg_pool = nn.AvgPool3d(kernel_size=kernel_size, stride=stride, padding=padding)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Average Pooling to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Average Pooling applied, shape depends on kernel_size, stride and padding.\n \"\"\"\n return self.avg_pool(x)\n\nbatch_size = 16\nchannels = 32\ndepth = 128\nheight = 128\nwidth = 256\nkernel_size = 3\nstride = 2\npadding = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nchannels = 16\ndepth = 32\nheight = 32\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [kernel_size, stride, padding]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_048_mean_reduction_over_a_dimension", "source_kb_id": 48, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_048_mean_reduction_over_a_dimension (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_049_max_reduction_over_a_dimension", "source_kb_id": 49, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_049_max_reduction_over_a_dimension (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_050_conv_standard_2d_square_input_square_kernel", "source_kb_id": 50, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_050_conv_standard_2d_square_input_square_kernel (KernelBench Level 1 #50, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_050_conv_standard_2d_square_input_square_kernel\"\nSOURCE_KB_ID = 50\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n def __init__(self, num_classes=1000):\n super(Model, self).__init__()\n self.conv1 = nn.Conv2d(in_channels=3, out_channels=96, kernel_size=11, stride=4, padding=2)\n \n def forward(self, x):\n x = self.conv1(x)\n return x\n\n# Test code\nbatch_size = 256\nnum_classes = 1000\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\n\ndef get_inputs():\n return [torch.rand(batch_size, 3, 224, 224)]\n\ndef get_init_inputs():\n return [num_classes]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_052_argmin_over_a_dimension", "source_kb_id": 52, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_052_argmin_over_a_dimension (KernelBench Level 1 #52, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_052_argmin_over_a_dimension\"\nSOURCE_KB_ID = 52\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that finds the index of the minimum value along a specified dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to perform argmin on.\n\n Args:\n dim (int): Dimension along which to find the minimum value.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Finds the index of the minimum value along the specified dimension.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Tensor containing the indices of the minimum values along the specified dimension.\n \"\"\"\n return torch.argmin(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_053_min_reduction_over_a_dimension", "source_kb_id": 53, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_053_min_reduction_over_a_dimension (KernelBench Level 1 #53, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_053_min_reduction_over_a_dimension\"\nSOURCE_KB_ID = 53\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs min reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies min reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after min reduction over the specified dimension.\n \"\"\"\n return torch.min(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_054_conv_standard_3d_square_input_square_kernel", "source_kb_id": 54, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_054_conv_standard_3d_square_input_square_kernel (KernelBench Level 1 #54, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_054_conv_standard_3d_square_input_square_kernel\"\nSOURCE_KB_ID = 54\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with square input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, (kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, width, height).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, width_out, height_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 3\nout_channels = 64\nkernel_size = 3\ndepth = 64\nwidth = 64\nheight = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\ndepth = 32\nwidth = 32\nheight = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, width, height)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_055_conv_standard_2d_asymmetric_input_square_kernel", "source_kb_id": 55, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_055_conv_standard_2d_asymmetric_input_square_kernel (KernelBench Level 1 #55, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_055_conv_standard_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 55\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\n# smaller spatial dims\nheight = 512\nwidth = 1024\nin_channels = 64 # increased channels\nout_channels = 128\nkernel_size = 3\n# asymmetric input: make width considerably larger than height\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nheight = 128\nwidth = 256\nin_channels = 32\nout_channels = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel", "source_kb_id": 56, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #56, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_056_conv_standard_2d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 56\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with asymmetric input and kernel sizes.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Tuple of two integers representing the height and width of the convolution kernel.\n stride (tuple, optional): Tuple of two integers representing the stride in the height and width dimensions. Defaults to (1, 1).\n padding (tuple, optional): Tuple of two integers representing the padding in the height and width dimensions. Defaults to (0, 0).\n dilation (tuple, optional): Tuple of two integers representing the dilation in the height and width dimensions. Defaults to (1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nkernel_size = (5, 7)\nheight = 512\nwidth = 256\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nheight = 128\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_057_conv_transposed_2d_square_input_square_kernel", "source_kb_id": 57, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_057_conv_transposed_2d_square_input_square_kernel (KernelBench Level 1 #57, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_057_conv_transposed_2d_square_input_square_kernel\"\nSOURCE_KB_ID = 57\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution with square input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 64 # double channels for heavier compute\nout_channels = 64\nkernel_size = 3\n# larger square input\nheight = 1024\nwidth = 1024\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nheight = 256\nwidth = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel", "source_kb_id": 58, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #58, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_058_conv_transposed_3d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 58\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution operation with asymmetric input and kernel sizes.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Tuple of 3 integers representing the kernel size in the form (depth, height, width).\n stride (tuple, optional): Tuple of 3 integers representing the stride in the form (depth, height, width). Defaults to (1, 1, 1).\n padding (tuple, optional): Tuple of 3 integers representing the padding in the form (depth, height, width). Defaults to (0, 0, 0).\n output_padding (tuple, optional): Tuple of 3 integers representing the output padding in the form (depth, height, width). Defaults to (0, 0, 0).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth_in, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 16\nkernel_size = (3, 5, 7) # Asymmetric kernel size\ndepth_in = 16\nheight_in = 32\nwidth_in = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 16\nout_channels = 16\ndepth_in = 8\nheight_in = 16\nwidth_in = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth_in, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_059_conv_standard_3d_asymmetric_input_square_kernel", "source_kb_id": 59, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_059_conv_standard_3d_asymmetric_input_square_kernel (KernelBench Level 1 #59, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_059_conv_standard_3d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 59\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel (kernel_size x kernel_size).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, (kernel_size, kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width, depth).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out, depth_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 3\nout_channels = 64\nkernel_size = 3\nwidth = 256\nheight = 256\ndepth = 10\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nwidth = 64\nheight = 64\ndepth = 8\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width, depth)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_060_conv_standard_3d_square_input_asymmetric_kernel", "source_kb_id": 60, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_060_conv_standard_3d_square_input_asymmetric_kernel (KernelBench Level 1 #60, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_060_conv_standard_3d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 60\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (kernel_width, kernel_height, kernel_depth).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, width, height, depth).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, width_out, height_out, depth_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 3\nout_channels = 64\nkernel_size = (3, 5, 7) # Asymmetric kernel\nwidth = 64\nheight = 64\ndepth = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nwidth = 32\nheight = 32\ndepth = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, width, height, depth)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_061_conv_transposed_3d_square_input_square_kernel", "source_kb_id": 61, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_061_conv_transposed_3d_square_input_square_kernel (KernelBench Level 1 #61, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_061_conv_transposed_3d_square_input_square_kernel\"\nSOURCE_KB_ID = 61\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution with square input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 48\nout_channels = 48\nkernel_size = 3\ndepth = 64\nheight = 64\nwidth = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 16\nheight = 16\nwidth = 16\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_062_conv_standard_2d_square_input_asymmetric_kernel", "source_kb_id": 62, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_062_conv_standard_2d_square_input_asymmetric_kernel (KernelBench Level 1 #62, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_062_conv_standard_2d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 62\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 64\nkernel_size = (5, 9)\nwidth = 512\nheight = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_064_conv_transposed_1d", "source_kb_id": 64, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_064_conv_transposed_1d (KernelBench Level 1 #64, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_064_conv_transposed_1d\"\nSOURCE_KB_ID = 64\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 64\nin_channels = 128\nout_channels = 128\nkernel_size = 3\n# much larger signal length for heavier workload\nlength = 65536\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\nout_channels = 64\nlength = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_065_conv_transposed_2d_square_input_asymmetric_kernel", "source_kb_id": 65, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_065_conv_transposed_2d_square_input_asymmetric_kernel (KernelBench Level 1 #65, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_065_conv_transposed_2d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 65\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n output_padding (int or tuple, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 64\nout_channels = 64\nkernel_size = (3, 7) # larger asymmetric kernel\nwidth = 512\nheight = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel", "source_kb_id": 66, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #66, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_066_conv_standard_3d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 66\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 3D convolution operation with asymmetric input and kernel sizes.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel in the form (kernel_size_d, kernel_size_h, kernel_size_w).\n stride (tuple, optional): Stride of the convolution in the form (stride_d, stride_h, stride_w). Defaults to (1, 1, 1).\n padding (tuple, optional): Padding applied to the input in the form (padding_d, padding_h, padding_w). Defaults to (0, 0, 0).\n dilation (tuple, optional): Spacing between kernel elements in the form (dilation_d, dilation_h, dilation_w). Defaults to (1, 1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), dilation: tuple = (1, 1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv3d = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 3\nout_channels = 64\nkernel_size = (3, 5, 7) # Asymmetric kernel size\ndepth = 16\nheight = 128\nwidth = 128\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\ndepth = 8\nheight = 64\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_068_conv_transposed_3d_square_input_asymmetric_kernel", "source_kb_id": 68, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_068_conv_transposed_3d_square_input_asymmetric_kernel (KernelBench Level 1 #68, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_068_conv_transposed_3d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 68\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (kernel_depth, kernel_width, kernel_height), \n where kernel_width == kernel_height.\n stride (tuple, optional): Stride of the convolution. Defaults to (1, 1, 1).\n padding (tuple, optional): Padding applied to the input. Defaults to (0, 0, 0).\n output_padding (tuple, optional): Additional size added to one side of the output shape. Defaults to (0, 0, 0).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, width, height).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, width_out, height_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_depth = 3\nkernel_width = 5\nkernel_height = 5\ndepth = 64\nwidth = 64\nheight = 64\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 16\nout_channels = 32\ndepth = 16\nwidth = 16\nheight = 16\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, width, height)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, (kernel_depth, kernel_width, kernel_height)] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel", "source_kb_id": 69, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #69, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_069_conv_transposed_2d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 69\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution operation with asymmetric input and kernel size.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Tuple of integers representing the kernel size (height, width).\n stride (tuple, optional): Tuple of integers representing the stride of the convolution. Defaults to (1, 1).\n padding (tuple, optional): Tuple of integers representing the padding applied to the input. Defaults to (0, 0).\n output_padding (tuple, optional): Tuple of integers representing the additional size added to one side of the output shape. Defaults to (0, 0).\n dilation (tuple, optional): Tuple of integers representing the spacing between kernel elements. Defaults to (1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), output_padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 64\nout_channels = 128\nkernel_size = (3, 5)\nheight_in = 128\nwidth_in = 256\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 32\nout_channels = 64\nheight_in = 64\nwidth_in = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_070_conv_transposed_3d_asymmetric_input_square_kernel", "source_kb_id": 70, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_070_conv_transposed_3d_asymmetric_input_square_kernel (KernelBench Level 1 #70, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_070_conv_transposed_3d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 70\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 3D convolution operation with asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int or tuple, optional): Stride of the convolution. Defaults to 1.\n padding (int or tuple, optional): Padding applied to the input. Defaults to 0.\n output_padding (int or tuple, optional): Additional size added to one side of each dimension in the output shape. \n Defaults to 0.\n dilation (int or tuple, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, \n dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, (kernel_size, kernel_size, kernel_size), \n stride=stride, padding=padding, output_padding=output_padding, \n dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 3D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 48\nout_channels = 24\nkernel_size = 3\ndepth = 96\nheight = 96\nwidth = 96\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 24\nheight = 24\nwidth = 24\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_071_conv_transposed_2d_asymmetric_input_square_kernel", "source_kb_id": 71, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_071_conv_transposed_2d_asymmetric_input_square_kernel (KernelBench Level 1 #71, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_071_conv_transposed_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 71\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 2D convolution with asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 32\nkernel_size = 3\n# large asymmetric input\nheight_in = 512\nwidth_in = 1024\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nheight_in = 128\nwidth_in = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped", "source_kb_id": 72, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped (KernelBench Level 1 #72, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_072_conv_transposed_3d_asymmetric_input_asymmetric_kernel_strided_padded_grouped\"\nSOURCE_KB_ID = 72\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 3D transposed convolution operation with asymmetric input and kernel, and optional stride.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple of ints): Size of the convolution kernel in the form (kernel_size_depth, kernel_size_height, kernel_size_width).\n stride (tuple of ints, optional): Stride of the convolution in the form (stride_depth, stride_height, stride_width). Defaults to (1, 1, 1).\n padding (tuple of ints, optional): Padding applied to the input in the form (padding_depth, padding_height, padding_width). Defaults to (0, 0, 0).\n output_padding (tuple of ints, optional): Additional size added to one side of the output shape. Defaults to (0, 0, 0).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1, 1), padding: tuple = (0, 0, 0), output_padding: tuple = (0, 0, 0), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 32\nkernel_size = (3, 5, 7)\ndepth = 12\nheight = 24\nwidth = 48\nstride = (2, 2, 2)\npadding = (1, 2, 3)\noutput_padding = (1, 1, 1)\ngroups = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 8\nheight = 12\nwidth = 24\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, output_padding, groups]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped", "source_kb_id": 73, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped (KernelBench Level 1 #73, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_073_conv_transposed_3d_asymmetric_input_square_kernel_strided_padded_grouped\"\nSOURCE_KB_ID = 73\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 3D transposed convolution operation with asymmetric input and square kernel.\n The input is padded before the convolution.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, groups=groups, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nkernel_size = 3\ndepth = 32\nheight = 64\nwidth = 128\nstride = 2\npadding = 1\ngroups = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 16\ndepth = 12\nheight = 24\nwidth = 32\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, groups]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_074_conv_transposed_1d_dilated", "source_kb_id": 74, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_074_conv_transposed_1d_dilated (KernelBench Level 1 #74, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_074_conv_transposed_1d_dilated\"\nSOURCE_KB_ID = 74\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation with square input and asymmetric kernel, optionally with dilation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 32\nin_channels = 32\nout_channels = 64\nkernel_size = 5\nlength = 131072\nstride = 1\npadding = 0\ndilation = 3\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nlength = 16384\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated", "source_kb_id": 75, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated (KernelBench Level 1 #75, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_075_conv_transposed_2d_asymmetric_input_asymmetric_kernel_strided_grouped_padded_dilated\"\nSOURCE_KB_ID = 75\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 2D transposed convolution operation with asymmetric input, asymmetric kernel, \n grouped, padded, and dilated.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (tuple, optional): Stride of the convolution (height, width). Defaults to (1, 1).\n padding (tuple, optional): Padding applied to the input (height, width). Defaults to (0, 0).\n dilation (tuple, optional): Spacing between kernel elements (height, width). Defaults to (1, 1).\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), dilation: tuple = (1, 1), groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = (3, 5)\nheight = 128\nwidth = 256\nstride = (2, 3)\npadding = (1, 2)\ndilation = (2, 1)\ngroups = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nheight = 64\nwidth = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation, groups]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_076_conv_standard_1d_dilated_strided", "source_kb_id": 76, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_076_conv_standard_1d_dilated_strided (KernelBench Level 1 #76, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_076_conv_standard_1d_dilated_strided\"\nSOURCE_KB_ID = 76\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 1D convolution operation with asymmetric input and a square kernel, potentially dilated and strided.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d = nn.Conv1d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 64\nout_channels = 128\nkernel_size = 3\n# longer signal\nlength = 524280\nstride = 3\ndilation = 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nlength = 32768\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided", "source_kb_id": 77, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided (KernelBench Level 1 #77, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_077_conv_transposed_3d_square_input_square_kernel_padded_dilated_strided\"\nSOURCE_KB_ID = 77\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 3D transposed convolution operation with square input and square kernel,\n and supports padding, dilation, and stride.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel (square kernel, so only one value needed).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 3D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, depth, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, depth_out, height_out, width_out).\n \"\"\"\n return self.conv_transpose3d(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = 3\ndepth = 16\nheight = 32\nwidth = 32\nstride = 2\npadding = 1\ndilation = 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2\nin_channels = 16\nout_channels = 32\ndepth = 8\nheight = 16\nwidth = 16\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, depth, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded", "source_kb_id": 78, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded (KernelBench Level 1 #78, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_078_conv_transposed_2d_asymmetric_input_asymmetric_kernel_padded\"\nSOURCE_KB_ID = 78\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 2D transposed convolution operation with asymmetric input and kernel, with optional padding.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width).\n stride (tuple, optional): Stride of the convolution (height, width). Defaults to (1, 1).\n padding (tuple, optional): Padding applied to the input (height, width). Defaults to (0, 0).\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: tuple = (1, 1), padding: tuple = (0, 0), bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 32\nkernel_size = (3, 7)\nheight = 512\nwidth = 1024\nstride = (1, 1)\npadding = (1, 3)\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 32\nheight = 128\nwidth = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated", "source_kb_id": 79, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated (KernelBench Level 1 #79, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_079_conv_transposed_1d_asymmetric_input_square_kernel_padded_strided_dilated\"\nSOURCE_KB_ID = 79\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation with asymmetric input and square kernel.\n Supports padding, striding, and dilation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = 3\n# long sequence\nlength = 131072\nstride = 2\npadding = 1\ndilation = 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nlength = 16384\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded", "source_kb_id": 80, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded (KernelBench Level 1 #80, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_080_conv_standard_2d_square_input_asymmetric_kernel_dilated_padded\"\nSOURCE_KB_ID = 80\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with square input and asymmetric kernel, with dilation and padding.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (tuple): Size of the convolution kernel (height, width). \n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (tuple, optional): Padding applied to the input (top/bottom, left/right). Defaults to (0, 0).\n dilation (tuple, optional): Spacing between kernel elements (height, width). Defaults to (1, 1).\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: tuple, stride: int = 1, padding: tuple = (0, 0), dilation: tuple = (1, 1), bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\nin_channels = 32\nout_channels = 64\nkernel_size = (5, 9)\nwidth = 512\nheight = 512\nstride = 1\npadding = (2, 4)\ndilation = (2, 3)\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided", "source_kb_id": 81, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided (KernelBench Level 1 #81, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_081_conv_transposed_2d_asymmetric_input_square_kernel_dilated_padded_strided\"\nSOURCE_KB_ID = 81\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a 2D transposed convolution operation with asymmetric input and square kernel, supporting dilation, padding, and stride.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel (square, e.g., 3 for a 3x3 kernel).\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv_transpose2d = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D transposed convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in). \n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv_transpose2d(x)\n\n\n# Test code\nbatch_size = 16\nin_channels = 32\nout_channels = 64\nkernel_size = 3\nheight_in = 64\nwidth_in = 128\nstride = 5\npadding = 1\ndilation = 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nin_channels = 32\nout_channels = 64\nheight_in = 32\nwidth_in = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel", "source_kb_id": 83, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel (KernelBench Level 1 #83, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_083_conv_depthwise_2d_square_input_asymmetric_kernel\"\nSOURCE_KB_ID = 83\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with a square input and an asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, in_channels, kernel_size=(kernel_size, 1), stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, in_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 8\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 0\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 16\nwidth = 256\nheight = 256\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel", "source_kb_id": 84, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel (KernelBench Level 1 #84, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_084_conv_depthwise_2d_asymmetric_input_square_kernel\"\nSOURCE_KB_ID = 84\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with asymmetric input and square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size), stride=stride, padding=padding, groups=in_channels, bias=bias)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height_in, width_in).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 64\nin_channels = 128\nout_channels = 128\nkernel_size = 3\nwidth_in = 512\nheight_in = 256\nstride = 1\npadding = 0\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 64\nwidth_in = 256\nheight_in = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height_in, width_in)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel", "source_kb_id": 85, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel (KernelBench Level 1 #85, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_085_conv_depthwise_2d_asymmetric_input_asymmetric_kernel\"\nSOURCE_KB_ID = 85\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise 2D convolution with asymmetric input and asymmetric kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size_h (int): Height of the convolution kernel.\n kernel_size_w (int): Width of the convolution kernel.\n stride_h (int, optional): Stride of the convolution in height dimension. Defaults to 1.\n stride_w (int, optional): Stride of the convolution in width dimension. Defaults to 1.\n padding_h (int, optional): Padding applied to the input in height dimension. Defaults to 0.\n padding_w (int, optional): Padding applied to the input in width dimension. Defaults to 0.\n dilation_h (int, optional): Spacing between kernel elements in height dimension. Defaults to 1.\n dilation_w (int, optional): Spacing between kernel elements in width dimension. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size_h: int, kernel_size_w: int, stride_h: int = 1, stride_w: int = 1, padding_h: int = 0, padding_w: int = 0, dilation_h: int = 1, dilation_w: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, in_channels, (kernel_size_h, kernel_size_w), stride=(stride_h, stride_w), padding=(padding_h, padding_w), dilation=(dilation_h, dilation_w), groups=in_channels, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 32\nin_channels = 128\nout_channels = 128\nkernel_size_h = 3\nkernel_size_w = 7\nwidth = 256\nheight = 128\nstride_h = 1\nstride_w = 1\npadding_h = 0\npadding_w = 0\ndilation_h = 1\ndilation_w = 1\ngroups = in_channels\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 64\ngroups = in_channels\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size_h, kernel_size_w, stride_h, stride_w, padding_h, padding_w, dilation_h, dilation_w, groups]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_086_conv_depthwise_separable_2d", "source_kb_id": 86, "category": "convolution", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_086_conv_depthwise_separable_2d (KernelBench Level 1 #86, split=train, category=convolution, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_086_conv_depthwise_separable_2d\"\nSOURCE_KB_ID = 86\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise-separable 2D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise-separable 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n x = self.depthwise(x)\n x = self.pointwise(x)\n return x\n\n# Test code\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 1\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_088_mingptnewgelu", "source_kb_id": 88, "category": "activation", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_088_mingptnewgelu (KernelBench Level 1 #88, split=train, category=activation, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_090_cumprod", "source_kb_id": 90, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_090_cumprod (KernelBench Level 1 #90, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_090_cumprod\"\nSOURCE_KB_ID = 90\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a cumulative product operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the cumulative product operation.\n \"\"\"\n\n def __init__(self, dim):\n \"\"\"\n Initialize the CumulativeProductModel.\n\n Args:\n dim (int): The dimension along which to perform the cumulative product.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n \"\"\"\n Forward pass, computing the cumulative product along the specified dimension.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, *input_shape).\n\n Returns:\n torch.Tensor: Tensor of the same shape as `x` after applying cumulative product along `dim`.\n \"\"\"\n return torch.cumprod(x, dim=self.dim)\n\n# Define input dimensions and parameters\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (1024,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_091_cumsum_reverse", "source_kb_id": 91, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_091_cumsum_reverse (KernelBench Level 1 #91, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_091_cumsum_reverse\"\nSOURCE_KB_ID = 91\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a reverse cumulative sum operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the reverse cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n return torch.cumsum(x.flip(self.dim), dim=self.dim).flip(self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_092_cumsum_exclusive", "source_kb_id": 92, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_092_cumsum_exclusive (KernelBench Level 1 #92, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_092_cumsum_exclusive\"\nSOURCE_KB_ID = 92\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs an exclusive cumulative sum (does not include the current element).\n\n Parameters:\n dim (int): The dimension along which to perform the exclusive cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n cumsum = torch.cumsum(x.narrow(dim=self.dim, start=0, length=x.size(self.dim)-1), dim=self.dim)\n return torch.cat((torch.zeros_like(x.select(self.dim, 0).unsqueeze(self.dim)), cumsum), dim=self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_093_masked_cumsum", "source_kb_id": 93, "category": "reduction_scan", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_093_masked_cumsum (KernelBench Level 1 #93, split=train, category=reduction_scan, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_093_masked_cumsum\"\nSOURCE_KB_ID = 93\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a masked cumulative sum, only summing elements that satisfy a condition.\n\n Parameters:\n dim (int): The dimension along which to perform the masked cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x, mask):\n \"\"\"\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, *input_shape).\n mask (torch.Tensor): Boolean mask of the same shape as x.\n\n Returns:\n torch.Tensor: Cumulative sum of elements where mask is True.\n \"\"\"\n return torch.cumsum(x * mask, dim=self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n x = torch.rand(batch_size, *input_shape)\n mask = torch.randint(0, 2, x.shape).bool() # Random boolean mask\n return [x, mask]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_096_huberloss", "source_kb_id": 96, "category": "loss_attention", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_096_huberloss (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_098_kldivloss", "source_kb_id": 98, "category": "loss_attention", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_098_kldivloss (KernelBench Level 1 #98, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_098_kldivloss\"\nSOURCE_KB_ID = 98\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Kullback-Leibler Divergence for comparing two distributions.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.kl_div(torch.log(predictions), targets, reduction='batchmean')\n\nbatch_size = 8192 * 2\ninput_shape = (8192 * 2,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [(torch.rand(batch_size, *input_shape)*scale).softmax(dim=-1), torch.rand(batch_size, *input_shape).softmax(dim=-1)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_099_tripletmarginloss", "source_kb_id": 99, "category": "loss_attention", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_099_tripletmarginloss (KernelBench Level 1 #99, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_099_tripletmarginloss\"\nSOURCE_KB_ID = 99\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Triplet Margin Loss for metric learning tasks.\n\n Parameters:\n margin (float): The margin between the positive and negative samples.\n \"\"\"\n def __init__(self, margin=1.0):\n super(Model, self).__init__()\n self.loss_fn = torch.nn.TripletMarginLoss(margin=margin)\n\n def forward(self, anchor, positive, negative):\n return self.loss_fn(anchor, positive, negative)\n\nbatch_size = 32768\ninput_shape = (8192,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape), torch.rand(batch_size, *input_shape)]\n \ndef get_init_inputs():\n return [1.0] # Default margin\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_100_hingeloss", "source_kb_id": 100, "category": "loss_attention", "dtype": "fp32", "variant": "base", "reference_code": "\"\"\"Task kb1_100_hingeloss (KernelBench Level 1 #100, split=train, category=loss_attention, dtype=fp32, variant=base).\"\"\"\nPROBLEM_ID = \"kb1_100_hingeloss\"\nSOURCE_KB_ID = 100\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"base\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Hinge Loss for binary classification tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.mean(torch.clamp(1 - predictions * targets, min=0))\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_002_standard_matrix_multiplication__bf16", "source_kb_id": 2, "category": "matmul", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication__bf16 (KernelBench Level 1 #2, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__bf16\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_006_matmul_with_large_k_dimension__bf16", "source_kb_id": 6, "category": "matmul", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_006_matmul_with_large_k_dimension__bf16 (KernelBench Level 1 #6, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension__bf16\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_016_matmul_with_transposed_a__bf16", "source_kb_id": 16, "category": "matmul", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_016_matmul_with_transposed_a__bf16 (KernelBench Level 1 #16, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a__bf16\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_018_matmul_with_transposed_both__bf16", "source_kb_id": 18, "category": "matmul", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_018_matmul_with_transposed_both__bf16 (KernelBench Level 1 #18, split=train, category=matmul, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_018_matmul_with_transposed_both__bf16\"\nSOURCE_KB_ID = 18\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B.T)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(N, K)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_020_leakyrelu__bf16", "source_kb_id": 20, "category": "activation", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_020_leakyrelu__bf16 (KernelBench Level 1 #20, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu__bf16\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_021_sigmoid__bf16", "source_kb_id": 21, "category": "activation", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_021_sigmoid__bf16 (KernelBench Level 1 #21, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid__bf16\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_024_logsoftmax__bf16", "source_kb_id": 24, "category": "activation", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_024_logsoftmax__bf16 (KernelBench Level 1 #24, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax__bf16\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_027_selu__bf16", "source_kb_id": 27, "category": "activation", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_027_selu__bf16 (KernelBench Level 1 #27, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_027_selu__bf16\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_033_batchnorm__bf16", "source_kb_id": 33, "category": "normalization", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_033_batchnorm__bf16 (KernelBench Level 1 #33, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm__bf16\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_035_groupnorm__bf16", "source_kb_id": 35, "category": "normalization", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_035_groupnorm__bf16 (KernelBench Level 1 #35, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm__bf16\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_039_l2norm__bf16", "source_kb_id": 39, "category": "normalization", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_039_l2norm__bf16 (KernelBench Level 1 #39, split=train, category=normalization, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm__bf16\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_048_mean_reduction_over_a_dimension__bf16", "source_kb_id": 48, "category": "reduction_scan", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_048_mean_reduction_over_a_dimension__bf16 (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension__bf16\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16", "source_kb_id": 55, "category": "convolution", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16 (KernelBench Level 1 #55, split=train, category=convolution, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_055_conv_standard_2d_asymmetric_input_square_kernel__bf16\"\nSOURCE_KB_ID = 55\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a standard 2D convolution operation with an asymmetric input and a square kernel.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the square convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv2d = nn.Conv2d(in_channels, out_channels, (kernel_size, kernel_size), stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n return self.conv2d(x)\n\n# Test code\nbatch_size = 8\n# smaller spatial dims\nheight = 512\nwidth = 1024\nin_channels = 64 # increased channels\nout_channels = 128\nkernel_size = 3\n# asymmetric input: make width considerably larger than height\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 4\nheight = 128\nwidth = 256\nin_channels = 32\nout_channels = 64\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_088_mingptnewgelu__bf16", "source_kb_id": 88, "category": "activation", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_088_mingptnewgelu__bf16 (KernelBench Level 1 #88, split=train, category=activation, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu__bf16\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_096_huberloss__bf16", "source_kb_id": 96, "category": "loss_attention", "dtype": "bf16", "variant": "bf16", "reference_code": "\"\"\"Task kb1_096_huberloss__bf16 (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=bf16, variant=bf16).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss__bf16\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"bf16\"\nVARIANT = \"bf16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_002_standard_matrix_multiplication__fp16", "source_kb_id": 2, "category": "matmul", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication__fp16 (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__fp16\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_005_matrix_scalar_multiplication__fp16", "source_kb_id": 5, "category": "matmul", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_005_matrix_scalar_multiplication__fp16 (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication__fp16\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_008_matmul_with_irregular_shapes__fp16", "source_kb_id": 8, "category": "matmul", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_008_matmul_with_irregular_shapes__fp16 (KernelBench Level 1 #8, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_008_matmul_with_irregular_shapes__fp16\"\nSOURCE_KB_ID = 8\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with irregular shapes\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor with shape (M, K).\n B: Input tensor with shape (K, N).\n\n Returns:\n C: Output tensor with shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 8205\nK = 2949\nN = 5921\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2051\nK = 1473\nN = 1973\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_010_3d_tensor_matrix_multiplication__fp16", "source_kb_id": 10, "category": "matmul", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_010_3d_tensor_matrix_multiplication__fp16 (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication__fp16\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_022_tanh__fp16", "source_kb_id": 22, "category": "activation", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_022_tanh__fp16 (KernelBench Level 1 #22, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh__fp16\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_028_hardsigmoid__fp16", "source_kb_id": 28, "category": "activation", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_028_hardsigmoid__fp16 (KernelBench Level 1 #28, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_028_hardsigmoid__fp16\"\nSOURCE_KB_ID = 28\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardSigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardSigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardSigmoid applied, same shape as input.\n \"\"\"\n return torch.nn.functional.hardsigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_029_softplus__fp16", "source_kb_id": 29, "category": "activation", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_029_softplus__fp16 (KernelBench Level 1 #29, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus__fp16\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_031_elu__fp16", "source_kb_id": 31, "category": "activation", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_031_elu__fp16 (KernelBench Level 1 #31, split=train, category=activation, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_031_elu__fp16\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_034_instancenorm__fp16", "source_kb_id": 34, "category": "normalization", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_034_instancenorm__fp16 (KernelBench Level 1 #34, split=train, category=normalization, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_034_instancenorm__fp16\"\nSOURCE_KB_ID = 34\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Instance Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the InstanceNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.inorm = nn.InstanceNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Instance Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, height, width).\n\n Returns:\n torch.Tensor: Output tensor with Instance Normalization applied, same shape as input.\n \"\"\"\n return self.inorm(x)\n\nbatch_size = 112 # heavier workload\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_038_l1norm__fp16", "source_kb_id": 38, "category": "normalization", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_038_l1norm__fp16 (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm__fp16\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_049_max_reduction_over_a_dimension__fp16", "source_kb_id": 49, "category": "reduction_scan", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_049_max_reduction_over_a_dimension__fp16 (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension__fp16\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_064_conv_transposed_1d__fp16", "source_kb_id": 64, "category": "convolution", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_064_conv_transposed_1d__fp16 (KernelBench Level 1 #64, split=train, category=convolution, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_064_conv_transposed_1d__fp16\"\nSOURCE_KB_ID = 64\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a transposed 1D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n output_padding (int, optional): Additional size added to one side of the output shape. Defaults to 0.\n groups (int, optional): Number of blocked connections from input channels to output channels. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.conv1d_transpose = nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the transposed 1D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, length).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, length_out).\n \"\"\"\n return self.conv1d_transpose(x)\n\n# Test code\nbatch_size = 64\nin_channels = 128\nout_channels = 128\nkernel_size = 3\n# much larger signal length for heavier workload\nlength = 65536\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nin_channels = 64\nout_channels = 64\nlength = 8192\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, length)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size] # Provide in_channels, out_channels, kernel_size for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_086_conv_depthwise_separable_2d__fp16", "source_kb_id": 86, "category": "convolution", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_086_conv_depthwise_separable_2d__fp16 (KernelBench Level 1 #86, split=train, category=convolution, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_086_conv_depthwise_separable_2d__fp16\"\nSOURCE_KB_ID = 86\nCATEGORY = \"convolution\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs a depthwise-separable 2D convolution operation.\n\n Args:\n in_channels (int): Number of channels in the input tensor.\n out_channels (int): Number of channels produced by the convolution.\n kernel_size (int): Size of the convolution kernel.\n stride (int, optional): Stride of the convolution. Defaults to 1.\n padding (int, optional): Padding applied to the input. Defaults to 0.\n dilation (int, optional): Spacing between kernel elements. Defaults to 1.\n bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.\n \"\"\"\n def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, dilation: int = 1, bias: bool = False):\n super(Model, self).__init__()\n self.depthwise = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=in_channels, bias=bias)\n self.pointwise = nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=bias)\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs the depthwise-separable 2D convolution.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).\n\n Returns:\n torch.Tensor: Output tensor of shape (batch_size, out_channels, height_out, width_out).\n \"\"\"\n x = self.depthwise(x)\n x = self.pointwise(x)\n return x\n\n# Test code\nbatch_size = 16\nin_channels = 64\nout_channels = 128\nkernel_size = 3\nwidth = 512\nheight = 512\nstride = 1\npadding = 1\ndilation = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 8\nin_channels = 64\nout_channels = 128\nwidth = 128\nheight = 128\n\ndef get_inputs():\n x = torch.rand(batch_size, in_channels, height, width)\n return [x]\n\ndef get_init_inputs():\n return [in_channels, out_channels, kernel_size, stride, padding, dilation]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_098_kldivloss__fp16", "source_kb_id": 98, "category": "loss_attention", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_098_kldivloss__fp16 (KernelBench Level 1 #98, split=train, category=loss_attention, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_098_kldivloss__fp16\"\nSOURCE_KB_ID = 98\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Kullback-Leibler Divergence for comparing two distributions.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.kl_div(torch.log(predictions), targets, reduction='batchmean')\n\nbatch_size = 8192 * 2\ninput_shape = (8192 * 2,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [(torch.rand(batch_size, *input_shape)*scale).softmax(dim=-1), torch.rand(batch_size, *input_shape).softmax(dim=-1)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_100_hingeloss__fp16", "source_kb_id": 100, "category": "loss_attention", "dtype": "fp16", "variant": "fp16", "reference_code": "\"\"\"Task kb1_100_hingeloss__fp16 (KernelBench Level 1 #100, split=train, category=loss_attention, dtype=fp16, variant=fp16).\"\"\"\nPROBLEM_ID = \"kb1_100_hingeloss__fp16\"\nSOURCE_KB_ID = 100\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp16\"\nVARIANT = \"fp16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Hinge Loss for binary classification tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.mean(torch.clamp(1 - predictions * targets, min=0))\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape), torch.randint(0, 2, (batch_size,)).float() * 2 - 1]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_002_standard_matrix_multiplication__shape_nonpow2", "source_kb_id": 2, "category": "matmul", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_002_standard_matrix_multiplication__shape_nonpow2 (KernelBench Level 1 #2, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_002_standard_matrix_multiplication__shape_nonpow2\"\nSOURCE_KB_ID = 2\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\nM = 768\nK = 1536\nN = 1280\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_004_matrix_vector_multiplication__shape_wide", "source_kb_id": 4, "category": "matmul", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_004_matrix_vector_multiplication__shape_wide (KernelBench Level 1 #4, split=train, category=matmul, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_004_matrix_vector_multiplication__shape_wide\"\nSOURCE_KB_ID = 4\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs matrix-vector multiplication (C = A * B).\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix-vector multiplication.\n\n Args:\n A: Input matrix of shape (M, K).\n B: Input vector of shape (K, 1).\n\n Returns:\n Output vector of shape (M, 1).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256 * 8 # 2048\nK = 131072 * 8 # 1048576\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 16384\nM = 512\nK = 32768\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, 1)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_005_matrix_scalar_multiplication__shape_nonpow2", "source_kb_id": 5, "category": "matmul", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_005_matrix_scalar_multiplication__shape_nonpow2 (KernelBench Level 1 #5, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_005_matrix_scalar_multiplication__shape_nonpow2\"\nSOURCE_KB_ID = 5\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix-scalar multiplication (C = A * s)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, s: float) -> torch.Tensor:\n \"\"\"\n Performs matrix-scalar multiplication.\n\n Args:\n A: Input matrix of shape (M, N)\n s: Scalar value\n\n Returns:\n C: Resulting matrix of shape (M, N)\n \"\"\"\n return A * s\n\nM = 16384 * 4\nN = 4096 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nM = 3000\nN = 2500\n\ndef get_inputs():\n A = torch.rand(M, N)\n s = 3.14\n return [A, s]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_006_matmul_with_large_k_dimension__shape_tall", "source_kb_id": 6, "category": "matmul", "dtype": "fp32", "variant": "shape_tall", "reference_code": "\"\"\"Task kb1_006_matmul_with_large_k_dimension__shape_tall (KernelBench Level 1 #6, split=train, category=matmul, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_006_matmul_with_large_k_dimension__shape_tall\"\nSOURCE_KB_ID = 6\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a large K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication of A and B.\n\n Args:\n A: Input tensor of shape (M, K)\n B: Input tensor of shape (K, N)\n\n Returns:\n Output tensor of shape (M, N)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 256\nN = 256\nK = 131072 * 4\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 256\nN = 256\nK = 32768\nM = 512\nN = 128\nK = 16384\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_007_matmul_with_small_k_dimension__shape_rect", "source_kb_id": 7, "category": "matmul", "dtype": "fp32", "variant": "shape_rect", "reference_code": "\"\"\"Task kb1_007_matmul_with_small_k_dimension__shape_rect (KernelBench Level 1 #7, split=train, category=matmul, dtype=fp32, variant=shape_rect).\"\"\"\nPROBLEM_ID = \"kb1_007_matmul_with_small_k_dimension__shape_rect\"\nSOURCE_KB_ID = 7\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_rect\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with a small K dimension\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16384 * 2\nK = 32 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 4096\nN = 4096\nK = 64\nM = 2048\nN = 3072\nK = 48\n\ndef get_inputs():\n A = torch.rand(M, K)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_009_tall_skinny_matrix_multiplication__shape_skinny", "source_kb_id": 9, "category": "matmul", "dtype": "fp32", "variant": "shape_skinny", "reference_code": "\"\"\"Task kb1_009_tall_skinny_matrix_multiplication__shape_skinny (KernelBench Level 1 #9, split=train, category=matmul, dtype=fp32, variant=shape_skinny).\"\"\"\nPROBLEM_ID = \"kb1_009_tall_skinny_matrix_multiplication__shape_skinny\"\nSOURCE_KB_ID = 9\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_skinny\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) where one of the matrices is tall and skinny (M >> N or N >> M)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): Input matrix of shape (M, K) or (K, M) where M >> N or N >> M.\n B (torch.Tensor): Input matrix of shape (K, N) or (N, K) where M >> N or N >> M.\n\n Returns:\n torch.Tensor: Output matrix of shape (M, N) or (N, M)\n \"\"\"\n return torch.matmul(A, B)\n\nM = 16384 * 2\nN = 16 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 8192\nN = 64\nM = 4096\nN = 32\n\ndef get_inputs():\n A = torch.rand(M, N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_010_3d_tensor_matrix_multiplication__shape_large_batch", "source_kb_id": 10, "category": "matmul", "dtype": "fp32", "variant": "shape_large_batch", "reference_code": "\"\"\"Task kb1_010_3d_tensor_matrix_multiplication__shape_large_batch (KernelBench Level 1 #10, split=train, category=matmul, dtype=fp32, variant=shape_large_batch).\"\"\"\nPROBLEM_ID = \"kb1_010_3d_tensor_matrix_multiplication__shape_large_batch\"\nSOURCE_KB_ID = 10\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_batch\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs 3D tensor-matrix multiplication.\n\n Args:\n A (torch.Tensor): Input 3D tensor of shape (N, M, K).\n B (torch.Tensor): Input matrix of shape (K, L).\n\n Returns:\n torch.Tensor: Output tensor of shape (N, M, L), resulting from the multiplication of A and B along the last dimension of A.\n \"\"\"\n return torch.matmul(A, B)\n\nN = 16\nM = 1024\nK = 2048\nL = 768\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 16\nM = 512\nK = 1024\nL = 512\nN = 32\nM = 256\nK = 512\nL = 768\n\ndef get_inputs():\n A = torch.rand(N, M, K)\n B = torch.rand(K, L)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_012_matmul_with_diagonal_matrices__shape_rect", "source_kb_id": 12, "category": "matmul", "dtype": "fp32", "variant": "shape_rect", "reference_code": "\"\"\"Task kb1_012_matmul_with_diagonal_matrices__shape_rect (KernelBench Level 1 #12, split=train, category=matmul, dtype=fp32, variant=shape_rect).\"\"\"\nPROBLEM_ID = \"kb1_012_matmul_with_diagonal_matrices__shape_rect\"\nSOURCE_KB_ID = 12\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_rect\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a matrix multiplication of a diagonal matrix with another matrix.\n C = diag(A) * B\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs the matrix multiplication.\n\n Args:\n A (torch.Tensor): A 1D tensor representing the diagonal of the diagonal matrix. Shape: (N,).\n B (torch.Tensor): A 2D tensor representing the second matrix. Shape: (N, M).\n\n Returns:\n torch.Tensor: The result of the matrix multiplication. Shape: (N, M).\n \"\"\"\n # Logically equivalent to torch.diag(A) @ B \n # more efficient as no need to materialize a full N\u00d7N matrix\n return A.unsqueeze(1) * B\n\nM = 4096\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 2048\nN = 2048\nM = 1536\nN = 3072\n\ndef get_inputs():\n A = torch.rand(N)\n B = torch.rand(N, M)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_013_matmul_for_symmetric_matrices__shape_small", "source_kb_id": 13, "category": "matmul", "dtype": "fp32", "variant": "shape_small", "reference_code": "\"\"\"Task kb1_013_matmul_for_symmetric_matrices__shape_small (KernelBench Level 1 #13, split=train, category=matmul, dtype=fp32, variant=shape_small).\"\"\"\nPROBLEM_ID = \"kb1_013_matmul_for_symmetric_matrices__shape_small\"\nSOURCE_KB_ID = 13\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_small\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B) with A and B being symmetric matrices.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A, B):\n \"\"\"\n Performs matrix multiplication of two symmetric matrices.\n\n Args:\n A (torch.Tensor): Input matrix A, shape (N, N), symmetric.\n B (torch.Tensor): Input matrix B, shape (N, N), symmetric.\n\n Returns:\n torch.Tensor: Output matrix C, shape (N, N).\n \"\"\"\n return torch.matmul(A, B)\n\nN = 4096\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nN = 1024\nN = 768\n\ndef get_inputs():\n \"\"\"\n Generates a pair of random symmetric matrices for testing.\n\n Returns:\n list: List containing two symmetric tensors A and B.\n \"\"\"\n A = torch.rand(N, N)\n A = (A + A.T) / 2 # Ensure symmetry\n B = torch.rand(N, N)\n B = (B + B.T) / 2 # Ensure symmetry\n return [A, B]\n\ndef get_init_inputs():\n \"\"\"\n No specific initialization inputs needed for this model.\n\n Returns:\n list: Empty list.\n \"\"\"\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_016_matmul_with_transposed_a__shape_nonpow2", "source_kb_id": 16, "category": "matmul", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_016_matmul_with_transposed_a__shape_nonpow2 (KernelBench Level 1 #16, split=train, category=matmul, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_016_matmul_with_transposed_a__shape_nonpow2\"\nSOURCE_KB_ID = 16\nCATEGORY = \"matmul\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a single matrix multiplication (C = A * B)\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, A: torch.Tensor, B: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Performs matrix multiplication.\n\n Args:\n A: Input tensor of shape (M, K).\n B: Input tensor of shape (K, N).\n\n Returns:\n Output tensor of shape (M, N).\n \"\"\"\n return torch.matmul(A.T, B)\n\nM = 1024 * 2\nK = 4096 * 2\nN = 2048 * 2\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nM = 1024\nK = 2048\nN = 1024\nM = 1536\nK = 1024\nN = 768\n\ndef get_inputs():\n A = torch.rand(K, M)\n B = torch.rand(K, N)\n return [A, B]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_020_leakyrelu__shape_wide", "source_kb_id": 20, "category": "activation", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_020_leakyrelu__shape_wide (KernelBench Level 1 #20, split=train, category=activation, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_020_leakyrelu__shape_wide\"\nSOURCE_KB_ID = 20\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LeakyReLU activation.\n \"\"\"\n def __init__(self, negative_slope: float = 0.01):\n \"\"\"\n Initializes the LeakyReLU module.\n\n Args:\n negative_slope (float, optional): The negative slope of the activation function. Defaults to 0.01.\n \"\"\"\n super(Model, self).__init__()\n self.negative_slope = negative_slope\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LeakyReLU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with LeakyReLU applied, same shape as input.\n \"\"\"\n return torch.nn.functional.leaky_relu(x, negative_slope=self.negative_slope)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 512\ndim = 12288\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_021_sigmoid__shape_nonpow2", "source_kb_id": 21, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_021_sigmoid__shape_nonpow2 (KernelBench Level 1 #21, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_021_sigmoid__shape_nonpow2\"\nSOURCE_KB_ID = 21\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Sigmoid activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Sigmoid activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Sigmoid applied, same shape as input.\n \"\"\"\n return torch.sigmoid(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1500\ndim = 3000\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_022_tanh__shape_tall", "source_kb_id": 22, "category": "activation", "dtype": "fp32", "variant": "shape_tall", "reference_code": "\"\"\"Task kb1_022_tanh__shape_tall (KernelBench Level 1 #22, split=train, category=activation, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_022_tanh__shape_tall\"\nSOURCE_KB_ID = 22\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Tanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Tanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Tanh applied, same shape as input.\n \"\"\"\n return torch.tanh(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 8192\ndim = 1024\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_024_logsoftmax__shape_vocab", "source_kb_id": 24, "category": "activation", "dtype": "fp32", "variant": "shape_vocab", "reference_code": "\"\"\"Task kb1_024_logsoftmax__shape_vocab (KernelBench Level 1 #24, split=train, category=activation, dtype=fp32, variant=shape_vocab).\"\"\"\nPROBLEM_ID = \"kb1_024_logsoftmax__shape_vocab\"\nSOURCE_KB_ID = 24\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_vocab\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a LogSoftmax activation.\n \"\"\"\n def __init__(self, dim: int = 1):\n super(Model, self).__init__()\n self.dim = dim\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies LogSoftmax activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, dim).\n\n Returns:\n torch.Tensor: Output tensor with LogSoftmax applied, same shape as input.\n \"\"\"\n return torch.log_softmax(x, dim=self.dim)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 512\ndim = 16384\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_027_selu__shape_nonpow2", "source_kb_id": 27, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_027_selu__shape_nonpow2 (KernelBench Level 1 #27, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_027_selu__shape_nonpow2\"\nSOURCE_KB_ID = 27\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a SELU activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies SELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with SELU applied, same shape as input.\n \"\"\"\n return torch.selu(x)\n \nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 6144\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_029_softplus__shape_wide", "source_kb_id": 29, "category": "activation", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_029_softplus__shape_wide (KernelBench Level 1 #29, split=train, category=activation, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_029_softplus__shape_wide\"\nSOURCE_KB_ID = 29\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softplus activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softplus activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softplus applied, same shape as input.\n \"\"\"\n return torch.nn.functional.softplus(x)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 8192\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_030_softsign__shape_nonpow2", "source_kb_id": 30, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_030_softsign__shape_nonpow2 (KernelBench Level 1 #30, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_030_softsign__shape_nonpow2\"\nSOURCE_KB_ID = 30\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a Softsign activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Softsign activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with Softsign applied, same shape as input.\n \"\"\"\n return x / (1 + torch.abs(x))\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 3000\ndim = 2000\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_031_elu__shape_tall", "source_kb_id": 31, "category": "activation", "dtype": "fp32", "variant": "shape_tall", "reference_code": "\"\"\"Task kb1_031_elu__shape_tall (KernelBench Level 1 #31, split=train, category=activation, dtype=fp32, variant=shape_tall).\"\"\"\nPROBLEM_ID = \"kb1_031_elu__shape_tall\"\nSOURCE_KB_ID = 31\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_tall\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs an ELU activation.\n \"\"\"\n def __init__(self, alpha: float = 1.0):\n \"\"\"\n Initializes the ELU model.\n\n Args:\n alpha (float, optional): The alpha parameter for the ELU function. Defaults to 1.0.\n \"\"\"\n super(Model, self).__init__()\n self.alpha = alpha\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies ELU activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with ELU applied, same shape as input.\n \"\"\"\n return F.elu(x, alpha=self.alpha)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 4096\ndim = 2048\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [1.0] # Provide alpha value for initialization\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_032_hardtanh__shape_nonpow2", "source_kb_id": 32, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_032_hardtanh__shape_nonpow2 (KernelBench Level 1 #32, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_032_hardtanh__shape_nonpow2\"\nSOURCE_KB_ID = 32\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs a HardTanh activation.\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies HardTanh activation to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of any shape.\n\n Returns:\n torch.Tensor: Output tensor with HardTanh applied, same shape as input.\n \"\"\"\n return F.hardtanh(x, min_val=-1., max_val=1.)\n\nbatch_size = 4096\ndim = 393216\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 2500\ndim = 3072\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return [] # No special initialization inputs needed\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_033_batchnorm__shape_spatial", "source_kb_id": 33, "category": "normalization", "dtype": "fp32", "variant": "shape_spatial", "reference_code": "\"\"\"Task kb1_033_batchnorm__shape_spatial (KernelBench Level 1 #33, split=train, category=normalization, dtype=fp32, variant=shape_spatial).\"\"\"\nPROBLEM_ID = \"kb1_033_batchnorm__shape_spatial\"\nSOURCE_KB_ID = 33\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_spatial\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Batch Normalization.\n \"\"\"\n def __init__(self, num_features: int):\n \"\"\"\n Initializes the BatchNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n \"\"\"\n super(Model, self).__init__()\n self.bn = nn.BatchNorm2d(num_features=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Batch Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Batch Normalization applied, same shape as input.\n \"\"\"\n return self.bn(x)\n\nbatch_size = 64\nfeatures = 64\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\ndim1 = 128\ndim2 = 128\nbatch_size = 8\nfeatures = 128\ndim1 = 64\ndim2 = 64\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_035_groupnorm__shape_groups16", "source_kb_id": 35, "category": "normalization", "dtype": "fp32", "variant": "shape_groups16", "reference_code": "\"\"\"Task kb1_035_groupnorm__shape_groups16 (KernelBench Level 1 #35, split=train, category=normalization, dtype=fp32, variant=shape_groups16).\"\"\"\nPROBLEM_ID = \"kb1_035_groupnorm__shape_groups16\"\nSOURCE_KB_ID = 35\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_groups16\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Group Normalization.\n \"\"\"\n def __init__(self, num_features: int, num_groups: int):\n \"\"\"\n Initializes the GroupNorm layer.\n\n Args:\n num_features (int): Number of features in the input tensor.\n num_groups (int): Number of groups to divide the channels into.\n \"\"\"\n super(Model, self).__init__()\n self.gn = nn.GroupNorm(num_groups=num_groups, num_channels=num_features)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Group Normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (batch_size, num_features, *).\n\n Returns:\n torch.Tensor: Output tensor with Group Normalization applied, same shape as input.\n \"\"\"\n return self.gn(x)\n\nbatch_size = 112 # scaled up\nfeatures = 64\nnum_groups = 8\ndim1 = 512\ndim2 = 512\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 16\nfeatures = 64\nnum_groups = 8\ndim1 = 128\ndim2 = 128\nbatch_size = 8\nfeatures = 128\nnum_groups = 16\ndim1 = 64\ndim2 = 64\n\ndef get_inputs():\n x = torch.randn(batch_size, features, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [features, num_groups] # num_features\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_038_l1norm__shape_nonpow2", "source_kb_id": 38, "category": "normalization", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_038_l1norm__shape_nonpow2 (KernelBench Level 1 #38, split=train, category=normalization, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_038_l1norm__shape_nonpow2\"\nSOURCE_KB_ID = 38\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L1 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L1 normalization layer.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L1 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (..., dim, ...).\n\n Returns:\n torch.Tensor: Output tensor with L1 normalization applied, same shape as input.\n \"\"\"\n return x / torch.mean(torch.abs(x), dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1536\ndim = 5120\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_039_l2norm__shape_wide", "source_kb_id": 39, "category": "normalization", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_039_l2norm__shape_wide (KernelBench Level 1 #39, split=train, category=normalization, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_039_l2norm__shape_wide\"\nSOURCE_KB_ID = 39\nCATEGORY = \"normalization\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs L2 normalization.\n \"\"\"\n def __init__(self):\n \"\"\"\n Initializes the L2Norm layer.\n\n Args:\n dim (int): Dimension along which to normalize.\n \"\"\"\n super(Model, self).__init__()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies L2 normalization to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor of shape (*, dim, *).\n\n Returns:\n torch.Tensor: Output tensor with L2 normalization applied, same shape as input.\n \"\"\"\n return x / torch.norm(x, p=2, dim=1, keepdim=True)\n\nbatch_size = 32768\n# choose dim so total <2^31\ndim = 65535\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1024\ndim = 8192\n\ndef get_inputs():\n x = torch.randn(batch_size, dim)\n return [x]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_048_mean_reduction_over_a_dimension__shape_large_reduce", "source_kb_id": 48, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_large_reduce", "reference_code": "\"\"\"Task kb1_048_mean_reduction_over_a_dimension__shape_large_reduce (KernelBench Level 1 #48, split=train, category=reduction_scan, dtype=fp32, variant=shape_large_reduce).\"\"\"\nPROBLEM_ID = \"kb1_048_mean_reduction_over_a_dimension__shape_large_reduce\"\nSOURCE_KB_ID = 48\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_reduce\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs mean reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Reduces the input tensor along the specified dimension by taking the mean.\n\n Args:\n x (torch.Tensor): Input tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Output tensor with reduced dimension. The shape of the output is the same as the input except for the reduced dimension which is removed.\n \"\"\"\n return torch.mean(x, dim=self.dim)\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 64\ndim1 = 256\ndim2 = 1023\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_049_max_reduction_over_a_dimension__shape_large_reduce", "source_kb_id": 49, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_large_reduce", "reference_code": "\"\"\"Task kb1_049_max_reduction_over_a_dimension__shape_large_reduce (KernelBench Level 1 #49, split=train, category=reduction_scan, dtype=fp32, variant=shape_large_reduce).\"\"\"\nPROBLEM_ID = \"kb1_049_max_reduction_over_a_dimension__shape_large_reduce\"\nSOURCE_KB_ID = 49\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_large_reduce\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs Max reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies Max reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after Max reduction over the specified dimension.\n \"\"\"\n return torch.max(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 64\ndim1 = 256\ndim2 = 1023\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_053_min_reduction_over_a_dimension__shape_nonpow2", "source_kb_id": 53, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_053_min_reduction_over_a_dimension__shape_nonpow2 (KernelBench Level 1 #53, split=train, category=reduction_scan, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_053_min_reduction_over_a_dimension__shape_nonpow2\"\nSOURCE_KB_ID = 53\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n Simple model that performs min reduction over a specific dimension.\n \"\"\"\n def __init__(self, dim: int):\n \"\"\"\n Initializes the model with the dimension to reduce over.\n\n Args:\n dim (int): The dimension to reduce over.\n \"\"\"\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Applies min reduction over the specified dimension to the input tensor.\n\n Args:\n x (torch.Tensor): Input tensor.\n\n Returns:\n torch.Tensor: Output tensor after min reduction over the specified dimension.\n \"\"\"\n return torch.min(x, dim=self.dim)[0]\n\nbatch_size = 128\ndim1 = 4096\ndim2 = 4095\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 32\ndim1 = 512\ndim2 = 511\nbatch_size = 48\ndim1 = 384\ndim2 = 768\n\ndef get_inputs():\n x = torch.randn(batch_size, dim1, dim2)\n return [x]\n\ndef get_init_inputs():\n return [1] # Example, change to desired dimension\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_088_mingptnewgelu__shape_nonpow2", "source_kb_id": 88, "category": "activation", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_088_mingptnewgelu__shape_nonpow2 (KernelBench Level 1 #88, split=train, category=activation, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_088_mingptnewgelu__shape_nonpow2\"\nSOURCE_KB_ID = 88\nCATEGORY = \"activation\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport math\n\n# From https://github.com/karpathy/minGPT/blob/master/mingpt/model.py\n\nclass Model(nn.Module):\n \"\"\"\n Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT).\n Reference: Gaussian Error Linear Units (GELU) paper: https://arxiv.org/abs/1606.08415\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n \n def forward(self, x):\n return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))\n\nbatch_size = 8192\ndim = 8192\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ndim = 4096\nbatch_size = 1536\ndim = 5120\n\ndef get_inputs():\n return [torch.randn(batch_size, dim)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_091_cumsum_reverse__shape_wide", "source_kb_id": 91, "category": "reduction_scan", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_091_cumsum_reverse__shape_wide (KernelBench Level 1 #91, split=train, category=reduction_scan, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_091_cumsum_reverse__shape_wide\"\nSOURCE_KB_ID = 91\nCATEGORY = \"reduction_scan\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that performs a reverse cumulative sum operation along a specified dimension.\n\n Parameters:\n dim (int): The dimension along which to perform the reverse cumulative sum.\n \"\"\"\n\n def __init__(self, dim):\n super(Model, self).__init__()\n self.dim = dim\n\n def forward(self, x):\n return torch.cumsum(x.flip(self.dim), dim=self.dim).flip(self.dim)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\nbatch_size = 1024\ninput_shape = (4096,)\n\ndef get_inputs():\n return [torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return [dim]\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_096_huberloss__shape_nonpow2", "source_kb_id": 96, "category": "loss_attention", "dtype": "fp32", "variant": "shape_nonpow2", "reference_code": "\"\"\"Task kb1_096_huberloss__shape_nonpow2 (KernelBench Level 1 #96, split=train, category=loss_attention, dtype=fp32, variant=shape_nonpow2).\"\"\"\nPROBLEM_ID = \"kb1_096_huberloss__shape_nonpow2\"\nSOURCE_KB_ID = 96\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_nonpow2\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Smooth L1 (Huber) Loss for regression tasks.\n\n Parameters:\n None\n \"\"\"\n def __init__(self):\n super(Model, self).__init__()\n\n def forward(self, predictions, targets):\n return torch.nn.functional.smooth_l1_loss(predictions, targets)\n\nbatch_size = 32768\ninput_shape = (32768,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (4096,)\nbatch_size = 1500\ninput_shape = (3000,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape)]\n\ndef get_init_inputs():\n return []\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"} +{"problem_id": "kb1_099_tripletmarginloss__shape_wide", "source_kb_id": 99, "category": "loss_attention", "dtype": "fp32", "variant": "shape_wide", "reference_code": "\"\"\"Task kb1_099_tripletmarginloss__shape_wide (KernelBench Level 1 #99, split=train, category=loss_attention, dtype=fp32, variant=shape_wide).\"\"\"\nPROBLEM_ID = \"kb1_099_tripletmarginloss__shape_wide\"\nSOURCE_KB_ID = 99\nCATEGORY = \"loss_attention\"\nSPLIT = \"train\"\nDTYPE = \"fp32\"\nVARIANT = \"shape_wide\"\n\nimport torch\nimport torch.nn as nn\n\nclass Model(nn.Module):\n \"\"\"\n A model that computes Triplet Margin Loss for metric learning tasks.\n\n Parameters:\n margin (float): The margin between the positive and negative samples.\n \"\"\"\n def __init__(self, margin=1.0):\n super(Model, self).__init__()\n self.loss_fn = torch.nn.TripletMarginLoss(margin=margin)\n\n def forward(self, anchor, positive, negative):\n return self.loss_fn(anchor, positive, negative)\n\nbatch_size = 32768\ninput_shape = (8192,)\ndim = 1\n\n# --- Task shape configuration (4GB-safe laptop envelope) ---\nbatch_size = 2048\ninput_shape = (2048,)\nbatch_size = 1024\ninput_shape = (4096,)\n\ndef get_inputs():\n scale = torch.rand(())\n return [torch.rand(batch_size, *input_shape)*scale, torch.rand(batch_size, *input_shape), torch.rand(batch_size, *input_shape)]\n \ndef get_init_inputs():\n return [1.0] # Default margin\nif __name__ == \"__main__\":\n import sys\n from pathlib import Path\n sys.path.insert(0, str(Path(__file__).resolve().parents[2]))\n from verifier import verify_kernel, format_result\n res = verify_kernel(None, __file__, self_check=True)\n print(format_result(res))\n sys.exit(0 if res[\"status\"] == \"PASS\" else 1)\n"}