AVO: Agentic Variation Operators for Autonomous Evolutionary Search

kernel 2603.24517
attention-kernelevolutionary-searchagentic-optimizationNVIDIA-Blackwellwarp-specializationFlashAttention

AVO: Agentic Variation Operators for Autonomous Evolutionary Search — L2 #

§1 TL;DR #

AVO 将 LLM coding agent 提升为进化搜索的 variation operator,在 NVIDIA B200 上经 7 天自主进化产出 attention kernel:causal MHA 超越 cuDNN 至多 3.5%、FA4 至多 10.5%,峰值 1668 TFLOPS (BF16);优化 30 分钟迁移至 GQA。

§2 Q1 / Q2 / Q3 #

Q1 痛点 #

现有 LLM-augmented evolutionary search 框架(FunSearch、AlphaEvolve、LoongFlow)将 LLM 限制在固定流水线的 Generate 环节:框架负责 Sample(亲本选择)和 evaluation,LLM 仅做单轮代码生成。LLM 无法自主查阅硬件文档、运行 profiler、诊断编译/正确性失败、或根据累积反馈修改优化策略。对 Blackwell 上已被深度手工优化的 attention kernel(FA4 历经数月人工调优、cuDNN 为闭源专用实现),进一步提升需要跨越文档阅读 → profiling → 代码修改 → 编译测试 → 诊断的多步工程循环,单轮生成无法支撑。

Q2 方法 #

AVO (Agentic Variation Operators) 用一个自主 coding agent 替代进化搜索的整个 Vary 算子。传统分解:

$$\texttt{Vary}(\mathcal{P}_t) = \texttt{Generate}(\texttt{Sample}(\mathcal{P}_t))$$

AVO 替换为:

$$\texttt{Vary}(\mathcal{P}_t) = \texttt{Agent}(\mathcal{P}_t, \mathcal{K}, \mathbf{f})$$

Agent 输入三要素:

单次 variation step 内部是 edit → evaluate → diagnose 自主循环:agent 自行决定查阅哪些文档、修改哪段代码、运行哪些测试、如何诊断失败。成功提交条件为通过正确性检查且吞吐 ≥ 当前最优。跨步骤通过 git commit 维持 lineage 连续性。持续进化通过 self-supervision 机制维持:当 agent 停滞或陷入无效编辑循环时,supervisor 审视整体进化轨迹并提出新的候选优化方向,重新引导探索。

核心技术壁垒:让通用 coding agent 在长时间自主运行中积累跨多个硬件子系统(同步/内存序、流水线调度、寄存器分配)的联合优化能力。7 天内 500+ 优化方向的系统性探索远超人类工程师同等时间产出,而三个代表性优化(§5 详述)均需联合推理多个 GPU 子系统,非单一参数调优。

Q3 结果 #

配置vs cuDNNvs FA4峰值
MHA causal (all seq_len)+0.4% ~ +3.5%+5.0% ~ +10.5%1668 TFLOPS
MHA non-causal (seq ≥ 16K)+1.8% ~ +2.4%
MHA non-causal (seq < 16K)测量噪声内测量噪声内
GQA causal (group 4/8)至多 +7.0%至多 +9.3%
GQA non-causal (group 4/8)至多 +6.0%至多 +4.5%

进化轨迹:40 committed versions / 7 天,5 个架构拐点。GQA 适配仅需额外 30 分钟自主运行。

§3 架构 / 方法图 #

Figure 1: EVO vs AVO 对比

Paper Figure 1。左:传统 evolutionary search (FunSearch / AlphaEvolve 等) 遵循 fixed pipeline,LLM 仅参与 single-turn generation。右:AVO 将整个 variation operator 替换为自主 agent,可自行查阅 previous solutions、evaluation utilities、tools 和 persistent memory,进行迭代式 plan → implement → test → debug。

关键对比:传统方案中 Sample 和 evaluation 由框架硬编码控制,LLM 无法在生成过程中获得 execution feedback 或主动查阅文档。AVO 中 agent 拥有完整自主权——包括何时查阅 $\mathcal{P}_t$ 中的历史版本、何时运行 profiler、何时改变优化策略。

