K-Search: LLM Kernel Generation via Co-Evolving Intrinsic World Model
Paper · 2026 · Shiyi Cao, Ziming Mao, Joseph E. Gonzalez et al.
Summary
Making a GPU program faster can require several changes that only pay off together. A programmer might first reorganize how data is stored so that a later change can load several values at once. If an automated search tests the reorganization on its own and sees a slowdown, it may drop the very program that makes the faster version possible. A compiler error can have a similar effect. It tells the search that a particular implementation failed, while leaving open whether the underlying idea was worth pursuing.
K-Search keeps plans for improving a kernel separate from the code that carries them out. A kernel is a program that performs a particular operation on a GPU. The system uses a large language model to maintain a tree of proposed changes, each tied to a specific version of the kernel. It selects a high-priority proposal and tries concrete implementations until progress stalls or the evaluation budget runs out. It then uses the results to propose follow-up changes, reconsider the priority of pending ones, and remove branches it judges unpromising. The authors call the planning component an intrinsic world model. Its judgments change as new observations enter its context during the search.
The main experiments compare K-Search with OpenEvolve and ShinkaEvolve on paged attention and mixture-of-experts kernels from FlashInfer-Bench. All methods get 120 candidate evaluations per run. Across the tested kernels, K-Search achieves a mean final score of 56.13, a 2.10 × improvement over OpenEvolve and a 2.21 × improvement over ShinkaEvolve on the paper’s latency-based score. The largest comparison with OpenEvolve is on the FP8 mixture-of-experts kernel, where the score improves by 14.3×. The generated kernels rarely run faster than the expert-written FlashInfer reference. On a separate Triangle Multiplicative Update task, K-Search produces a Triton kernel with a geometric-mean latency of 1030 µs on H100. The authors measure it locally with the competition evaluator and compare it with previously ranked submissions.
The search trace for a paged attention kernel shows what the separate planning state can represent. K-Search drops an early proposal to split the work over the sequence, then proposes a more targeted version deeper in a branch that already incorporates other improvements. The benchmark comparisons establish how well the complete system searches under the tested conditions. The trace shows how its priorities and proposals change along one successful path.
Deep dive: K-Search: LLM Kernel Generation via Co-Evolving Intrinsic World Model
K-Search uses a language model to plan GPU kernel optimizations and revise its choices as it tests the speed and correctness of generated code. · about 32 minutes to read
The problem and its context
Why a faster kernel can be several edits away
A GPU kernel implements an operation by dividing its work among many threads. The same mathematical specification leaves room for a wide range of implementations. A programmer can change how work is grouped, where intermediate values are stored, when threads coordinate, and which hardware instructions they use. These decisions interact. A layout that works well for one division of the work can become a bottleneck under another. An optimization for one GPU generation can also lose its advantage when a newer architecture changes the available instructions or the cost of moving data. The paper uses the transition from Hopper to Blackwell to explain why kernel tuning remains a recurring problem in GPU & parallel computing.
Consider the paper’s example of changing a memory layout to enable vectorized access. Vectorization lets an implementation operate on a group of values together. The layout change may be needed to arrange those values suitably, yet rewriting the layout alone may make the kernel slower. If the search promotes candidates according to their immediate measured performance, the program containing the preparatory change has a weak case for surviving. A search that can retain and revisit the intended sequence of changes has more ways to reach the combined design.
This is what the authors mean by a non-monotonic optimization path. The code at an intermediate point need not score better than the best program already found. There can also be a gap between evidence about the algorithm and evidence about the code. A candidate may fail to compile because of a mistake in the implementation. It may compile and give incorrect answers. It may pass the correctness check but stage data inefficiently. Each outcome matters when selecting a program to run. Each also leaves different possibilities open for the strategy that motivated the program.
The difficulty is compounded by evaluation cost. Writing one more plausible variant is only part of a search step. The system still needs to compile it, test its outputs, and measure latency if it passes. Even useful diagnostics consume a portion of the available budget. The practical question is how to spend a limited number of trials across competing designs, including how many attempts to give an idea that has yet to yield usable code.
What existing optimization systems already do
Specialized libraries demonstrate how much engineering can go into a particular family of operations. FlashAttention targets efficient attention, the operation that combines information from other positions according to their relevance to a query. FlashLinearAttention covers variants that include linear attention and state-space approaches. FlashInfer focuses on inference serving, where a system must run requests of different lengths and handle batches that change over time. It supports a paged key-value cache, which stores the keys and values used by attention across pages that a kernel must locate when it reads them. These libraries show the value of narrowing the optimization problem to particular operators and workloads. Transformer and attention · FlashAttention-2 · FlashAttention-3 · FlashInfer
The compiler literature approaches the problem through scheduling. A schedule specifies how a tensor computation is organized for execution, including which operations are grouped and how work is divided. TVM and the Ansor scheduler use learned cost estimates to guide a search over schedules. Higher-level GPU programming tools address another part of the problem. Triton provides a way to express work in tiles, or blocks of data processed together. CuTe offers abstractions for describing layouts. These tools give a developer useful ways to express hardware-aware choices. Choosing a compatible set of choices for the particular workload remains an optimization problem. TVM · Triton
Earlier approaches using large language models already make use of execution feedback. The paper describes systems that generate code, observe what happens during compilation or execution, and use the resulting errors or profiling information to generate another variant. Population-based systems maintain multiple candidates so that search can develop several promising programs. A separate line of work uses reinforcement learning to improve CUDA or Triton generation, including the quality of code produced in a single attempt and the ability to refine an existing program. These approaches address the probability of producing useful code from the context at hand. K-Search asks how the system should choose which optimization to pursue and what to preserve from an unsuccessful attempt. Large language models · Kevin · CUDA-L1
How program evolution and planning meet
The paper places its baselines in a broader tradition of generating programs and using an evaluator to guide evolution. FunSearch applies this idea to mathematical and combinatorial problems. AlphaEvolve maintains a database of programs that can serve as the starting point for further edits. OpenEvolve uses an archive and quality-diversity mechanisms to preserve candidates with different characteristics, so the search can pursue alternatives as well as improve the strongest candidate. ShinkaEvolve combines selection based on performance with a check on novelty. Its search can turn away proposals judged too similar to what it already has. FunSearch · AlphaEvolve · ShinkaEvolve
Evolutionary archives give a search a memory of programs and what happened when they ran. A generator may identify an optimization from previous code or from feedback supplied in its prompt. The distinction the authors draw concerns the records on which the search acts directly. In their description of program evolution, the system’s selection rules select programs to supply as context. In K-Search, the selectable objects are explicit proposals, each associated with a particular program. A proposal can remain pending as results come in from another branch, or lose priority without the system taking another sample from it.
The other source of inspiration is work that treats language-based reasoning as planning with a world model. In that literature, a world model represents how an action may change a state. Some approaches use a language model to anticipate outcomes during planning. Others induce structured rules that a conventional planner can use. WebEvolver applies a world model that changes alongside an agent’s experience. K-Search adapts the idea to a more specific state: what a kernel search has explored, what it still intends to try, and which of those options looks promising given the evidence so far. The transition of interest is a change in that search state. The actual behavior of generated code is established by the evaluator. RAP · World models for task planning · WebEvolver
The method, step by step
What the evaluator returns
K-Search begins with a task specification and an evaluator. The specification gives the reference computation, the optimization objective, and instructions specific to the kernel. In the FlashInfer tasks the reference implementation is written in PyTorch. It gives the candidate something concrete to match when the evaluator checks its outputs. The generated CUDA program can organize the computation differently so long as it meets the specification and passes those checks. The evaluator then measures its performance under the benchmark conditions.
In the paper, an observation tuple records the outcome of a candidate’s evaluation.
o = (s, p, m) = E(x)
Here x is a candidate kernel program and E is the evaluator. The observation o groups the correctness indicator s, the positive latency measurement p, and metadata m. The indicator is 1 when the candidate passes the correctness check and 0 otherwise. The metadata can include compiler messages or profiler output. These observations carry information that a scalar score alone would lose. An incorrect result and a compiler failure can both score zero, yet their diagnostics can point toward different remedies.
The score used for optimization rewards a candidate according to the ratio of reference latency to candidate latency, subject to the correctness check.
J(x) = s · (p_ref / p) · 100
J(x) is the score of program x, s is its correctness indicator, p_ref is the reference kernel’s latency, and p is the candidate’s measured latency. The scaling factor is 100. Multiplication by s gives failed candidates a score of zero under the evaluation rule. For a correct kernel on a workload, smaller p means larger J(x). In the FlashInfer experiments, the paper aggregates scores over the benchmark workloads for a kernel.
The authors present the target as a maximization over possible implementations.
x⋆ = arg max_{x ∈ 𝒳} J(x)
𝒳 is the space of kernel programs, x ∈ 𝒳 means that x is a member of that space, and arg max denotes an implementation that maximizes the score J. The search is constrained by B, its evaluation budget. The algorithm returns the best program it evaluated, so the formal objective describes what it seeks. The budget constrains how much of the program space it can investigate.
From a history of programs to a frontier of plans
The paper first gives a schematic description of the baseline it wants to improve on. An evaluation history accumulates program and observation pairs, and a selection heuristic chooses a subset to use when generating another program.
Hₜ = {(xᵢ, oᵢ)}ᵗᵢ₌₁
Hₜ is the history through evaluation index t. The pair (xᵢ, oᵢ) contains the program xᵢ evaluated at index i and its observation oᵢ. The collection runs from the first evaluation through t. Curly braces denote the collection of pairs. The individual observation can carry a measured score together with text such as an error message.
xₜ₊₁ ∼ π_LLM(x | {(xₖ, oₖ) : (xₖ, oₖ) ∈ Cₜ}), Cₜ ⊆ Hₜ
xₜ₊₁ is the next candidate and π_LLM is the language model’s conditional program-generation policy. The symbol ∼ means the candidate is sampled from that policy, and | separates the program variable x from the information the generation conditions on. Cₜ is the context subset chosen from Hₜ, as indicated by ⊆. The index k labels a selected program xₖ and its observation oₖ. The notation after the colon restricts the pairs in the prompt to members of Cₜ. The history is valuable here, but the heuristic chooses which implementations enter the next step.
K-Search organizes the search around intentions expressed in natural language. The search state Sₜ is a tree that contains the explored actions, the best code retained from those actions, and the pending actions that can be selected next. The pending set is the frontier, denoted A(Sₜ). A frontier node is open. Once the system has finished trying to implement the proposal, the visited node is closed. A closed node can anchor further proposals that build on the program found there.
aₜ = (x_parent, δ)
aₜ is the action selected at search step t, x_parent is the specific parent implementation to change, and δ is the intended optimization. Attaching the intent to a parent is important. A plan to partition a key-value sequence across thread blocks, for example, can have different consequences on a kernel that already shares memory loads across heads than on a kernel that processes each head separately. Storing an action as a pair makes this dependency explicit.
The world model assigns an open action a priority in the interval from 0 to 1. This is its assessment of the promise of the proposed change in the current state. Scores on open nodes and scores on finished programs serve different purposes. A high priority licenses spending evaluations on a proposal. A high program score comes from correctness and latency measurements. The paper does not tie a given priority to an expected numerical speedup or to a measured probability of success.
How K-Search turns optimization plans into evaluated GPU kernels
The steps in order.
Choosing and implementing an action
Selection takes the highest-priority proposal on the current frontier.
aₜ = arg max_{a ∈ A(Sₜ)} V(a | Sₜ)
aₜ is the selected action at step t. The variable a ranges over the actions in A(Sₜ), the frontier of state Sₜ. V(a | Sₜ) is the priority of action a as judged in that state, and arg max selects an action with the highest value. The vertical bar reads as “given.” As the planner changes the priorities or adds proposals, this same selection rule can send the search down different branches.
The selected proposal goes to the code-generation role. It receives an intended change together with the parent program to which the change applies. The formulation for a single trial gives generation and evaluation as separate operations.
xₜ ∼ π_code(x | aₜ)
π_code is the stochastic code-generation policy, x is its program variable, and aₜ is the action on which it conditions. xₜ is the sampled implementation and ∼ denotes the draw. The action focuses the search on a particular transformation. The stochastic policy can produce different concrete attempts at that transformation.
oₜ = E(xₜ)
oₜ is the observation returned by evaluator E for the candidate xₜ. The subscript t associates that observation with the candidate in the formal version of the search. The system evaluates candidates through the task interface, so even an appealing optimization has to produce code that passes the same checks as other programs.
The implemented algorithm gives a proposal a local refinement loop. It starts with a stagnation counter and an empty record of the best result for the selected action. Each candidate costs an evaluation from the remaining budget. If its score strictly improves on the local best, the algorithm retains the program and observation and resets the counter. Otherwise the counter increments. The loop ends when the system has made K consecutive attempts without improving the local best or has exhausted the budget B. An improvement renews the allowance for local work. The stagnation rule measures attempts since improvement, so it can stop a proposal that has produced working code as well as one whose implementations keep failing.
This distinction between local and overall progress matters. A candidate can improve the best implementation of the current proposal while still trailing the strongest kernel elsewhere in the tree. Its result can nevertheless give the planner a new program to extend or a reason to reconsider a related proposal. The system can retain its best program overall while exploring paths that temporarily fall below it.
Updating the plan after execution
The world model is a model of how the search state changes. The paper writes the transition after observing a trial as follows.
Sₜ₊₁ ∼ P_model(S | Sₜ, aₜ; xₜ, oₜ)
Sₜ₊₁ is the next search state and S stands for a possible value of that state. P_model denotes the world model’s conditional transition distribution. Sₜ is the prior state, aₜ is the selected action, xₜ is the resulting code, and oₜ is its evaluation observation. The semicolon separates the realized program and feedback from the state and action in the conditioning information. The symbol ∼ describes the next state as a draw from the transition. This formulation captures the role of execution evidence in changing what the planner would try next.
In the implementation, the planner updates the tree after local refinement. The pseudocode passes the locally best implementation and observation to the transition. The accompanying description says that the planner reasons over the trajectory of attempts. It can insert actions that extend the current program, update the priorities of pending actions, and prune branches it deems infeasible or redundant. A priority change leaves a proposal available for later selection. Pruning removes that node from further consideration. A related idea can still be proposed as a new action with a different parent.
The planner’s adaptation happens through in-context learning. Once execution observations are in its context, it can use them alongside its existing knowledge when it makes the next judgment. The algorithm has no weight-training step. In this sense the planning state and kernel co-evolve: attempts at implementing a plan supply evidence that changes the tree, and the changed tree determines which plans receive attempts. The authors release the implementation as K-Search.
Watching the tree change on MLA Paged Decode
The paper illustrates the method with a trace for MLA Paged Decode. Decode is the stage where each batch item supplies a new query and attends to the keys and values already cached. MLA uses a compressed part of the cached representation, called CKV, alongside a position-related part. In the trace, r labels a round of the search, and each round spends an evaluator call on a candidate. Multiple rounds can therefore go towards implementing and refining the same action.
At r1, the frontier contains proposals to process multiple heads together, split the sequence work, or handle heads independently. Their initial priorities are 0.9, 0.7, and 0.3, respectively. The planner chooses head fusion first. Its rationale is that if heads share cached data, processing them together may avoid repeated reads from global memory. The predicted 16× reduction in global memory traffic is the planner’s hypothesis for shared CKV accesses compared with independent processing. The trace reports measured program scores separately from this expectation.
After the work on head fusion yields a score of 34, the planner adds actions to that branch. One aims to keep rescaling work resident in registers, storage directly available to the executing threads. Another explores a chunk size with the aim of keeping more GPU work active. The planner also lowers the priority of independent head processing to 0.1. The paper connects the downgrade to the evidence in favor of reusing cache loads across heads. By round 34, the independent-head branch has been pruned. Meanwhile, the program associated with register-resident rescaling reaches a score of 45.
At round 42, the original sequence-splitting proposal is removed, and a variant aimed at lower overhead appears under the register-resident branch. Splitting a sequence into chunks can expose parallel work, but it also creates partial results that must be combined. The revised placement makes the proposal depend on an already improved kernel. The new action is distinct from the root-level action even though both involve splitting, because the cost and benefit now depend on a different parent implementation.
Further down the successful branch, the planner proposes applying sm_scale, the attention score scaling factor, when loading the query Q. This follows a variant that had already vectorized accesses. The trace marks the prescaled, vectorized version with a score of 52 at r102. The example includes both changes to the kernel and decisions about what to try next. It shows a proposal being dropped in one context and revived in another, as well as a later refinement that builds on a particular successful implementation.
Experiments and results
Workloads and comparison rules
The main evaluation uses FlashInfer-Bench traces captured in real traffic. A trace gives a concrete workload on which the evaluator can check correctness and measure speed. The tasks cover paged prefill and decode for MLA, paged decode for grouped-query attention (GQA), and an FP8 mixture-of-experts kernel (MoE). Prefill processes the input context, where multiple query rows can be available together. Decode adds a new query for each active sequence, so reading the previously cached keys and values becomes a central cost. GQA lets groups of query heads share key and value heads, creating an opportunity to reuse those reads. MoE routes tokens to selected expert networks, creating variation in the amount of work assigned to different experts.
The attention tasks target Hopper. MLA Paged Prefill comes from a DeepSeek-V3 setting with a paged cache, compressed key-value information, and a separate component carrying positional information. It faces memory bandwidth pressure for long contexts. MLA Paged Decode is also in a DeepSeek-V3 setting. The task represents dynamic batches, with latency a particular concern at small batch sizes. GQA Paged Decode uses the Qwen3-A3B-30B setting. Data movement is central to that task, and the paper identifies opportunities both in sharing cache loads among heads and in overlapping those loads with computation. Qwen3 Technical Report
The FP8 MoE task targets Blackwell and uses a DeepSeek-V3 style specification. FP8 is the low-precision format involved in the kernel. Packing values and applying their scales add work, and the amount of computation assigned to a particular expert depends on the routing decisions for the input. A prefill kernel’s difficulty with irregular sequence lengths and a MoE kernel’s difficulty with irregular expert assignments arise in different parts of their computations, so the benchmark tests the search on more than one kind of optimization problem.
The compared systems are OpenEvolve, ShinkaEvolve, and K-Search. They use gemini-3-pro-preview and share the same initial program for a kernel. ShinkaEvolve uses Qwen3-8B for embeddings, the representations used in its novelty mechanism. The evolutionary baselines use their default configurations and the paper’s generation prompt. That prompt supplies the target GPU, the computation to implement, the relevant shapes and data types, and the performance targets. The authors give all systems an initial CUDA program for MLA Paged Decode because the baselines struggle to produce a working kernel for that task from scratch.
All candidates for the FlashInfer experiments are written in CUDA and face the same compilation and correctness checks. The experiments use NVIDIA H100 and B200 GPUs, CUDA 12.8, FlashInfer 0.5.3, and PyTorch 2.8.0. An evaluation covers the specified workloads for a candidate and uses the FlashInfer implementation as its latency reference. Incorrect or failed candidates consume search budget as well as successful ones. The setup therefore tests a search system’s ability to produce usable implementations along the way, in addition to the quality of the strongest one it eventually finds.
The candidate budget is B = 120 for each run, and K-Search uses K = 7 for its local stagnation limit. Each method is run three times. At each iteration, the main figure plots the mean best-so-far score across runs, with a band spanning the minimum and maximum among them. A failed trial leaves the best-so-far value where it was. A plateau can therefore contain search effort, including unsuccessful attempts to implement or improve an idea. The final value answers how strong a program the method has found by the end of its allotted evaluations.
Final scores across kernels
K-Search finishes ahead of both evolutionary baselines on the average final score for every tested FlashInfer kernel. Across the tasks, it records an overall average of 56.13, compared with 26.68 for OpenEvolve and 25.37 for ShinkaEvolve. The paper gives the corresponding improvements as 2.10 × and 2.21 ×. The ratios compare scores of generated programs. FlashInfer provides the denominator used to construct those scores through its reference latencies, so performance against the expert implementation is a separate comparison.
Overall average final score across FlashInfer-Bench kernels
K-Search finishes with the highest average latency-based score.
The numbers
| System or setting | Final score |
|---|---|
| OpenEvolve | 26.68 |
| ShinkaEvolve | 25.37 |
| K-Search (this paper) | 56.13 |
On FP8 MoE, K-Search scores 44.1. OpenEvolve finishes at 3.09 and ShinkaEvolve at 27.9. The paper reports a 14.3× improvement over OpenEvolve and a 1.58× improvement over ShinkaEvolve on this kernel. The difference between those comparisons is revealing. The task is difficult for the systems in different ways, and the especially large ratio against OpenEvolve reflects the low score it reaches. A code analysis in the paper finds differences in how the resulting kernels schedule the routed work and carry out the expert computations.
On MLA Paged Prefill, the final scores are 57.4 for K-Search, 19.5 for OpenEvolve, and 11.3 for ShinkaEvolve. The paper gives the improvements over the baselines as 2.95× and 5.10×. Here the generated K-Search kernel handles variable-length sequence boundaries during GPU execution and makes more of the threads in a block available for score computation and normalization. The baseline programs have different approaches to preparing the work for the GPU.
The GQA Paged Decode task yields a final score of 76.0 for K-Search, against 44.2 for OpenEvolve and 27.7 for ShinkaEvolve. The reported improvements are 1.72× and 2.74×. The aggregate favors K-Search, though the workload analysis shows that its design carries a cost on some small batches. On MLA Paged Decode, K-Search reaches 47.1, compared with 39.9 and 34.7 for OpenEvolve and ShinkaEvolve. The corresponding reported gains are 18% and 36%. That is the task on which the search methods start from the supplied CUDA program. Its result measures improvement from a shared starting point.
What the workloads reveal
The search curves summarize what the methods find within budget. To see where a generated kernel performs well, the authors also plot performance on individual workloads. The comparison covers 152 total workload traces across the 4 kernel types. K-Search generally beats the evolutionary baselines across these traces. The distribution matters because the same implementation decision can help some shapes while hurting others, even for workloads that call the same operator.
GQA Paged Decode provides the clearest example. Among the traces on which the generated K-Search kernel loses to the baselines, the paper counts 16 with batch_size=1 and 4 with batch_size=16. It reports no such losses at larger batch sizes. K-Search’s implementation divides the cached sequence among cooperating thread blocks, which compute and then merge partial attention results. This creates parallel work along the sequence, at the cost of storing partial results and coordinating the merge. The programs from OpenEvolve and ShinkaEvolve assign the full sequence for a batch and key-value head to a single block. That block processes the sequence serially across its chunks, with no cross-block merge for that work item.
The authors attribute the small-batch disadvantage to the overhead of coordinating split work. The measurements compare complete kernels on particular traces, so the pattern is evidence about these implementations. It also explains why the main score and the per-workload view answer different questions. A strong average can coexist with a clear group of workloads on which another implementation is faster. The affected batch sizes identify where the compromise appears in this benchmark.
The paper’s Fast p plot offers another view of the same workload measurements. For a specified speedup threshold relative to FlashInfer, it reports the share of traces on which a generated kernel meets that threshold. This puts the expert reference in view at every point. On GQA Paged Decode, K-Search reaches a speedup of at least 0.36 on 100% of workloads, compared with 50% for ShinkaEvolve. At the threshold of 0.50, K-Search reaches 87.5% of workloads, OpenEvolve reaches 50.0%, and ShinkaEvolve reaches 39.6%. The authors report that the K-Search proportions at that higher threshold are 1.75× and 2.21× those of the baselines, respectively.
GQA Paged Decode traces reaching 0.50 speedup over FlashInfer
The K-Search kernel reaches the threshold on a larger share of traces.
The numbers
| System or setting | Workloads % |
|---|---|
| OpenEvolve | 50.0 |
| ShinkaEvolve | 39.6 |
| K-Search (this paper) | 87.5 |
For MLA Paged Prefill, K-Search reaches a speedup of at least 0.40 on 57.9% of workloads. Neither evolutionary baseline reaches that threshold on any workload for the task. A threshold below parity describes how consistently the generated program approaches a fraction of the reference’s speed. The authors observe that the generated kernels rarely overtake FlashInfer. The practical achievement of the search budget is thus visible in how many traces move closer to the reference and how much the method improves over other automated searches.
A separate latency result on TriMul
The GPUMODE Triangle Multiplicative Update task tests a different computation. TriMul operates on representations of pairs and is used in AlphaFold3 and other systems for protein structure prediction. The operation combines normalization, gated linear projections, optional masking, and a contraction over pairs. A contraction combines tensor elements by summing over a shared index. In TriMul, its cost grows cubically with the length dimension. The paper gives the input and the contraction’s complexity as follows.
X ∈ ℝ^(B × N × N × C)
X is the input pair representation. ℝ denotes real-valued entries, and the superscript expression gives the tensor’s shape. Here B is batch size, each N is the length of a pair axis, and C is the channel dimension. The B used for this tensor dimension is separate from the evaluation budget symbol in the search algorithm. The multiplication signs separate the dimensions of the shape.
O(N³)
O is big-O notation for the growth of the contraction’s computational cost, N is the length of a pair axis, and the exponent ³ indicates cubic growth. The paper identifies this contraction as part of the operation the generated kernel must carry out. The leaderboard metric measures the latency of the complete kernel on benchmark cases.
K-Search generates Triton code for TriMul, starting without a seed Triton program. The stagnation limit is K=5, reduced from K=7 on the FlashInfer CUDA tasks because the authors consider Triton implementations simpler to produce. The run has a budget of 300 iterations. GPT-5.2 is used for the first 150 steps. Gemini-3-Pro then continues for 150 steps from the strongest solution produced in the first stage. This setup includes a deliberate handoff between generators halfway through the budget.
The submission window had closed, so the authors evaluate locally with the official GPUMODE evaluator on NVIDIA H100 80 GB HBM3 hardware. The reported latency of 1030 µs is the geometric mean over a fixed set of benchmark cases. The ranked CUDA entry from shiyegao records 1074 µs, and Zeyu Shen’s Triton entry records 1140 µs. The TTT-Discover entry, labeled TTT in the comparison, reports 1161 µs with 25,600 iterations and uses reinforcement learning alongside evolutionary search. The scores place the local K-Search measurement ahead of all the H100 entries shown in the paper.
GPUMODE TriMul geometric-mean latency on NVIDIA H100
The local K-Search measurement is lower than the ranked latencies shown.
The numbers
| System or setting | µs |
|---|---|
| shiyegao | 1074 |
| Zeyu Shen | 1140 |
| TTT | 1161 |
| K-Search (this paper) | 1030 |
The TriMul experiment broadens the range of computations and programming environments in which the search is demonstrated. Its comparison uses the leaderboard’s latency metric and previously measured entries. The FlashInfer experiment supplies the controlled comparison with the two evolutionary baselines under a common evaluation budget.
What the ablations show
The paper reports no component ablations. It instead analyzes a search trace, the outcomes of individual generations, workload-level comparisons, and the structure of selected generated kernels.
Which parts of the search process are visible
The MLA Paged Decode trace exposes decisions that would be hard to recover from a collection of final source files. The planner can lower the priority of one branch after observing the success of its sibling. It can also reintroduce an idea with a different parent. Both behaviors follow directly from the way the algorithm records actions. The trace confirms that these operations occur during a successful run and gives the authors’ explanation of the decisions. It provides a process account of how that run arrived at its final program.
The trace is especially informative about the relationship between choices and observations. The efficacy of the head-fusion program gives a concrete basis for placing less emphasis on independent head processing. The later proposal for a low-overhead split under the fused, register-resident branch expresses a more conditional claim about that technique. The planner records where to try it, which preserves information about how the potential gains depend on the parent. The final prescaling proposal shows another step in which the planner names a change in relation to code already produced. The sequence of tree edits establishes that feedback can change the proposed structure of the search.
The authors also report that the vast majority of ShinkaEvolve’s generations in their GQA logs receive zero scores, from failed or incorrect programs. OpenEvolve varies considerably from one evaluation to the next and frequently generates programs below its own previous best. On MoE its final score remains low. These observations help explain how a fixed evaluation allowance can produce different final results. The budget counts trials regardless of their usefulness. A method can spend much of it producing invalid code or variants that never advance the best result.
K-Search’s local refinement and persistent frontier give a plausible explanation of why its budget is spent more effectively. Several attempts at one intent can help the system work through an implementation defect, while the frontier gives it alternatives when the intent stops yielding progress. The logs and final scores describe the complete search systems. A controlled test that kept the code-generation prompt and planner fixed while changing the retry rule would be needed to estimate the contribution of retries on their own. The same distinction applies to priority updates and pruning.
FP8 MoE separates routing from expert computation
The authors examine the MoE candidates at the level of their GPU work. For this task the input gives scores for 256 candidate experts. The routing step selects the top 8, and the specification has 32 local experts and hidden size 7168. The experts then apply an up projection and a gate projection, combine them with the SiLU activation, and apply a down projection. Routing governs which work exists, while the projections govern how that work is executed. Both parts contribute to the measured latency.
K-Search’s kernel assigns a block of 256 threads to the routing work for a token. Threads in a warp, a group that can cooperate directly on the GPU, exchange values as part of finding the highest scoring experts. ShinkaEvolve’s kernel instead has each thread load the expert scores and search them with loops. OpenEvolve organizes its work around persistent blocks, which repeatedly claim tiles from a shared counter and map them to expert and token work. This avoids some launches, but the authors identify the repeated atomic operation on the counter as an overhead. An atomic update coordinates concurrent access to a memory location, making it part of the cost of repeatedly assigning work.
The K-Search implementation also rearranges tokens so that data belonging to the same expert is contiguous. It skips experts with no tokens and uses tensor cores, specialized hardware for matrix operations, on 16 × 16 blocks through WMMA. Double-buffering lets it load the next block of data while computing on the current one. The paper associates OpenEvolve’s persistent design with heavier shared-memory use and lower occupancy, meaning fewer blocks can be active together under the resource constraints. ShinkaEvolve carries out the expert computation in a dot-product style without using tensor cores.
These choices help account for the pronounced differences in MoE scores. They occur across routing, work assignment, memory access, and arithmetic, so the comparison also shows why a single label like “uses tensor cores” would tell only part of the story. Each generated candidate is a different complete design. The paper does not time otherwise identical versions with routing, token reordering, or double-buffering varied separately.
Attention kernels expose different costs of moving data
For GQA Paged Decode, the K-Search kernel assigns blocks to contiguous sections of the key-value sequence. Each block calculates its section’s contribution and writes a partial result to temporary storage. A counter lets the last block detect that the other partials are ready and merge them. The sequence-wide work can thus proceed in parallel across blocks. K-Search also double-buffers keys and values while processing chunks, where the ShinkaEvolve candidate mostly alternates between loading data and computing attention.
The architecture of the GQA candidate gives the authors a way to explain both sides of its measured workload profile. Extra blocks can help with a long sweep over cached keys and values. Partial results and a final merge add work that the simpler baseline arrangement avoids. The comparison between complete kernels across shapes reveals where the generated design performs well. It does not independently quantify the effect of sequence splitting and the effect of overlapping memory with arithmetic.
The MLA Paged Prefill comparison centers on variable-length input sequences. A query is 576-dimensional, with 512 dimensions in the compressed key-value component and 64 associated with rotary position information. The candidates implement causal attention over the paged layout with 16 heads. Causal attention restricts a query to the appropriate positions in its context. The program forms attention scores, applies softmax to turn them into weights, and uses those weights to combine values. The paper expresses the score computation and weighted output through the following products.
QKᵀ
Q is the collection of query vectors, K is the collection of key vectors, and ᵀ denotes transposition. Juxtaposition denotes matrix multiplication, producing the query-key scores. In the MLA decode description, the score computation uses the compressed and position-related components of the cache.
P · V
P is the matrix of attention weights obtained after softmax, V is the matrix of value vectors, and · denotes matrix multiplication. The product is the weighted output. V here denotes attention values, distinct from the priority function in the search procedure.
In prefill, a tile of 16 query rows can cross a sequence boundary. The K-Search kernel assigns such tiles to GPU blocks and identifies the relevant portions of each sequence while the block executes. It uses an array of cumulative sequence boundaries to determine which rows share a cache range. In the baseline designs, the CPU maps tiles to batches and sends the mapping to the GPU. The authors identify the extra pass and metadata as costs avoided by K-Search’s design. For the score and softmax stage, they also find that the K-Search program distributes the work among the threads of the block, while the OpenEvolve program leaves much of that work to a single warp.
MLA Paged Decode brings out a different combination of changes. All the compared programs can split a sequence and later merge its partial results. K-Search selects the splitting strategy according to sequence length, writing the output directly for short sequences when it can use a single block per batch and head. The evolutionary baseline candidates use 64-token chunks and enforce a minimum number of splits. The direct write therefore avoids a reduction and temporary storage on workloads where partitioning offers little opportunity for useful extra work.
The final MLA decode implementation also retains query fragments in registers instead of staging the full query in shared memory. Each block reuses those fragments as it processes more key-value chunks. Its prefetch pipeline issues loads farther ahead than the double-buffered pipelines of the baseline kernels. Prefetching means requesting data before it is needed, allowing some of the wait for memory to overlap with arithmetic. The authors expect the deeper pipeline to help on long sequences with enough chunks to keep it occupied. Together, the analyses relate performance to decisions about where data lives, how it travels, and how much independent work the GPU can execute.
Limitations
Boundaries stated in the paper
The authors specify that adaptation currently occurs through in-context learning. The planner’s use of prior observations is part of the search run. The reported experiments therefore concern a system that accumulates experience in the course of solving a task. The paper gives no demonstration of a learned update carried from one kernel task to the next. The transition notation describes how the planner behaves as the search state changes, while code correctness and latency remain the evaluator’s measurements.
The FlashInfer comparison uses fixed workload traces and a fixed number of evaluations. The authors omit detailed workload configurations such as head counts from their main kernel overview, and they supply an initial CUDA implementation on the MLA decode task. These choices matter when reading the result. The seeded experiment tests what each method can achieve with a common working point from which to search. The attention and MoE scores come from kernels tuned for their specified architectures and measured on the corresponding inputs. The authors also explicitly observe that the generated programs seldom exceed the FlashInfer reference.
For TriMul, the authors state that the challenge’s submission period had ended. Their result is a local measurement made with the official evaluator, compared with ranked H100 latencies. The run changes generators at a specified point and continues from its strongest earlier solution. The reported outcome describes that combined search procedure. It establishes a local benchmark result under the stated conditions, with the leaderboard providing the comparison entries.
What can be inferred from the design
The strongest evidence concerns K-Search as a complete framework. Sharing the main generator, evaluator, initial program, and candidate budget makes the FlashInfer comparison informative about how the systems use trials. K-Search changes several aspects of the procedure at once: the representation of pending work, the method for choosing a proposal, the handling of repeated attempts, and the rules for editing the frontier. The experiments leave the individual contributions of these changes unresolved. A lower rate of invalid candidates could come from tighter instructions for an individual generation, from the choice of which plan to attempt, or from their interaction.
The evaluation budget also defines sample efficiency in a particular way. It counts kernel evaluations. The methods can require different numbers of planning calls, different amounts of text in context, and different amounts of time spent on candidates that fail early or run through the full benchmark. The paper’s budget comparison supports claims about results per allowed candidate evaluation. There is no matched accounting for language-model token use or end-to-end search cost from which to draw the same conclusion about time or money.
The repeated-run bands show the range of observed best-so-far curves. They make variability visible for each method on each task. They do not provide a formal estimate of uncertainty for tasks beyond those evaluated. Similarly, the detailed traces give a clearer view of the selected operators than the aggregate does, but their provenance in real traffic does not establish coverage of future distributions. The paper uses identical workloads when comparing methods and reports per-workload performance on those traces. A separate evaluation on workload shapes withheld from search would address how well the generated kernels retain their advantage on unseen inputs.
Correctness also has an empirical scope. Passing the suite establishes agreement with the reference under the evaluator’s tests. The paper does not provide a proof covering every admissible input for the generated code. This distinction matters for optimizations that specialize to shape constraints or use workload-dependent paths. The same specialization that makes a candidate competitive can make the tested input domain particularly important when interpreting the score.
Priority is a judgment used to decide what the evaluator should try next. The paper shows useful priority revisions in the MLA trace, while the numeric priorities themselves have no reported calibration against eventual success. A branch can be removed permanently on the planner’s judgment, and that removal prevents observing what that exact branch might have yielded with more attempts. The ability to introduce a related plan elsewhere gives the system some flexibility, but the search remains bounded. The best result in the trace is the best one found along that run.
Finally, having results on Hopper and Blackwell broadens the set of tested tasks and hardware, while each kernel is optimized in its own setting. There is no cross-architecture evaluation showing that a generated kernel retains its advantage when moved from one GPU generation to another. TriMul adds evidence on an operation outside the FlashInfer suite and on a different programming language. Because the search budget, generator schedule, and comparison protocol also change, the TriMul result demonstrates another use of the framework without isolating which of those choices accounts for its latency.
What came after
No follow-up work citing K-Search is documented here, so there is no later result to attribute to its search method.
Cite
Cite as Shiyi Cao, Ziming Mao, Joseph E. Gonzalez and Ion Stoica. 2026. K-Search: LLM Kernel Generation via Co-Evolving Intrinsic World Model. arXiv:2602.19128.
@misc{cao2026k,
title = {{K-Search: LLM Kernel Generation via Co-Evolving Intrinsic World Model}},
author = {Shiyi Cao, Ziming Mao, Joseph E. Gonzalez and Ion Stoica},
year = {2026},
doi = {10.48550/arxiv.2602.19128},
eprint = {2602.19128},
archivePrefix = {arXiv},
url = {https://doi.org/10.48550/arxiv.2602.19128}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/cao-2026-k-search-llm-kernel-generation/