Manuscript Offprint

arXiv:2610.39380

Learning to Formulate: Agentic Hardware-Software Co-Design of AI Infrastructure through Progressive Optimization and Verification

Yi Ding, Li Shang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

AI infrastructure, the chips and software that train and serve AI models, is designed in layers. Layers make the system manageable, but they also fix which choices an optimizer can consider. Gains that need the chip and its software to change together are excluded before optimization begins: the formulation leaves them out. Language-model agents make it possible to revisit these boundaries, but an agent's proposal cannot show by itself that a design is correct or optimal. We present Formulaic, a flow that divides the work. The agent writes the formulation, a mathematical solver optimizes within it, and verification and measurement check its assumptions and results. The agent refines the problem step by step, from the computation graph toward the chip. Each step is a template: a family of programs with the conditions under which they are correct. Wall relaxation searches the chip by pricing the hardware limits that bind the software. This paper takes a first step, through separate studies rather than one end-to-end run. On NVIDIA GB10, templates the agent wrote run complete Qwen3-8B layers 1.075×1.075 \times faster than SGLang. In a simulated Ventus GPU study, joint design cuts the worst-scenario cycles of Qwen2.5-0.5B to 0.428 of the reference, against 0.934 for software alone. On a five-step GEMM refinement chain, reusing proofs makes checking 2.51×2.51 \times faster.

1 Introduction

Progress in AI is increasingly limited by the infrastructure that runs it. The cost, energy and availability of computation, memory and data movement now decide what can be trained and served. Designing that infrastructure is a co-design problem across the whole stack: the workload, the software that executes it, from serving systems through compilers and kernel libraries, and the chip underneath, down to its microarchitecture. The layers are deeply coupled. Whether a kernel runs fast depends on the register file and on-chip memory; whether that memory is worth its silicon depends on whether the software can reuse data through it. The largest gains come from exactly these interactions. Yet industry develops chips and software on separate tracks, each split layer by layer behind interfaces frozen early. A chip is architected against the workloads of the past, a tile size is chosen for a register file sized for last year's tiles, and the cross-layer combinations where specialization pays off are never explored. The mismatch keeps growing: a new model can change the demands on hardware within months, while a new chip takes years.

Layered design makes complex systems manageable, but it also fixes which interactions an optimizer can consider. Some missed opportunities therefore arise before optimization begins: they are excluded by the formulation. Removing every boundary is not an easy fix either. Written all at once, with every choice of tiling, data movement, scheduling and hardware resource exposed together, co-design becomes a very large mixed-integer program that is hard to solve at useful scale. Layer-wise engineering is a fixed, hand-made formulation that stays solvable by giving up cross-layer interactions; the monolithic model keeps every interaction and gives up solvability. The question is how to find a formulation in between, one that exposes the cross-layer choices that matter while staying small enough to solve.

Language-model agents are already applied to parts of this problem. Agents write and optimize GPU kernels in CUDA and Triton [1, 2, 3, 4, 5], generate and optimize RTL [6, 7] and reason about processor architectures [9], and evolutionary coding agents have found programs and algorithms that people had not [10, 11]. Many of these systems pair the agent with strong evaluators: profilers, test suites and, in some cases, formal equivalence checks and reusable skill libraries [7]. What they usually do not produce is an explicit optimization formulation: a written statement of the choices, the constraints that keep them correct, and the cost that ranks them. Without one, it is hard to say whether a better design exists in the space the agent considered, which assumptions a design relies on, or where else an idea holds.

Language-model agents create an opportunity to revisit these boundaries, by constructing and revising formulations that expose useful cross-layer choices. Their proposals, however, cannot establish correctness or optimality by themselves. Formulaic explores a division of responsibility in which agents propose formulations, mathematical solvers optimize within them, and verification and measurement check their assumptions and consequences, sending a formulation back for repair when it fails [12, 13, 14]. We call this using the agent as a white box. The term means that the formulation is explicit and the evidence for it can be inspected; it says nothing about the model's internals. The flow is organized around one idea. A language-model agent refines the co-design problem step by step, from the workload down toward the chip microarchitecture. Each step is a template that a solver can optimize and a verifier can check. Because each step adds few decisions, the search and the proof can stay small.

Templates proposed by the agent. A template is a design pattern packaged with the conditions under which it is correct. The same conditions bound the solver's search, give the verifier its preconditions and tell the agent where the template may be reused, and we seek the weakest such conditions [15]. Proved templates are kept, with their measurements, in an evolving population [16, 17], so a formulation found for one problem seeds the next.

Hardware–software co-optimization. Progressive refinement descends from the computation graph to the microarchitecture, and each step solves a small formulation over the few decisions it adds. On the chip side, the best software presses against a few hardware limits, which we call walls. Wall relaxation prices each wall by re-solving with it moved one step, buys the step that recovers the most latency per unit of area, and repeats, so every chip it visits comes with the best software in the model's menu.

Verification in the loop. Because each step adds little, each step owes only a local proof that its finer transactions implement the coarser one. Local proofs compose back to the workload and are reused when their premises are unchanged, so verification runs inside the loop, not as an audit at the end.

Results. This paper takes a first step in this direction through a common template representation and complementary studies of formulation construction, hardware–software optimization and verification reuse. The studies are separate; running the whole loop on one design is future work. We first set the stage on software alone. On NVIDIA GB10 with the chip fixed, the agent’s templates are on par with the industry state of the art: complete Qwen3-8B layers run 1.075×1.075 \times faster than SGLang (geometric mean over eight scenarios), hybrid-MoE layer groups beat SGLang in seven of eight scenarios, and against a black-box coding agent given the same caps, one run each, the flow’s program is faster at every input length. Co-design then adds what software alone cannot reach. In a Ventus GPGPU study that simulates 128-token prefill and extrapolates the 512-token scenarios, letting the chip change with the software cuts the worst-scenario cycles of Qwen2.5-0.5B to 0.428 of the reference, against 0.934 for the best software-only design, a 2.2×2.2 \times gain under the same area ceiling. In a separate complete instruction-simulation study, a 64×6464 \times 64 tile that is slower on the reference chip becomes part of the best design once registers, tensor shape and cache change together. Finally, verification can stay affordable inside the loop: reusing proofs speeds up checking of a five-step refinement chain by 2.51×2.51\times, real agent edits save less (1.25×)(1.25\times), and local checks catch the faults injected at every step.

References (94)