Figure 2: AVO 内部结构

Paper Figure 2。AVO 的核心结构:自主 coding agent 以完整进化谱系 $\mathcal{P}_t$、领域知识库 $\mathcal{K}$、评分函数 $\mathbf{f}$ 为输入,内部执行多轮 edit-evaluate-diagnose 循环。

目标运算:scaled dot-product attention $O = \mathrm{softmax}(QK^\top / \sqrt{d}) \, V$,forward prefilling,BF16 精度,head dimension 128。

目标硬件与 warp-specialized pipeline (B200 Blackwell)

AVO 在此 warp-specialized pipeline 上进化,从 seed kernel 出发经 40 版本迭代,逐步发现跨子系统优化。

§4 作者证明 #

符号表 #

符号含义
$\mathcal{P}_t$进化谱系:所有已 commit 的 solution-score 对 $\{(x_i, \mathbf{f}(x_i))\}$
$x_i$第 $i$ 个 candidate solution(CUDA kernel 源码 + inline PTX)
$\mathbf{f}$多维评分函数:$(f_1, \ldots, f_n)$,每维为一个 benchmark 配置的 TFLOPS
$\mathcal{K}$领域知识库:CUDA guides + PTX ISA + Blackwell spec + FA4 source
$\texttt{Vary}$Variation operator:从 $\mathcal{P}_t$ 产生新 candidate
$\texttt{Sample}$亲本选择(传统方案,score/diversity-based heuristics)
$\texttt{Generate}$LLM 单轮生成(传统方案)
$\texttt{Agent}$AVO 的自主 coding agent,替代 Sample + Generate + evaluation

方程物理意义 #

Eq. 1 — $\mathcal{P}_{t+1} = \texttt{Update}(\mathcal{P}_t, (x_{t+1}, \mathbf{f}(x_{t+1})))$, $x_{t+1} = \texttt{Vary}(\mathcal{P}_t)$:进化主循环。Vary 产生候选,Update 将其加入群体(可能剪枝低分成员)。所有进化搜索共享的框架性定义。

Eq. 2/3 — $\texttt{Vary}(\mathcal{P}_t) = \texttt{Generate}(\texttt{Sample}(\mathcal{P}_t))$:传统 LLM-augmented evolutionary search 的 Vary 分解。AlphaEvolve 用 island-based MAP-Elites + fitness/diversity heuristics 做 Sample;LoongFlow 用 Boltzmann selection + fixed Plan-Execute-Summarize pipeline。LLM 仅参与 Generate。

Eq. 4 — $\texttt{Vary}(\mathcal{P}_t) = \texttt{Agent}(\mathcal{P}_t, \mathcal{K}, \mathbf{f})$:AVO 的核心形式化。整个 Vary 被替换为单个 autonomous agent 调用,agent 同时承担亲本选择、候选生成和中间评估。$\mathcal{K}$ 和 $\mathbf{f}$ 的直接可访问性是与传统分解的结构性区别。

形式化校验 #

