Hierarchy-Aligned Agents for Whole-Block GPU Fusion

Current LLM agents for GPU code split work by job: one agent plans, one writes code, one debugs, one profiles. They also optimize one kernel at a time. A kernel is a single program launched on the GPU. Modern chips such as NVIDIA's H100 and B200 get their largest wins from a different kind of work. Several operators (say, a normalization, two matrix multiplies and an activation) are fused into one program. Their intermediate results stay in fast on-chip memory, and that memory is shared across a cluster of processor cores instead of spilling to slow main memory. This proposal builds a multi-agent system whose division of labor follows the chip's memory hierarchy rather than the stages of a software workflow. A cluster-level agent decides how a whole transformer block is split across groups of cores and what data moves between them. A core-level agent writes the tiled computation inside each group. A warp-level agent handles instruction pipelining. Explicit, machine-checked resource contracts sit between the levels, stating how many bytes of on-chip memory, how many registers and how much cross-core traffic each level may use.

The payoff is twofold. It targets a regime where existing agent systems are known to fall short: the authors of KForge observe that optimizing an isolated kernel can change how many threads the GPU keeps active, which slows later stages, and they leave whole-block optimization to future work. It also gives a concrete answer to the "cascading error" problem of multi-agent pipelines. When a candidate breaks a contract, the violation says which level failed, so the system can backtrack at that level instead of regenerating everything.

Core Claim

For fused, multi-operator GPU blocks, decomposing the agent team along hardware levels, with budgets that are checked at compile time before anything runs, will find faster correct implementations than decomposing by workflow role at the same token and hardware-evaluation budget. The advantage should come specifically from two ingredients. The first is access to cross-core shared memory, which NVIDIA calls distributed shared memory (DSM). The second is contract-based blame assignment. Neither ingredient alone should be sufficient.

Relation to Prior Work

Several systems already combine multi-agent decomposition with kernel optimization, and they motivate this proposal by leaving the same gap open. They all decompose by workflow role, and all optimize individual kernels:

  • STARK uses Plan, Code and Debug agents over a search tree.
  • Astra adds Testing and Profiling agents for existing production kernels.
  • KernelSkill uses seven agents with long-term and short-term memory.
  • KForge pairs a generator with a profiler-reading analyst.

Two other systems are the closest to our routing and representation choices.

  • AKG Kernel Agent has a Conductor that routes failures by error type: syntax errors go back to the Coder, numerical errors go back to the Designer. We route by which resource budget was violated. That is a finer signal and is tied to the hardware.
  • CAKE supplies part of our method. It has agents assign memory tiers, pipeline depths and warp roles in a typed intermediate representation, and runs cheap static checks before hardware runs. On B200 it reports that agents writing raw CUDA/PTX reached only 0.928x of a tuned baseline, versus 1.144x with its typed representation. We reuse this "hardware-explicit, layout-implicit" stance, and the layout abstraction of Axe, so that agents never hand-write index arithmetic. Neither CAKE nor Axe splits the agent team by hierarchy level or reasons about cluster-wide fusion of whole blocks.

The main constraint comes from outside the agent literature. FlashFuser shows that fusing operators across multiple cores via DSM on H100 cuts memory access by 58%. It reports 3.3x speedups over tuned libraries on GEMM chains, convolution chains and gated feed-forward layers. It gets there with an analytical cost model and template-based search, not LLMs. This is both an opportunity and a threat. The opportunity is that it shows DSM fusion is where the headroom is. The threat is that on the operator patterns its templates cover, a compiler may simply beat agents. We therefore use FlashFuser's own workloads as a check. We claim agent value only on blocks outside its templates: non-standard attention such as DeltaNet and Kimi Delta Attention, mixture-of-experts routing and combine stages, and irregular KernelBench compound operators.

KernelBand also constrains our design. It reports that letting the LLM freely pick optimization directions from profiler metrics underperforms a hardware-aware bandit. We therefore do not let the cluster-level agent's own judgment select its plans. Its proposals are first scored by a FlashFuser-style analytical traffic model, and only the top candidates are lowered to code.

Research Program

Specification. The system takes a PyTorch reference for a whole block, for example RMSNorm, then the gated FFN, then the residual add. This is the same input format KernelBench uses.

Cluster agent. This agent proposes a fusion plan. A plan specifies:

  • how the block's operators are grouped,
  • the cluster size (how many thread blocks share DSM),
  • which intermediate tensors stay in shared memory, which travel over DSM, and which spill to main memory.

For each group, the cluster agent issues a contract to the level below. The contract states the shared-memory bytes per thread block, the DSM bytes exchanged per step, the register budget per thread, and a minimum occupancy target. The analytical model ranks the proposed plans by estimated main-memory traffic and inter-core traffic, and only the top-$k$ plans proceed.

Core-level agent. For each group, this agent writes the tiled computation in a CAKE/Axe-style typed representation, within its contract.

Warp-level agent. This agent chooses pipeline stages, asynchronous copy and matrix-unit instructions, and warp specialization.

Contract checking and blame. After compilation, the compiler's resource report and a static synchronization checker verify every contract before the candidate runs on hardware. Violations are attributed as follows:

  • An overspent register budget goes back to the warp agent.
  • A shared-memory overflow within the promised tile shape goes back to the core agent.
  • A contract that no implementation below it can satisfy returns to the cluster agent, together with the observed lower bound. The next plan the cluster agent proposes is then informed by real limits.

