{"slug": "test-reduce-prove-validating-the-most-complex-ai-gpu-kernels-with-resolve", "title": "Test, Reduce, Prove: Validating the Most Complex AI GPU Kernels with RESOLVE", "summary": "A validation approach called RESOLVE, detailed in a paper on arXiv (2610.05683), proved three complex AI \"mega-kernels\" — Mirage, LUCE and the FlashMoE router — equivalent to their references on the workloads checked, while finding new bugs and reproducing bugs previously caught only after release. The work, which reduces GPU programs beyond the reach of today's proofs to simpler programs that can be formally verified, has produced 6 bug-fix pull requests to these mega-kernels, 4 of them already merged, with the reduced kernels and proofs published in the FStarLang/kuiper-megakernels repository. The authors frame the effort as necessary because AI agents are optimizing GPU kernels faster than anyone can review them and no formal model of a modern GPU yet exists to check them against.", "body_md": "[← All posts](https://risemsr.github.io/blog/)\n\n# Test, Reduce, Prove: Validating the Most Complex AI GPU Kernels with RESOLVE\n\nAI agents are optimizing GPU kernels faster than anyone can review them, yet there's no formal model of a modern GPU to check them against. We can't wait for one.\n\n**TL;DR:** [RESOLVE](https://arxiv.org/abs/2610.05683) is a validation\napproach that uses techniques from concurrency testing to reduce complex GPU\nprograms, which are out of reach for proofs today, to simpler programs that\nwe can prove correct. In this post, we apply it to some of the most complex\nAI kernels we know of: *mega-kernels*, which run a whole model or a large\npart of one in a single GPU launch. In three case studies\n([Mirage](https://github.com/mirage-project/mirage),\n[LUCE](https://github.com/Luce-Org/lucebox) and the\n[FlashMoE](https://github.com/osayamenja/FlashMoE) router), we prove each\nmega-kernel equivalent to its reference on the workloads we checked, find new bugs, reproduce bugs that were only\nfound after release, and uncover subtle differences between inference\nimplementations. And it’s already making a difference upstream: we’ve\nopened **6 bug-fix pull requests to these mega-kernels, and 4 are already\nmerged**. Our reduced kernels and proofs are all\n[available](https://github.com/FStarLang/kuiper-megakernels/tree/main).\n\n## Where we’re coming from\n\nWith so many kernels now written or tuned by agents, the question of whether a\nkernel is actually correct keeps coming up.\nWrong answers aren’t the only risk; GPU bugs can also be\n[security problems](https://blog.trailofbits.com/2024/01/16/leftoverlocals-listening-to-llm-responses-through-leaked-gpu-local-memory/). We’ve been working on this\nfrom a few directions.\n\nOn the verification side, some of us built\n[GPUVerify](https://doi.org/10.1145/2384616.2384625) (OOPSLA 2012), which\nproves GPU kernels free of data races and barrier divergence. More recently,\n[Kuiper](https://doi.org/10.1145/3808280) (PLDI\n2026) lets you write GPU kernels in F* and Pulse with machine-checked proofs\nof functional correctness, without giving up low-level performance. Our\ncolleagues have shown that models can\n[write F* proofs](https://doi.org/10.1109/ICSE55347.2025.00002) (ICSE 2025)\nand that agents can [build large verified programs](https://doi.org/10.1145/3828709)\n(ICFP 2026). With agents writing Kuiper code and proofs, we\n[verified a solution to every KernelBench Level 1 problem](https://doi.org/10.1145/3819802.3820580)\n(PAgE 2026).\n\nOn the semantics side, some of us have spent more than a decade trying to pin\ndown what GPUs actually do: the\n[memory model](https://doi.org/10.1145/2694344.2694391) (ASPLOS 2015),\n[forward-progress guarantees](https://doi.org/10.1145/3485508) between thread\nblocks (OOPSLA 2021), and how threads in a warp behave, most recently in\n[SIMT-Step](https://doi.org/10.1145/3808297) (PLDI 2026).\n\nAnd on the testing side, inserting random delays to shake out rare thread\nschedules goes back to Sebastian and Madan’s work on\n[PCT](https://doi.org/10.1145/1736020.1736040) (ASPLOS 2010) and\n[DataCollider](https://www.usenix.org/conference/osdi10/effective-data-race-detection-kernel)\n(OSDI 2010). For GPUs, we have built memory-model testing tools such as\n[MC Mutants](https://tyler-utah.github.io/files/mcmutants2023.pdf) (ASPLOS\n2023) and [GPUHarbor](https://doi.org/10.1145/3597926.3598095) (ISSTA 2023).\n\nRESOLVE brings these three threads together. Its requirements come from working with teams across Microsoft: it has to handle the kernels they actually deploy, whether written in CUDA, CUTLASS, Triton, Gluon or something else, at the shapes and batch sizes their models run with.\n\nDeployed kernels get their speed by exploiting cutting-edge features of GPU architectures, such as asynchronous copies, the Tensor Memory Accelerator (TMA), warp specialization, tensor cores, and persistent thread blocks that signal one another through flags in memory. Formal semantics for GPU programming models are lagging behind: they all make simplifying assumptions that exclude some or all of these features, or treat them in a preliminary manner that has not been widely validated by the community. Rather than wait for those models to mature, RESOLVE is upfront about what it assumes about the hardware. For the features that aren’t modeled yet, it tests the compiled kernel on a real GPU instead of proving things about it. That lets us validate today’s most aggressive kernels now, and as the models mature, more of each kernel can move from testing to proof.\n\n## Why not just test?\n\nThe usual way to check a kernel is to run it next to a reference implementation, typically in PyTorch, and check that the outputs are “close.” While testing is a very reasonable starting point when trying to validate kernels, it is by no means perfect. Like any other validation tool, tests may report false positives (reject a correct kernel) and false negatives (accept an incorrect kernel).\n\nWhen we evaluated how tests fare on our corpus of correct and incorrect kernels, we found that testing has two major weaknesses:\n\n1. \n**Concurrency bugs** : Tests can fail to detect bugs that do not manifest reliably. For example,\na concurrency bug, such as a data race, can make the output of a kernel nondeterministic.\nThis means that a bug can go undetected when we run the test, causing a false negative.\n2. \n**Numeric tolerances** : Many optimizations, such as reordering a sum or\nlowering precision, keep the math the same but change the floating-point\nresult, so tests have to allow small differences. It isn’t clear how small.\n\nFinding the right tolerance isn’t just a matter of calibration: one loose\nenough to accept correct kernels can also accept incorrect ones. In our\n[PAgE paper](https://doi.org/10.1145/3819802.3820580), KernelBench’s Softmax\ntest passed a kernel that returned all zeros, because the expected outputs\nwere far smaller than the tolerance (a false negative), while *correct* Triton\nmatrix multiplications using TF32 tensor cores *failed* the same tolerance (a\nfalse positive). In the RESOLVE paper, two agent-written KernelBench solutions\nthat never touch memory passed the benchmark’s tests.\n[Racer](https://arxiv.org/abs/2610.28429) makes the same point: a logic bug\ncan produce an error smaller than the tolerance a correct optimized kernel\nneeds.\n\n## Why not just prove?\n\nGiven the inadequacies of testing, why not just prove kernels correct?\nFormal methods are moving fast (in no small part thanks to AI), and several\ngroups have applied them to GPU kernels (see the [related work](#related-work) at the end).\nBut any proof about a GPU kernel is relative to some model of how the GPU\nbehaves, and GPUs are an unusually hard target to model.\n\nTo start with, formal models show up *years* after the hardware (Figure 1). CUDA\nshipped in 2007, and NVIDIA’s [formal model of PTX memory](https://doi.org/10.1145/3297858.3304043) came out in 2019.\nWarp shuffles have been around since 2012, and there are still only\n[candidate models](https://doi.org/10.1145/3808297) for them. Asynchronous copies (2020) and TMA (2022) have only just\ngotten formal models, which haven’t yet been\nwidely vetted. All of these features\nare about concurrency: how threads share data and wait for one another.\n\n*Figure 1. How long GPU features have been in use without a formal model.*\n\nEven rigorously reviewed models need scrutiny. While bringing NVIDIA’s PTX and\nKhronos’ Vulkan memory models into the Dartagnan tool, its developers\n[found two bugs](https://doi.org/10.1145/3622781.3674174) in the original\nmodels, and\n[Beyond the Fence](https://users.cs.utah.edu/~vijay/papers/asplos27a.pdf)\n(ASPLOS) recently found one in the PTX model, confirmed by NVIDIA. Warps are further\nbehind: no GPU programming language gives them a rigorous semantics, and the\n[candidate models](https://doi.org/10.1145/3808297) are exceptionally\ncomplicated and hard to compose with other concurrency semantics, such as\nmemory models.\n\nEvaluating models is also difficult because GPU implementations are often\nmuch stronger than their specifications: a model built from how real hardware\nbehaves may not match what vendors intend, and could break when any part of\nthe stack is updated. For example, a MICRO 2024 paper removed synchronization\nusing behavior that real GPUs provide but NVIDIA’s PTX memory model doesn’t\nguarantee (see this\n[SIGARCH post](https://www.sigarch.org/gpu-memory-consistency-specifications-testing-and-opportunities-for-performance-tooling/)\non GPU memory-model specifications).\nSimilarly, in [SIMT-Step](https://doi.org/10.1145/3808297) we saw warps\nrunning almost entirely in lockstep on 10 GPUs from 8 vendors, although the\nCUDA programming guide says threads in a warp are scheduled independently.\n\nSemantics are only half the problem. The other half is the *specification*.\nA proof shows that a kernel meets its specification and nothing more. If the\nspecification leaves an output unconstrained, or describes the wrong\ncomputation, the proof goes through anyway. That is harder to rule out now\nthat agents write specifications as well as proofs.\n\nNone of this makes proofs pointless, but the semantics and the specification underneath a proof deserve as much scrutiny as the proof itself, including ours.\n\n## RESOLVE: test what we can’t model\n\nOur approach in RESOLVE is to prove only the parts of a kernel whose meaning we’re confident about (arithmetic, loops and indexing) and to check everything else by running the actual binary on an actual GPU. There are three steps, and Figure 2 walks through them on a small example: adding up 32 numbers with warp shuffles. The first two are tests, so RESOLVE needs a test suite. In practice a few inputs are usually enough, because at a fixed size most GPU kernels access the same memory no matter what values the inputs hold.\n\n*Figure 2. RESOLVE on a toy kernel. (1) We test that the warp-shuffle kernel\nalways produces the same bits. (2) An agent rewrites it as a single-threaded\nprogram, and we check on the GPU that the bits still match. (3) We prove that\nthe reduced program and the reference compute the same sum over the real\nnumbers. The two add in a different order, so their bits can differ, but no\ntolerance is needed.*\n\n**Step 1: Test.** First we check that the kernel is deterministic. RESOLVE runs\nit many times while inserting random delays, using\n[NVBit](https://github.com/NVlabs/NVBit) to instrument the compiled GPU binary (SASS) directly, and\nchecks that the output bits never change. The idea goes back to\n[DataCollider](https://www.usenix.org/conference/osdi10/effective-data-race-detection-kernel),\nwhich inserted delays to catch races in the Windows kernel; RESOLVE brings it\nto GPU binaries. Because it instruments the final binary, RESOLVE doesn’t care\nwhat language the kernel came from, and it doesn’t need a formal model of\nmemory ordering, TMA or warps, since it only looks at the outputs the\nhardware produces. To tune it, we injected 143 synchronization bugs into\nKernelBench Level 1 kernels and used them to calibrate how long each delay lasts\nand how often delays are inserted. With those settings, the tester caught all 92\nbugs that run, change the output, and aren’t confined to a single warp, and a\ntest takes only a median of 88 seconds per kernel for this benchmark.\n\n**Step 2: Reduce.** Next, an agent rewrites the optimized kernel, whatever\nlanguage it was written in, into a reduced-concurrency CUDA program with the\nconcurrency features we don’t have rigorous models for stripped out: typically a\nsingle thread (or a single warp where tensor cores need it), plain loops, no\nbarriers, no asynchronous copies. A heavily fused kernel, such as a\nmega-kernel, can also be split into a sequence of small, simple kernels, run\none after another, that together produce exactly the same bits as the fused\noriginal. Blocks then no longer wait on each other through flags; the kernel\nboundaries do that job.\nWe only accept the rewrite if its outputs match the original bit for bit on\nthe GPU across all our tests. We reduce the\nreference the same way. The reference in Figure 2 is simple enough that it is\nalready reduced, but in practice we take references from stable versions of\nPyTorch or Hugging Face models, and those need reducing too.\n\n**Step 3: Prove.** Finally, we prove in Kuiper that the two reduced programs\ncompute the same mathematical function. Kuiper proves the arithmetic over the\nreal numbers, so the optimized kernel and the reference can add things up in\na different order and still be proved equal, with no tolerance. But unlike\nmodels that treat floats purely as reals, Kuiper decides every comparison and\nbranch on the actual floats, including infinity and NaN. That is how our\nproofs found bugs a purely real-valued model can’t see, such as an `argmax`\nthat skipped NaN logits and a sum that overflowed to infinity. Agents write the proofs, including the usual\nhard parts such as loop invariants (over 300 in the [mega-kernel proofs](https://github.com/FStarLang/kuiper-megakernels/tree/main/proofs) alone),\nand F* checks them. Working on the reduced-concurrency programs keeps these\nproofs manageable.\n\nAgents do much of the work in Steps 2 and 3. Figure 3 shows what they write in each step and what checks it.\n\n*Figure 3. What agents do in each step of RESOLVE, and what checks their work.\nThe specification itself gets separate checks, described in\n[Checking the specifications](#checking-the-specifications).*\n\nSee the [RESOLVE paper](https://arxiv.org/abs/2610.05683) for results on\nbenchmarks and on deployed kernels written in a variety of languages and\nlibraries, including CUTLASS, Gluon and Triton.\n\n### Requiring determinism\n\nRequiring determinism is the central design decision in RESOLVE. It is a pragmatic choice, and we think it is a new way to connect testing and proof. If a kernel produces the same bits on every run, however its threads are scheduled, then its output is a function of its input, and the GPU can tell us what that function is. The reduced program then only has to match those bits, and the proof only has to reason about a reduced-concurrency program, not every way the threads could interleave. We only need this at a fixed configuration: a kernel may produce different bits at different batch sizes, for example because it picks a different tiling.\n\nThe price is that RESOLVE can’t handle kernels that are nondeterministic on\npurpose, such as a sum computed with floating-point `atomicAdd`. In practice\nthat was rare: in a recent run of agent-optimized KernelBench Level 1 kernels,\nwe found only one kernel that was not deterministic by design. More often,\nnondeterminism was a sign that it wasn’t clear what the kernel should\ncompute. In FlashMoE, which tokens get dropped when an expert is full\ndepended on which thread block got there first. An agent with our tools made\nthe kernel deterministic at 0.8% overhead. Determinism is also becoming a\ngoal in its own right for\n[LLM inference](https://thinkingmachines.ai/blog/defeating-nondeterminism-in-llm-inference/),\nso we expect this requirement to get easier to meet over time.\n\n### Choosing test inputs\n\nThe properties that Steps 1 and 2 establish hold only for the inputs we run;\nhowever, two things keep the number of inputs we need small. First, RESOLVE\nis concerned with optimizing model deployments (such as the mega-kernels\nbelow, each built for one model), not general library routines that must work\nat every size. A deployment runs with a handful of shapes and batch sizes, so\nthose are the sizes we check. Second, at a fixed size\nmost kernels touch the same memory and take the same branches whatever values\ntheir inputs hold. This was true of 52 of 76 CUDA SDK kernels in\n[one study](https://doi.org/10.1145/2254064.2254110) and of about 60% of\n2,770 kernels in [another](https://doi.org/10.1145/3689797). When\na kernel does branch on its data, the branches are usually simple: a ReLU\nkernel only checks whether each value is above zero, so any input with both\nsigns covers both paths. As we’ve examined kernels, we’ve found that a few\ndistributions reach every branch we could find.\n\n## Mega-kernels\n\nMega-kernels are a good example of how hard AI kernels are being pushed.\nInstead of launching one kernel per operation, they run an entire model\nforward pass in one long-lived launch, using most of the complex features we\ndiscussed at the start (TMA, asynchronous memory copies, warp operations,\netc.). Thread blocks stay on the GPU, pull work off queues, and signal\neach other through flags in memory.\n[Mirage’s persistent kernel](https://arxiv.org/abs/2512.22219) compiles a\nwhole model into one such kernel, [LUCE](https://www.lucebox.com/blog/megakernel)\nruns a full decoder in a single launch, and\n[FlashMoE](https://arxiv.org/abs/2506.04667) fuses mixture-of-experts routing,\ndispatch and the experts themselves. Industry is moving this way too, for\nexample [AMD on MI355X](https://rocm.blogs.amd.com/software-tools-optimization/megakernel-intro/README.html).\nMost fully formal tools aren’t able to express these kernels; the reduction\nstep is what makes them tractable.\n\nFor each mega-kernel we start from a reference: the Hugging Face model for\nMirage and LUCE, and a straightforward implementation of the router for\nFlashMoE. RESOLVE reduces both the reference and the mega-kernel to\n[reduced-concurrency CUDA programs](https://github.com/FStarLang/kuiper-megakernels/tree/main/kernels) whose outputs match the originals bit for\nbit. It breaks each reduced program into smaller computations, such as\nnormalization and attention, and proves that corresponding computations in\nthe reference and the mega-kernel satisfy the same\n[shared specification](https://github.com/FStarLang/kuiper-megakernels/blob/main/proofs/mirage-spec/KPlay.Spec.fst).\nIt then combines these proofs to establish that the two programs compute the\nsame function, under the assumptions listed below.\n\n| Mega-kernel | Workload checked | Spec relation | \n|---|---|---|\n| Mirage | Qwen3-0.6B, 28 layers, one request with a 7-token prompt, generating the first token | [shared specification](https://github.com/FStarLang/kuiper-megakernels/blob/main/proofs/mirage-spec/KPlay.Spec.Review.fsti) | \n| LUCE | Qwen3.5-0.8B, 24 layers, prompt lengths 1 to 8, up to 5 decode steps | [shared specification](https://github.com/FStarLang/kuiper-megakernels/blob/main/proofs/luce-spec/KPlay.Spec.Review.fsti) | \n| FlashMoE | The router (projection, softmax, top-1 selection, capacity), not the expert MLPs | [shared specification](https://github.com/FStarLang/kuiper-megakernels/blob/main/proofs/flashmoe-spec/KPlay.Spec.Review.fsti) | \n\nTo get there, we added 15 new floating-point operations to\n[Kuiper](https://github.com/FStarLang/kuiper), such as fast exponentials,\nflush-to-zero arithmetic and math functions built from bit manipulation\ntricks. Each one runs within a single thread, so under our real-valued\napproximation its meaning is simply its real-number counterpart; that is why\nadding them was straightforward. As formal models of PTX mature, such as those\nbehind [TensorLean](https://tensorlean.ai),\n[TxVerify](https://github.com/mlc-ai/tx-verify) and\n[SF Tensor’s work](https://sf-tensor.com/engineering/formalizing-ptx), we hope\nto reuse their semantics for single-threaded operations, such as arithmetic\nand conversions, rather than adding them one at a time. We also\nupstreamed three new array lemmas to F*/Pulse\n([merged](https://github.com/FStarLang/FStar/pull/4786)), and\n[submitted a fix](https://github.com/FStarLang/FStar/pull/4899) for an F*\ncompiler bug.\n\nPer mega-kernel, the median time was about 0.6 hours for testing, 3.2 hours\nfor reducing (including splitting into families) and 6.8 hours for proving.\nWith a capable model (for example Claude Opus 5.5) in an agent framework that\ncan compile and run code, such as GitHub Copilot CLI, we never saw the agent\nfail to reduce a kernel. That includes LUCE, which we couldn’t yet reduce when\nwe wrote the [RESOLVE paper](https://arxiv.org/abs/2610.05683), due to\nunsupported tensor core shapes.\n\nAlong the way we found these new problems. For each one, we gave an agent the RESOLVE tools and asked it for an efficient fix, and so far the agents have produced one readily.\n\n| Kernel | What went wrong | Found by | Upstream | \n|---|---|---|---|\n| LUCE | Attention blocks overwrote each other’s scratch results | Concurrency testing | [#761](https://github.com/Luce-Org/lucebox/pull/761) (merged) | \n| LUCE | In-place rotary embedding read a value after overwriting it | Manual inspection* | [#804](https://github.com/Luce-Org/lucebox/pull/804) (merged) | \n| Mirage | `argmax` started from −50000 instead of −∞ | Proof | [#793](https://github.com/mirage-project/mirage/pull/793) (merged) | \n| Mirage | A real attention score of −50000 was treated as masked | Proof | [#840](https://github.com/mirage-project/mirage/pull/840) (open) | \n| Mirage | Summing values before normalizing overflowed to ∞ when the correct result was finite | Proof | [#840](https://github.com/mirage-project/mirage/pull/840) (open) | \n| FlashMoE | Dropped tokens depended on thread-block arrival order | Concurrency testing | [#32](https://github.com/osayamenja/FlashMoE/pull/32) (open) | \n| LUCE | `argmax` skipped NaN logits and could return an invalid token (−1) | Proof | [#1026](https://github.com/Luce-Org/lucebox/pull/1026) (merged) | \n\n* Initially found by manual inspection, and later also identified by our proof pipeline.\n\nThe two stages catch different kinds of bugs. Concurrency testing found the races, where blocks or threads stepped on each other’s data. The proofs found bugs in the math itself, like a sentinel value that real data can hit or a sum that overflows to infinity, which no amount of schedule perturbation would expose.\n\nWe also independently discovered and reproduced two problems that the developers fixed upstream:\n\n| Kernel | What went wrong | Found by | Upstream fix | \n|---|---|---|---|\n| Mirage | Uninitialized tile padding and two missing barriers in attention | Concurrency testing | [#768](https://github.com/mirage-project/mirage/pull/768) | \n| LUCE | Grid-barrier reset raced with arriving blocks | Concurrency testing | [#40](https://github.com/Luce-Org/lucebox/pull/40) | \n\nFor Mirage, we posted our reproduction in\n[#777](https://github.com/mirage-project/mirage/pull/777) three days after\n#768 was opened and before it was merged, and closed ours in favor of it. For LUCE, the fix came from a\n[community report](https://github.com/Luce-Org/lucebox/issues/28), and the\n[blog post](https://www.lucebox.com/blog/megakernel) introducing the kernel\nmentions running into grid-synchronization problems during development. In\nboth cases, running our concurrency testing on versions from before the fix\nreproduced the problem quickly.\n\nWe thank the LUCE and Mirage developers, especially\n[@davide221](https://github.com/davide221),\n[@jiazhihao](https://github.com/jiazhihao) and\n[@Electronic-Waste](https://github.com/Electronic-Waste), for taking the time\nto review our pull requests.\n\n## Decomposing and proving mega-kernels\n\nEach reduced mega-kernel breaks into families of operations, and each family\nis proved separately before the proofs are composed. For Mirage there are four\n(Figure 4): the embedding with its positional tables, the decoder layer (once\nfor each of the 28 layers), the final normalization with the projection onto\nthe vocabulary, and the `argmax` that picks the next token. The reduced\nmega-kernel makes 256 kernel launches for this workload, and the proof needs\nto cover each. The one family specified over the floats themselves, rather\nthan the reals, is the final `argmax`, where the family proofs are joined\ntogether.\n\n*Figure 4. How the Mirage proof is put together. We explain below why\n`argmax` is specified over floats rather than reals.*\n\n### Argmax: ties, types and exceptional values\n\nPyTorch’s `argmax` returns the first index of the largest logit. Mirage’s\ncomputes it in parallel: each thread finds the largest logit in its share of\nthe vocabulary, and the partial winners are then compared in a tree. When two\nlogits tie, which one survives depends on how the tree pairs them, not on\nwhich index is smaller: with equal maxima at token IDs 1 and 2, Mirage returns\n2 and PyTorch returns 1. Both are reasonable answers, but they are different\ntokens, so no tolerance can reconcile them. To address this, we specify\n`argmax` as returning any index of a maximal value, which both programs\nsatisfy.\n\nThe bigger issue is types. Every other family is proved to compute the\nreference’s math over the real numbers, with the actual floats only\napproximately related to those reals. That argument breaks down at `argmax`:\nthe two programs compute different floats, so close logits can come out in a\ndifferent order and the programs pick different winners.\nSo we specify `argmax` exactly, over the floats the previous stage actually\nproduced, and stitch the families together at that boundary. Thus the final\ntheorem says that each program picks a maximal token from logits that\napproximate the reference’s, but not that both programs pick the same token.\n\nSpecifying `argmax` over floats also covers exceptional values. PyTorch’s\n`argmax` returns the first NaN if there is one. LUCE’s skipped NaNs, and when\nevery logit was NaN or −∞ it returned −1, which isn’t a valid token. A strictly\nreal-valued analysis couldn’t have caught this, since NaN and −∞ don’t exist\nover the reals; our proof caught it because of the way we model floats, and\nthe fix is merged ([#1026](https://github.com/Luce-Org/lucebox/pull/1026)).\n\n## Checking the specifications\n\nWe also check the specifications themselves, in two opposite\ndirections, much like the two measures used to\n[judge LLM-written postconditions](https://doi.org/10.1145/3660791): a good\nspecification accepts correct code and rejects buggy code.\n\n**Is it wrong?** The reference is proved against the same specification as\nthe mega-kernel, so a specification that describes something other than what\nthe reference computes makes the reference proof fail.\n\n**Is it too weak?** A specification can hold for the reference and still say\nvery little, for example by leaving some outputs unconstrained (an earlier\npost on this blog about\n[small proof-oriented tests](https://risemsr.github.io/blog/2026-04-16-spotting-specs/)\ntackles the same worry). So we also prove that each specification is a\nfunction: over exact real numbers, it allows one answer per input. For floats\nit allows only the differences that every specification shares, like `argmax`\nties. A [script](https://github.com/FStarLang/kuiper-megakernels/blob/main/tightness.py) writes [this theorem](https://github.com/FStarLang/kuiper-megakernels/blob/main/proofs/mirage-tightness/KPlay.Tightness.Mirage.Statement.fst) from the specification itself.\n\nSpecifications also rest on facts about the hardware that the documentation\ndoesn’t quite promise. For example, Mirage compares BF16 values after\nconverting them to FP32, so the proof needs that conversion to keep their\norder. PTX implies it but doesn’t guarantee it, so we [assume it](https://github.com/FStarLang/kuiper-megakernels/blob/main/support/mirage-cleanroom/Kuiper.Float.Casts.Raw.fsti) and checked all\n65,536 BF16 values on the GPU. Most of what our proofs rely on is either\ndocumented or covered by testing, but cases like this one will keep coming up\nas the hardware and programming languages evolve.\n\n## What we’re still trusting\n\nEvery result about GPU kernels rests on assumptions. Here are some of ours.\n\n- Our concurrency results come from testing, not proof. If a race never changes the output on the GPU we test on, we won’t see it. We also can’t currently insert delays between threads in the same warp.\n- Our testing and reduction hold for the binaries, compilers, GPUs and inputs\nwe used, and the proofs cover the model sizes, batch sizes and prompt lengths\nwe list. For Mirage, the scenario we picked used one request whose KV cache\nfit in a single page, so bugs that need several requests or pages, like the page-table offset\naddressed in [Mirage #812](https://github.com/mirage-project/mirage/pull/812) , are\noutside what we checked. We are actively working on scaling the proofs to\ncover them.\n- The result is only as meaningful as the reference: the Hugging Face model for Mirage and LUCE, and a router we wrote ourselves for FlashMoE.\n\n## What’s next\n\nRESOLVE uses testing to cover the gap in GPU semantics, rather than closing it. Today, we don’t see a rigorous way to validate deployed kernels end to end, at the pace people are writing them, without leaning on testing somewhere, and running the real binary on real hardware is the most trustworthy testing we have.\n\nIn the longer run, we want testing to carry less of the load, so we’re also\nworking on the gap itself. [SIMT-Step](https://doi.org/10.1145/3808297) gives\nus precise language for talking about warp behavior, and\n[WarpDRF](https://arxiv.org/abs/2610.07541) proposes a simple contract that\nevery GPU we tested honors. If GPU vendors and programming frameworks commit\nto conservative contracts like this, we can prove kernels against the\ncontract rather than against one particular GPU, and those proofs will keep\nholding as the hardware changes.\n\nThe other big open problem for us is arithmetic.\n[Bit-accurate models](https://arxiv.org/abs/2511.10909) and an\n[SMT formalization](https://doi.org/10.1007/978-3-031-93706-4_21) of\ntensor-core arithmetic now exist for recent NVIDIA GPUs, and building them\ninto proofs would let us bound rounding error, and handle kernels that\napproximate a function differently from their reference, not just prove that\nthe math matches. In the meantime, RESOLVE already makes tolerance testing more useful:\nonce a kernel is deterministic and proved to compute the same math as its\nreference, any remaining difference comes from floating-point precision, so a\ntolerance test measures exactly the thing it was meant to measure.\n\nWe also want proofs that hold for every size, not just the sizes of one\ndeployment. General-purpose libraries need this, and so do serious bugs that\nonly appear at large sizes. Index arithmetic can overflow, for example:\n[GPU-Fuzz](https://arxiv.org/abs/2602.10478) found a PyTorch `ConvTranspose2d`\nkernel whose 32-bit element count wraps around and writes out of bounds, and\nvLLM [fixed a similar truncation](https://github.com/vllm-project/vllm/pull/44971)\nin its GGUF dequantize kernels as a security issue, and over half of the 582\npotential bugs that [KernelArmor](https://arxiv.org/abs/2611.18754) reported\nin production CUDA kernels were integer overflows. Kuiper uses machine\nintegers and proves they don’t overflow, so RESOLVE already catches such bugs\nat the sizes we check.\n\n## Related work\n\nThis list aims for breadth rather than completeness. If we missed your work, please let us know!\n\n**Proving GPU kernels correct.** Besides [Kuiper](https://doi.org/10.1145/3808280),\nrecent work includes [ProofWright](https://arxiv.org/abs/2511.12294),\n[Volta](https://doi.org/10.1145/3839470), [LARK](https://arxiv.org/abs/2611.02028),\n[Racer](https://arxiv.org/abs/2610.28429),\n[SF Tensor’s PTX formalization in Lean](https://sf-tensor.com/engineering/formalizing-ptx),\n[Gimlet Labs’ Z3-based equivalence checking](https://gimletlabs.ai/blog/formally-verifying-ai-generated-kernels),\n[TensorLean](https://tensorlean.ai) and\n[TxVerify](https://blog.mlc.ai/2026/11/24/what-must-we-trust-verifying-production-gpu-kernels-with-a-core-assumption-split).\nMost of these treat floating point as real arithmetic; TensorLean also bounds\nround-off error.\n\n**Static analysis of GPU kernels.** [GPUVerify](https://doi.org/10.1145/2384616.2384625),\ndeveloped in collaboration with Microsoft Research, proves kernels free of\ndata races and barrier divergence. [GKLEE](https://doi.org/10.1145/2145816.2145844)\nfinds races and deadlocks with symbolic execution,\n[Faial](https://doi.org/10.1007/978-3-030-81685-8_19) checks data-race freedom\nand is [still actively maintained](https://gitlab.com/umb-svl/faial), and\n[test amplification](https://doi.org/10.1145/2254064.2254110) generalizes race\nfreedom from a single test to all inputs. More recently,\n[KernelArmor](https://arxiv.org/abs/2611.18754) has agents write annotations\nso that a verifier can prove memory and thread safety for production CUDA\nkernels.\n\n**Concurrency testing and race detection.** The best-known systematic\nconcurrency testing tools target CPU programs, and several came out of MSR:\n[CHESS](https://www.usenix.org/conference/osdi-08/finding-and-reproducing-heisenbugs-concurrent-programs)\nand [PCT](https://doi.org/10.1145/1736020.1736040) control the thread\nschedule, and [DataCollider](https://www.usenix.org/conference/osdi10/effective-data-race-detection-kernel)\ninserts delays to catch races in the Windows kernel.\n[Race-directed random testing](https://doi.org/10.1145/1375581.1375584) steers\nthe schedule toward potential races. On GPUs,\n[Barracuda](https://doi.org/10.1145/3062341.3062342),\n[iGUARD](https://doi.org/10.1145/3477132.3483545) and NVIDIA’s\n[Compute Sanitizer](https://docs.nvidia.com/compute-sanitizer/ComputeSanitizer/index.html)\ndetect races by instrumenting the kernel.\n[SuperCollider](https://doi.org/10.1145/3808339) is the closest to RESOLVE’s\nfirst step, but it is built into NVIDIA’s `ptxas` compiler, so others can’t\neasily extend it.\n\n**Determinism, reduction and translation validation.** Determinism checking\ngoes back to [Cilk](https://doi.org/10.1145/258492.258493) and\n[Burnim and Sen](https://doi.org/10.1145/1595696.1595700), and has recently\nbecome a concern for [LLM inference](https://thinkingmachines.ai/blog/defeating-nondeterminism-in-llm-inference/),\nwhere [Vosti](https://arxiv.org/abs/2609.38981) verifies it end to end.\nOur reduction step is related to [Lipton reduction](https://doi.org/10.1145/361227.361234)\nand [sequentialization](https://doi.org/10.1007/978-3-540-70545-1_7), and our\napproach of checking each optimization rather than the optimizer follows\n[translation validation](https://doi.org/10.1007/BFb0054170) and\n[Alive2](https://doi.org/10.1145/3453483.3454030).\n\n**Verifying LLM serving systems.** One layer up from the kernels, the Hao AI Lab’s\n[vstack and veriserve](https://haoailab.com/blogs/verifiable-llm-infra/) use agents\nto model-check and prove the KV-page lifecycle of disaggregated serving in SGLang\nand vLLM.\n\n**GPU semantics and arithmetic.** See our early\n[GPU memory model work](https://doi.org/10.1145/2694344.2694391) (ASPLOS 2015),\nNVIDIA’s [PTX memory model](https://doi.org/10.1145/3297858.3304043),\n[Dartagnan](https://github.com/hernanponcedeleon/Dat3M), a community\n[SIGARCH post](https://www.sigarch.org/gpu-memory-consistency-specifications-testing-and-opportunities-for-performance-tooling/)\non memory-model specifications, and, for tensor-core arithmetic,\n[Khattak and Mikaitis](https://doi.org/10.1145/3830409),\n[Valpey et al.](https://doi.org/10.1007/978-3-031-93706-4_21) and\n[FTTN](https://doi.org/10.1109/CCGRID59990.2024.00014).", "url": "https://wpnews.pro/news/test-reduce-prove-validating-the-most-complex-ai-gpu-kernels-with-resolve", "canonical_source": "https://risemsr.github.io/blog/2026-12-03-resolve-megakernels/", "published_at": "2026-12-04 02:43:07+00:00", "updated_at": "2026-12-04 03:17:11.200143+00:00", "lang": "en", "topics": ["ai-research", "ai-safety", "ai-infrastructure", "mlops", "developer-tools"], "entities": ["RESOLVE", "Mirage", "LUCE", "FlashMoE", "Kuiper", "F*", "Microsoft", "GPUVerify"], "also_reported_by": [], "takeaway": "RESOLVE reduces mega-kernels like Mirage, LUCE and the FlashMoE router to simpler programs provably equivalent to their references, surfacing bugs that post-release testing missed and yielding 6 upstream fix PRs, 4 merged.", "recommendation": {"advice": "Before trusting agent-optimized GPU kernels, reduce them to simpler programs and formally prove equivalence to a reference on your actual shapes and batch sizes; this surfaced bugs in Mirage, LUCE and FlashMoE that shipped undetected.", "playbook": "evals-testing", "playbook_url": "https://wpnews.pro/playbooks/evals-testing"}, "alternates": {"html": "https://wpnews.pro/news/test-reduce-prove-validating-the-most-complex-ai-gpu-kernels-with-resolve", "markdown": "https://wpnews.pro/news/test-reduce-prove-validating-the-most-complex-ai-gpu-kernels-with-resolve.md", "text": "https://wpnews.pro/news/test-reduce-prove-validating-the-most-complex-ai-gpu-kernels-with-resolve.txt", "jsonld": "https://wpnews.pro/news/test-reduce-prove-validating-the-most-complex-ai-gpu-kernels-with-resolve.jsonld"}}