compile_fail
15_EleutherAI-pythia-1.4b.py
model
Llama-4-Maverick-17B-128E-Instruct-FP8
started
2026-05-11T08:40:40Z
compile error: load_inline() missing 1 required positional argument: 'cpp_sources'
timingkernelbench.timing
kernel mean / median / std
—
reference PyTorch source (the prompt the agent sees)
import torch
from transformers import AutoConfig, AutoModelForCausalLM
class Model(torch.nn.Module):
def __init__(self, model_name, config):
super().__init__()
self.model_name = model_name
self.config = config
self.model = AutoModelForCausalLM.from_pretrained(self.model_name, config=self.config)
def forward(self, x):
return self.model(x).logits
model_name = "EleutherAI/pythia-1.4b"
config = AutoConfig.from_pretrained(model_name)
vocab_size = config.vocab_size
sequence_length = 512
batch_size = 8
def get_inputs():
p = popcorn_pri
bs = p.jitter_int(batch_size)
sl = p.jitter_int(sequence_length)
inputs = torch.randint(0, vocab_size, (bs, sl))
return [inputs]
def get_init_inputs():
return [model_name, config]
turn 039.2s turn · 3.5s LLM · 35.8s tools · tokens in=957 · out=476 · total=1,433 · FINAL
call → submit_kernel
callsubmit_kernel
{
"kernel_code": "import torch\nfrom torch.utils.cpp_extension import load_inline\n\n# Define the CUDA kernel\ncuda_source = '''\n#include <cuda_runtime.h>\n#include <cuda_fp16.h>\n\n__global__ void custom_kernel(float *output, int *input, int vocab_size, int sequence_length, int batch_size) {\n int idx = blockIdx.x * blockDim.x + threadIdx.x;\n if (idx < batch_size * sequence_length) {\n int input_val = input[idx];\n if (input_val >= 0 && input_val < vocab_size) {\n output[idx] = (float)input_val;\n } else {\n output[idx] = 0.0f;\n }\n }\n}\n\nvoid wrapper_function(torch::Tensor output, torch::Tensor input, int vocab_size, int sequence_length, int batch_size) {\n int blockSize = 256;\n int numBlocks = (batch_size * sequence_length + blockSize - 1) / blockSize;\n custom_kernel<<<numBlocks, blockSize>>>(output.data_ptr<float>(), input.data_ptr<int>(), vocab_size, sequence_length, batch_size);\n}\n'''\n\n# Compile the CUDA kernel\ncustom_kernel_module = load_inline(\n name='custom_kernel_module',\n cuda_sources=[cuda_source],\n functions=['wrapper_function'],\n extra_cuda_cflags=['-O3']\n)\n\nclass ModelNew(torch.nn.Module):\n def __init__(self, model_name, config):\n super().__init__()\n self.model_name = model_name\n self.config = config\n self.model = torch.nn.Embedding(config.vocab_size, config.hidden_size)\n\n def forward(self, x):\n output = torch.empty(x.size(0), x.size(1), self.config.hidden_size, dtype=torch.float32, device=x.device)\n custom_kernel_module.wrapper_function(output, x, self.config.vocab_size, x.size(1), x.size(0))\n return output"
}
result ← submit_kernel (fail)
failsubmit_kernel
submit_kernel FAILED: kernel did not compile.
load_inline() missing 1 required positional argument: 'cpp_sources'
final submitted kernel (46 lines, 1,649 chars) — full source, untruncated
import torch
from torch.utils.cpp_extension import load_inline
# Define the CUDA kernel
cuda_source = '''
#include <cuda_runtime.h>
#include <cuda_fp16.h>
__global__ void custom_kernel(float *output, int *input, int vocab_size, int sequence_length, int batch_size) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < batch_size * sequence_length) {
int input_val = input[idx];
if (input_val >= 0 && input_val < vocab_size) {
output[idx] = (float)input_val;
} else {
output[idx] = 0.0f;
}
}
}
void wrapper_function(torch::Tensor output, torch::Tensor input, int vocab_size, int sequence_length, int batch_size) {
int blockSize = 256;
int numBlocks = (batch_size * sequence_length + blockSize - 1) / blockSize;
custom_kernel<<<numBlocks, blockSize>>>(output.data_ptr<float>(), input.data_ptr<int>(), vocab_size, sequence_length, batch_size);
}
'''
# Compile the CUDA kernel
custom_kernel_module = load_inline(
name='custom_kernel_module',
cuda_sources=[cuda_source],
functions=['wrapper_function'],
extra_cuda_cflags=['-O3']
)
class ModelNew(torch.nn.Module):
def __init__(self, model_name, config):
super().__init__()
self.model_name = model_name
self.config = config
self.model = torch.nn.Embedding(config.vocab_size, config.hidden_size)
def forward(self, x):
output = torch.empty(x.size(0), x.size(1), self.config.hidden_size, dtype=torch.float32, device=x.device)
custom_kernel_module.wrapper_function(output, x, self.config.vocab_size, x.size(1), x.size(0))
return output