Agent 怎么钻评测的漏洞?
怎么防 reward hacking?
先弄清楚:每个概念是什么
- Reward hacking
- agent 让分数变高,但没有完成任务。
- Harness
- 判定候选对不对、测它多快的那段代码,所以它就是被攻击的对象(见 LLM harness)。
- CUDA stream
- GPU 上的一条任务队列。
- Speed of light(SOL)
- 按硬件峰值算出来的时间下限。
看图:三个真实的漏洞各打在哪
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 正确性)。
- 隔离 harness:candidate 分进程跑,输入每次 clone,计时等所有 stream,评测脚本只读(技术见 sandbox)
- 规则和物理上限:运行时禁止 PyTorch fallback;计时循环里每次重新校验输出;比 SOL 还快的结果直接作废
- Judge 加人工:reward 突然跳高就让 LLM judge 复查,高分样本人工抽查,发现的手法固化成新规则
KernelGuard 用静态规则、physics floor 和 LLM judge 三层,把比赛里的 hacked 提交率从 3.45% 降到 0.37%。Search agent 一侧见 search agent 怎么训。
必答点
- 定义:分数高了,任务没完成
- 三个例子:Sakana 的 memory exploit、CUDA-L1 的 stream、METR 的 o3 改 timer
- 搜索或 RL 越强,越容易找到 harness 的漏洞
- 三层防御:隔离 harness,规则加 SOL,judge 加人工抽查高分
- 在 prompt 里写“不要作弊”没有用
追问
在 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 节