# God Does Not Play Dice: Enforcing Batch Invariance in Agentic Kernel Generation

DevFeed: [God Does Not Play Dice: Enforcing Batch Invariance in Agentic Kernel Generation](<https://devfeed.tech/articles/god-does-not-play-dice-enforcing-batch-invariance-in-agentic-kernel-generation-103164.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2610.36623>)

Author: Youwei Bao, Chengpeng Wang, Simin Chen

Published: 2026-10-28T04:00:00Z

Content type: article

Language: en

Sources: [arXiv: Artificial Intelligence](<https://devfeed.tech/sources/arxiv-artificial-intelligence.md>), [arXiv: Machine Learning](<https://devfeed.tech/sources/arxiv-machine-learning.md>), [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [reproducibility](<https://devfeed.tech/topics/reproducibility.md>), [agentic-coding](<https://devfeed.tech/topics/agentic-coding.md>), [LLM optimization](<https://devfeed.tech/topics/llm-optimization.md>), [Loop Engineering](<https://devfeed.tech/topics/loop-engineering.md>), [Large Language Model](<https://devfeed.tech/topics/llm.md>)

Tags: [acceptance](<https://devfeed.tech/tags/acceptance.md>), [agent-frameworks](<https://devfeed.tech/tags/agent-frameworks.md>), [agentic](<https://devfeed.tech/tags/agentic.md>), [agents](<https://devfeed.tech/tags/agents.md>), [analysis](<https://devfeed.tech/tags/analysis.md>), [batch](<https://devfeed.tech/tags/batch.md>), [benchmarking](<https://devfeed.tech/tags/benchmarking.md>), [bi](<https://devfeed.tech/tags/bi.md>), [consistency](<https://devfeed.tech/tags/consistency.md>), [cs-ai](<https://devfeed.tech/tags/cs-ai.md>), [cs-lg](<https://devfeed.tech/tags/cs-lg.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [efficiency](<https://devfeed.tech/tags/efficiency.md>), [experiments](<https://devfeed.tech/tags/experiments.md>), [feedback](<https://devfeed.tech/tags/feedback.md>), [generation](<https://devfeed.tech/tags/generation.md>), [gpu](<https://devfeed.tech/tags/gpu.md>), [invariance](<https://devfeed.tech/tags/invariance.md>), [kernel](<https://devfeed.tech/tags/kernel.md>), [llm-serving](<https://devfeed.tech/tags/llm-serving.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [performance](<https://devfeed.tech/tags/performance.md>), [real-world](<https://devfeed.tech/tags/real-world.md>)

## AI overview

Dynamic batching in LLM serving can change a kernel's numerical output for the same input when the kernel lacks batch invariance (BI), harming reproducibility. The authors report 19 confirmed BI violations among 83 batch-applicable released artifacts. Their plug-in, \tool, adds contract-guided static dependency analysis and dynamic bitwise-consistency checks to kernel agents' optimization loop. It rejects structurally risky or non-invariant candidates before performance benchmarking and returns feedback for revision. Across three agent frameworks on real-world LLM serving tasks, BI-aware generation raised the BI pass rate from 67.6% to 91.9% while retaining 91.8% of baseline geometric mean speedup.

## Source excerpt

arXiv:2610.36623v1 Announce Type: new Abstract: Large language model (LLM) serving systems dynamically batch user requests for GPU execution, so the same request may be processed alongside different requests across runs. If the GPU kernels lack batch invariance (BI), this changing batch context can alter the numerical output for an unchanged input, undermining reproducibility. Existing kernel generation agents focus on correctness and efficiency but \emph{overlook BI}. We find 19 confirmed BI violations among 83 batch-applicable released artifacts. To address this limitation, we propose \tool, which combines contract-guided static dependency analysis with dynamic validation of bitwise consistency across batch contexts. \tool is designed as a plug-in component for general kernel agents, allowing their original optimization capabilities to be reused while adding BI enforcement. We integrate it as successive acceptance gates in the optimization loop, rejecting structurally risky or dynamically non-invariant candidates before performance benchmarking and returning feedback to the agent. Experiments across three agent frameworks under baseline and BI-aware generation on real world LLM serving tasks show that \tool improves the BI pass rate from 67.6\% to 91.9\% while retaining 91.8\% of the baseline geometric mean speedup. These results demonstrate that \tool can be incorporated into kernel optimization by agents as an additional reliability objective alongside correctness and speed.