Correctness, profiling and memory. Numerical testing and profiling follow Astra's separation of testing from timing. A tree memory in the style of STARK is kept per level.

Analysis. Beyond speed, we will label a sample of failed candidates by hand with their true root-cause level. We then measure how often contract-based blame agrees with that label, compared with AKG-style error-type routing. This tests the mechanism directly, not only the end result.

Baselines

Naive reference points. The do-nothing reference is PyTorch Eager. The strong non-agent compiler reference is torch.compile in max-autotune mode, run on the same shapes and GPU. A second naive agent reference optimizes each kernel of the block separately with the best role-based agent and then runs the kernels in sequence. This reference is the one that shows whether per-kernel wins disappear once the kernels are composed, as KForge warns.

Strongest existing agent method. This is KernelSkill, which reports average speedups over Torch Eager of 2.82x on KernelBench Level 2 and 1.92x on Level 3, with 100% of tasks compiled and verified (KernelSkill). STARK is a second strong reference, reporting up to 3.03x over Eager and beating max-autotune (STARK). Both will be run on H100 and B200 rather than their original hardware. They get the same base LLM, the same per-task token budget, the same number of hardware evaluations, and permission to emit cluster and DSM code. If their code is unavailable, we will reimplement them from the papers and report our reimplemented numbers alongside theirs. Beating them means higher geometric-mean speedup and a higher $\text{Fast}_{1.0}$ rate: the share of tasks that are both correct and faster than max-autotune. This must hold on Levels 2 and 3 at matched budget, with confidence intervals from three seeds.

Compiler competitor. On gated FFN chains with Llama3-70B and Qwen2.5 shapes, the competitor is FlashFuser, which reports 3.3x over tuned libraries and a 58% memory-access reduction (FlashFuser). Matching it there is enough. Beating it is not expected. The claim is only about coverage beyond its templates.

Emerging attention workloads. Here the references are the official FlashKDA implementation and Hawkeye's reported 18.9x geomean over compilers on emerging attention variants (Hawkeye). We will cite that figure rather than rerun Hawkeye unless its code is obtainable.

Ablations. Four ablations isolate the key ingredients:

  • Roles, not levels. The same agents and budget, but split into plan, code and debug roles.
  • Levels, no contracts. Hierarchy agents that communicate in free-form text instead of checked budgets.
  • No DSM. Clusters of size one, so no cross-core shared memory.
  • No cost model. The cluster agent's plans go straight to lowering without ranking.

Why not just…?

Why not just run STARK or KernelSkill on the whole block as one big kernel? This is the most serious threat. Nothing in principle stops a role-based planner from proposing DSM fusion. The "roles, not levels" ablation is designed to settle it. It uses the same model, budget and representation, and changes only how the work is split and whether failures carry level-specific blame. If it matches the full system, the contribution reduces to "give existing agents DSM and a typed representation," and we would report exactly that.

Why not let FlashFuser's cost model choose the fusion plan and have one agent fill in the code? This hybrid might work as well as our system on regular GEMM chains, which is why we compare against FlashFuser directly on its own workloads. It is also why our cluster agent keeps a cost model as a filter rather than competing with one. The case for agents rests on blocks whose dataflow is not a GEMM chain, such as DeltaNet-style recurrences and mixture-of-experts combine stages, where no template exists. The "no cost model" and "roles, not levels" runs will show whether the agent's plan proposals add anything beyond what enumeration plus a single coder achieves.

Why not optimize each kernel with an existing agent and chain them? This is cheaper and reuses mature tools. However, KForge reports that isolated optimization can reduce occupancy in later stages. FlashFuser's 58% memory reduction also exists only because intermediates never leave the chip, which chained kernels cannot achieve. The per-kernel-then-compose baseline measures this gap on real blocks rather than assuming it.

Why not use a single strong reasoning model with long context? Astra's ablation found a single agent reached 1.08x against 1.32x for its multi-agent system on SGLang kernels (Astra). KernelBench reports that out of the box, models match Eager in fewer than 20% of cases (KernelBench). Whole blocks enlarge the context further. We nonetheless include a single-model run at matched tokens, because newer reasoning models could narrow this gap.

Proposed Experiments

Workloads. - KernelBench Levels 2 and 3, on H100 and B200. - Gated FFN blocks at the Llama3-70B and Qwen2.5-14B/32B shapes used by FlashFuser. - Mixture-of-experts decode blocks at GPT-OSS-20B shapes. - Kimi Delta Attention and Gated DeltaNet prefill blocks.

Metrics. - $\text{Fast}_p$ at $p = 1.0$ and $1.5$ against max-autotune. - Geometric-mean speedup. - Main-memory bytes moved, measured with the Nsight profiler. - Tokens spent and hardware evaluations per correct kernel. - End-to-end serving throughput in SGLang for the best blocks. FlashFuser's reported averages there are 1.32x on real LLMs and 1.24x overall, which serve as reference points.

Decisive checks. There are three:

  • At matched budget, the full system beats the "roles, not levels" ablation on Level 3 and on the non-template blocks by a margin outside seed variance.
  • Removing DSM erases most of that margin, which shows the gain comes from cross-core fusion and not from prompt structure.
  • Contract-based blame agrees with hand-labeled root causes more often than error-type routing does, and this higher agreement coincides with fewer wasted regenerations.

If the first check fails, the hierarchy idea is wrong. If the first passes but the second fails, the gain is organizational rather than hardware-specific, and we would report it as such.