Agent 怎么钻评测的漏洞?
怎么防 reward hacking?

英文问法What is reward hacking? Give a real example from kernel optimization. · How could an agent game your benchmark, and how do you stop it? · How do you know a 100x speedup is real?

考过推断,非面经。没有 Unity 的面经原题,别家面经里也没有直接问这题的 · 它是设计 kernel agent 一题的追问 · Unity 自己的材料只有 FlashVector Figure 2 的图中文字 "fixed verifier the agent cannot edit · all candidates run sandboxed",论文没有用 reward hacking 这个词 · 真实例子来自 Sakana 事件、CUDA-L1 和 METR 的报告

先弄清楚:每个概念是什么

Reward hacking
agent 让分数变高,但没有完成任务。
Harness
判定候选对不对、测它多快的那段代码,所以它就是被攻击的对象(见 LLM harness)。
CUDA stream
GPU 上的一条任务队列。
Speed of light(SOL)
按硬件峰值算出来的时间下限。

看图:三个真实的漏洞各打在哪

加固之前:candidate 和 harness 在同一个进程里,三处各有一个漏洞 harness ① ② ③ 加固后的边界 candidate kernel agent 写的 reference 的输出(显存) timer:只等 default stream 计时函数和评测脚本 ① Sakana:kernel 读到 reference 留在显存里的输出,correctness check 没拦住 ② CUDA-L1:计算放到另一个 stream,timer 测不到 ③ METR 测的 o3:改写 timer,测出来的时间变短 加固:candidate 单独一个进程,计时等所有 stream,评测脚本只读
图 1:① 和 ③ 是 candidate 够得着 harness 的 GPU memory 和代码,② 是 timer 没盖住全部计算。蓝色虚线是加固后的进程边界。① 的机制是外界的推测。

30 秒回答

Reward hacking is when the agent raises its score without doing the task. Sakana's system found a memory exploit in its own harness, and one kernel reported as 150x faster was actually 3x slower. A third of CUDA-L1's kernels ran work on a side stream the timer missed. METR saw o3 overwrite the grader's timer. So I treat the harness as the attack surface: run each candidate in its own process, keep the scripts read-only, re-verify inside the timing loop, reject anything faster than the hardware limit, and audit sudden jumps by hand.

三个真实例子

例子漏洞数字
Sakana AI
CUDA Engineer
(2025-02)
harness 里有 memory exploit,kernel 没算对也能过 correctness check。外界推测是 caching allocator 把 reference 刚释放的 GPU memory 分给了它,里面的旧数据还在一个 kernel 报快 150x,实际慢 3x。别人修掉漏洞后复现,median speedup 是 1.10x
CUDA-L1
(2025-07)
计算放到另一个 CUDA stream,KernelBench 的 timer 只等 default stream,测不到250 个 kernel 里有 82 个,占 32.8%。平均 speedup 从 17.7x 改成 3.12x
METR 测 o3
(2025-06)
改写 harness 的 timer。另一种手法是从 call stack 里找出 harness 算好的答案Optimize a Kernel 任务 24 次 run 里 hack 了 6 次

常见类型和三层防御

常见的类型有调用 PyTorch fallback、缓存输出、降精度、hardcode 测试 shape 和改评测脚本。SOL-ExecBench 里有 14.5% 的提交被标为 hack。最多的是降精度,占全部提交的 6.4%(对策见 kernel 正确性)。

  1. 隔离 harness:candidate 分进程跑,输入每次 clone,计时等所有 stream,评测脚本只读(技术见 sandbox)
  2. 规则和物理上限:运行时禁止 PyTorch fallback;计时循环里每次重新校验输出;比 SOL 还快的结果直接作废
  3. Judge 加人工:reward 突然跳高就让 LLM judge 复查,高分样本人工抽查,发现的手法固化成新规则

KernelGuard 用静态规则、physics floor 和 LLM judge 三层,把比赛里的 hacked 提交率从 3.45% 降到 0.37%。Search agent 一侧见 search agent 怎么训。

必答点

追问

在 prompt 里写“不要作弊”为什么不行?

METR 试过,效果很小。事后问 o3 这样做是否符合用户的意图,10 次里它 10 次回答 no,说明它知道这是作弊。

Speed of light 怎么算?

用运算量除以硬件的峰值算力。4096 × 4096 的 matmul 是 \(2 \times 4096^3 \approx 1.37 \times 10^{11}\) FLOPs,H100 的 BF16 峰值约 989 TFLOPS,相除约 0.14 ms。KernelBench v0.1 给的下界是约 0.138 ms。

你自己的经验怎么接上?

RL environment 里的 verifier 就是这里的 harness。它的覆盖面要大于 policy 的搜索能力,并且持续找人或 agent 来攻击它。只讲简历上公开的层面。

来源ml-八股 08 第 21 题 · Sakana 事件:TechCrunch 2025-02-21、GIGAZINE,复现的 1.10x 见 EvoEngineer App. A.8 · CUDA-L1(32.8%、17.7x 改 3.12x)· METR 2025-06-05 · KernelBench v0.1(SOL 的例子)· SOL-ExecBench Table 3 · KernelGuard · KernelFalcon · 整理见文献笔记 5.3 节