本文形式化为定义性(描述框架结构),非分析性(无定理/收敛证明)。主要证据为实证。

  1. 维度一致性:$\mathbf{f}$ 输出维度 $n$ = benchmark 配置数(4 seq_len × 2 masking = 8 for MHA),与报告的结果矩阵对齐
  2. 边界条件:正确性失败时 $f_j = 0$,保证不正确的 kernel 不进入 commit 序列
  3. 收敛特性:无形式化收敛保证;40-version 轨迹呈阶梯状递增 + 递减回报,符合 kernel 优化直觉(粗粒度增益 → 细粒度调优)
  4. Roofline 位置:attention 在 Blackwell 上为 compute-bound(tiled FlashAttention 消除 $N \times N$ score matrix 物化),1668 TFLOPS 接近 B200 BF16 tensor core 峰值
  5. 评分可比性:使用 FA4 仓库的同一 timing script、同样预热/重复轮数、10 次独立运行取均值 + 标准差
  6. 外部基准验证:Appendix A 对比 FA4 论文自报 baseline 数字(排除测量系统差异),趋势一致
  7. §5 实验与数据 #

    5.1 MHA 吞吐对比 #

    Figure 3: MHA forward prefilling 吞吐量

    Paper Figure 3。B200, head\_dim=128, 16 heads, BF16, total tokens 固定 32K。左 non-causal,右 causal。

    Causal MHA 是 AVO 的主要优势区域:所有 4 个 seq\_len 配置全面超越两条 baseline,最大增益出现在 seq\_len=32K(cuDNN +3.5%, FA4 +10.5%)。Non-causal 在短序列(4K, 8K)处与 baseline 在测量噪声内,长序列(16K, 32K)有 +1.8%~2.4% 增益。Causal 与 non-causal 的不对称性源于 branchless rescaling 优化仅应用于 fully unmasked 的 K-block iterations——causal 模式下存在 fully masked blocks 仍需原始分支逻辑。

    5.2 GQA 迁移 #

    Figure 4: GQA forward prefilling 吞吐量

    Paper Figure 4。32 query heads, head\_dim=128, BF16。Group size 8 (Qwen3-30B-A3B) 和 group size 4 (Qwen3-8B) 两种配置,causal 和 non-causal。

    GQA 结果验证了 MHA 进化中发现的优化并非针对 MHA 特定 compute pattern 过拟合:在不同 query/KV head 比例下均保持优势。Causal GQA 上 cuDNN 至多 +7.0%、FA4 至多 +9.3%;non-causal 至多 +6.0% / +4.5%。GQA 适配仅需 30 分钟 agent 自主运行,无人工指导。

    5.3 进化轨迹 #

    Figure 5: Causal MHA 进化轨迹

    Paper Figure 5。绿色实线为 running-best geometric mean;绿色圆点标记刷新最优的版本;虚线为 cuDNN / FA4 geometric mean baseline。40 committed versions / 7 天。

    40 个 committed versions 背后是 500+ 个已探索的候选优化方向(包括正确性失败、吞吐回退、编译失败的尝试)。吞吐呈阶梯状提升:v1–v20 为粗粒度增益(缩小与 baseline 的差距),v21–v40 为细粒度 cycle-level 调度和资源分配(增益递减但持续积累)。

    5 个架构拐点对应阶梯跳跃:

    1. v8:QK-PV interleaving + bitmask causal masking
    2. v13:restructured single-pass softmax computation
    3. v20:branchless accumulator rescaling + lighter memory fence
    4. v30:correction/MMA pipeline overlap
    5. v33:register rebalancing across warp groups
    6. 5.4 三项代表性优化 ablation #

      优化版本Non-causalCausal攻击的瓶颈
      Branchless accumulator rescalingv19→v20+8.1%+1.6%warp sync + blocking memory fence
      Correction/MMA pipeline overlapv29→v30+1.1%+0.4%correction warp idle during 2nd PV GEMM
      Register rebalancingv32→v33+2.1%~0%correction warp register spill to local mem

      Branchless rescaling(最大单项增益):online softmax 中 running maximum 变化时需 rescale output accumulator。v19 用条件分支检查是否需要 rescale——分支引入 warp synchronization 开销并阻止使用轻量 memory fence。v20 改为 branchless speculative 路径:总是计算 rescale factor,不需要时用 predicated select 替换为 1.0(乘 1.0 的代价远小于分支同步代价)。消除分支 → 消除 warp divergence → blocking fence 替换为 non-blocking ordering fence。Non-causal 增益远大于 causal,因为 branchless 路径仅应用于 fully unmasked K-block iterations。

      Correction/MMA overlap:dual Q-stage pipeline 中,v29 的 correction warp 需等待两个 PV GEMM 均完成才开始 normalize。v30 让 correction warp 在第一个 PV GEMM 完成后即开始工作,与第二个 PV GEMM 重叠执行——串行依赖转为 pipeline 并行。

      Register rebalancing:Blackwell 每 SM 2048 warp-registers。FA4 分配 192 / 80 / 48(softmax 8 warps / correction 4 warps / remaining 4 warps)。Profiling 发现 correction warp group 在 80 寄存器下 spill 到 local memory。v33 重新分配为 184 / 88 / 56——可行因为 AVO kernel 的 softmax 用 packed arithmetic 处理 score values,184 寄存器仍有充足 headroom;correction warp 在 §5.2 pipeline overlap 后位于 critical path,8 个额外寄存器减少 spill 消除 stall。

      §6 论证链 #

      步骤论点证据来源依赖
      1现有 LLM-in-loop evolutionary search 将 LLM 限制在 single-turn Generate,无法自主诊断、查阅文档或迭代修改§2.1: FunSearch / AlphaEvolve / LoongFlow 的 fixed pipeline 分析
      2自主 coding agent 具备 planning + tool use + persistent memory,可执行多步工程循环§1: SWE-bench / SWE-agent / Claude Code / Codex / VibeTensor步骤 1 的 gap
      3AVO 将自主 agent 替代整个 Vary operator,agent 拥有 $\mathcal{P}_t$ / $\mathcal{K}$ / $\mathbf{f}$ 的完整访问权§3.1: Eq. 4 形式化 + §3.2: edit-evaluate-diagnose 循环步骤 1 + 2
      4AVO 在 B200 attention kernel 上超越 cuDNN 和 FA4§4.2 Fig. 3 (MHA) + §4.3 Fig. 4 (GQA)步骤 3 的实例化
      5agent 发现的优化是真实硬件级多子系统联合推理,非表面代码变换§5.1–5.3: branchless rescaling / pipeline overlap / register rebalancing + Table 1 ablation步骤 4 的质量分析
      6MHA 优化可迁移至 GQA,说明发现的优化具有泛化性§4.3: 30 min 自主适配 + Fig. 4 全配置超越 baseline步骤 4 + 5

      §7 实现 cross-reference #

      [实现未公开]

      AVO 使用 NVIDIA 内部开发的通用 coding agent,kernel 源码未开放。

      可追踪的外部依赖

      • Baseline 测量: FA4 仓库 timing script + benchmark 配置 (commit 71bf77c)
      • cuDNN 9.19.1(含 Blackwell 专用优化)
      • 硬件: NVIDIA B200, CUDA 13.1, PyTorch 2.10.0
      • GQA 配置来自 Qwen3 model family(Qwen3-30B-A3B: 32q/4kv;Qwen3-8B: 32q/8kv)

      关键实现细节

      1. Branchless speculative rescale + fence weakening:在 online softmax accumulator rescaling 中消除条件分支,用 predicated select (multiply by 1.0) 替代 warp-level skip。关键不在 branchless 本身,而在于消除分支后允许将 blocking memory fence 降级为 non-blocking ordering fence——non-blocking fence 安全的前提是所有 warp threads 走同一 control flow 路径,branchless 设计恰好保证了这一点。这是整个进化过程中单项增益最大的优化 (+8.1% non-causal)。
        1. Register budget 184/88/56 重分配:重新分配 warp-register budget 需要同时理解三个条件——(a) softmax warp 因 packed arithmetic 对 score values 做小片段处理,184 寄存器仍有 headroom;(b) correction warp 在 pipeline overlap 优化后位于 execution critical path;(c) 88 寄存器刚好消除到 local memory 的 spill。三个条件缺一不可。
        2. Software → Hardware 反向启示

          • Blackwell 的 warp-register budget (2048/SM) 对 warp-specialized kernel 偏紧——register rebalancing 优化的存在说明人工/自动的分配粒度不足以消除 spill;未来 ISA 若支持 per-warp-group 的动态 register ceiling 可直接获益
          • Branchless rescaling 的收益源于 blocking fence 的高代价;若硬件提供更细粒度的 fence 语义(per-warp-group ordering fence),该优化可更简洁地实现
          • Correction warp 与 MMA warp 的 pipeline overlap 受制于 barrier-based signaling 的刚性;更灵活的 producer-consumer 同步原语可简化此类手动 pipeline 重排