compile_fail
3_mistralai-Mistral-7B-v0.1.py
model
Llama-4-Maverick-17B-128E-Instruct-FP8
started
2026-05-11T08:39:39Z
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 = "mistralai/Mistral-7B-v0.1"
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 015.0s turn · 3.8s LLM · 11.2s tools · tokens in=959 · out=399 · total=1,358 · 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 my_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\n''' # End of cuda_source string\n\n# Load the CUDA kernel\nmy_cuda_module = load_inline(\n name='my_cuda_module',\n cuda_sources=[cuda_source],\n functions=['my_kernel']\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.vocab_size = config.vocab_size\n\n def forward(self, x):\n batch_size, sequence_length = x.shape\n output = torch.empty(batch_size, sequence_length, dtype=torch.float32, device=x.device)\n my_cuda_module.my_kernel(output, x, self.vocab_size, sequence_length, batch_size, block=(256, 1, 1), grid=((batch_size * sequence_length + 255) // 256, 1, 1))\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 (41 lines, 1,316 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 my_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;
}
}
}
''' # End of cuda_source string
# Load the CUDA kernel
my_cuda_module = load_inline(
name='my_cuda_module',
cuda_sources=[cuda_source],
functions=['my_kernel']
)
class ModelNew(torch.nn.Module):
def __init__(self, model_name, config):
super().__init__()
self.model_name = model_name
self.config = config
self.vocab_size = config.vocab_size
def forward(self, x):
batch_size, sequence_length = x.shape
output = torch.empty(batch_size, sequence_length, dtype=torch.float32, device=x.device)
my_cuda_module.my_kernel(output, x, self.vocab_size, sequence_length, batch_size, block=(256, 1, 1), grid=((batch_size * sequence_length + 255) // 256, 1, 1))
return output