Large language model (LLM) inference systems rely on CUDA kernels for core GPU computations, yet the interface between models and kernels is implicit and poorly specified. Models and kernels evolve independently and often make incompatible assumptions about tensor shapes and input sizes, leading to subtle memory bugs in CUDA kernels. These bugs can crash inference services, corrupt model weights, or be exploited by remote adversaries. Existing techniques either incur prohibitive runtime overhead, require specialized hardware, or fail to handle dynamic tensor shapes and variable kernel launch configurations, leaving the CUDA memory bugs largely unaddressed. This paper presents M2K, a fully automated framework that makes the model-kernel interface explicit and leverages it to detect memory bugs in CUDA kernels used in LLM inference systems. M2K consists of two components. HFProbe traces model execution without GPU hardware, classifies kernel arguments into model-fixed and user-variable, and emits symbolic constraints that capture the interface. cuKLEE then performs symbolic execution on CUDA kernels to pinpoint memory bugs under the interface constraints, modeling tensors as disjoint memory regions and treating thread identifiers symbolically to scale to thousands of threads. In the evaluation, M2K discovers 181 previously unknown bugs in real LLM inference systems, while producing only nine false positives, demonstrating its effectiveness.
Figures & tables
Figure 1. An overview of M2K.
Figure 2. A CUDA kernel example, its wrapper function, its registration to vLLM, and a Hugging Face model using the kernel.
Dimension
Breakdown
Count
How discovered
User-reported (production failure)
13
Unit test
6
Code review
1
Memory location
GPU global memory (tensors)
17
GPU shared memory
3
Bug type
Integer overflow → buffer overflow
10
Table 1. Summary of 20 kernel memory bugs in vLLM.
Tensor Fields
Description
Variables
t.storage_.data_ptr_
base address
Bt
t.numel_
# of elements
Nt
t.sizes_and_strides_.size_
# of dimensions
Dt
t.sizes_and_strides_
dimensions
dt0 , dt1 , … dtD−1
t.data_type_.itemsize_
element size
St
Table 2. Constraint variables defined for tensor t .
Table 4. Constraint variables defined for CUDA threads.
Models
Kernels
IO
OOB
DR
NULL
Total
vLLM
62
50
72
195
02
-
269
HF
54
117
1310
-
-
-
1310
Papers
4
6
240
-
-
-
240
Total
120
173
1622
195
02
-
1819
Table 5. Benchmark information and detection results. ( IO: integer overflow, OOB: out-of-bounds, DR: data race, and NULL: null-pointer dereference. xy : x true positives, y false positives. ’-’ indicates zero true and false positives.)
Figure 5. How the number of bugs changes with GPU memory. (The vertical line represents NVIDIA B300.)
Honeycomb
GKLEE
ESBMC-GPU
cuKLEE
vLLM
/
/
/
15
Simplified
0
5
3
19
Table 6. Comparison with baseline techniques. (20 bugs are for each row. ‘/’: not applicable.)
Figure 7. Contributions of M2K’s components. (26 bugs detected in vLLM. W.O.: without, C: cuKLEE, H: HFProbe, M: configuration mutation, and V: Validation.)