GLM-5.3-Flash 部署复盘:Infra Agent 优化推理系统
Two weeks.
这是一篇极具价值的工程复盘,详细拆解了 AI Agent 如何自主优化底层推理系统的具体路径与参数取舍,对做 Infra 和 Agent 的同学有直接参考价值。
Two weeks.
两周。
That's how long it took to go from GLM-5.3-Flash's first run on domestic accelerators to serving all of its production traffic, with 3.2× end-to-end throughput along the way.
从 GLM-5.3-Flash 在国内加速器上首次运行到承载全部生产流量,耗时如此之长,期间端到端吞吐量提升了 3.2 倍。
What I keep thinking about is who did much of the work: an Infra Agent powered by GLM-5.3.
我反复思考的是:谁完成了大部分工作?是由 GLM-5.3 驱动的 Infra Agent。
A model helping optimize the system that serves it.
一个帮助优化为其提供服务的系统的模型。
The conditions were hard. Limited memory and interconnect bandwidth. 1M-token context. Multimodal requests. An immature software stack where kernels were missing and documentation was often guesswork. Every optimization was a trade: compute for memory (ReplaySSM), communication for memory (intra-node tensor parallelism), precision for capacity (mixed INT8/FP8/BF16 caching), and disaggregation for scheduling freedom (Encode–Prefill–Decode).
条件十分苛刻。内存和互连带宽受限。上下文长度为 1M token。多模态请求。软件栈尚不成熟,内核缺失,文档往往只能靠猜测。每一项优化都是一种权衡:用计算换内存(ReplaySSM),用通信换内存(节点内张量并行),用精度换容量(混合 INT8/FP8/BF16 缓存),以及用解耦换取调度自由(Encode–Prefill–Decode)。
But the most important lesson wasn't about any single optimization.
但最重要的教训并非关于任何单一的优化。
When the agent got stuck, it was rarely because it couldn't write the code. It was because it didn't know *why* things got worse.
当代理陷入困境时,很少是因为它写不出代码。而是因为它不知道*为什么*情况会变糟。
"Throughput down 20%" tells you something broke. It doesn't tell you which layer, which hypothesis, or what to test next. In RL terms, it's a sparse reward with a credit assignment problem. And an end-to-end benchmark that takes hours makes exploration painfully slow.
"吞吐量下降 20%" 告诉你某些东西出错了。但它没有告诉你哪一层出了问题、哪个假设不成立,或者下一步该测试什么。在强化学习术语中,这是一个具有信用分配问题的稀疏奖励。而一个需要数小时才能完成的端到端基准测试,使得探索过程痛苦地缓慢。
Senior engineers solve this with an implicit process reward in their heads. They know when to check the timeline, when to run a microbenchmark, and which layer's output to compare.
高级工程师通过头脑中隐式的过程奖励来解决这个问题。他们知道何时检查时间线,何时运行微基准测试,以及比较哪一层的输出。
So we made that explicit. We call it dense feedback: layered verification interfaces the agent can call directly.
因此我们将其显式化。我们称之为密集反馈:分层验证接口,代理可以直接调用。
Correctness feedback: did it compute right? System behavior feedback: where did the time go? Performance feedback: which option wins, under which conditions?
正确性反馈:计算是否正确? 系统行为反馈:时间花在哪里了? 性能反馈:哪种选项在何种条件下胜出?
Each signal has to be local, cheap, and objectively verifiable.
每个信号都必须是局部的、廉价的且可客观验证的。
Three things the agent found:
代理发现了三件事:
First, precision drift in KDA's context-parallel path that grew with sequence length. The cause was TF32 rounding error compounding through chained state-matrix merges. The fix is now merged upstream in Flash Linear Attention (PR #1180).
首先,KDA 上下文并行路径中存在精度漂移,且随序列长度增加而加剧。原因是 TF32 舍入误差在链式状态矩阵合并过程中不断累积。修复方案现已合并至 Flash Linear Attention 上游(PR #1180)。
Second, KV transfer never overlapped with DeepEP dispatch. The agent followed the call chain across the Python/C++ boundary and found that the intranode path never released the GIL. After the fix, transfer overhead fell from over 30% to under 1%.
其次,KV 传输从未与 DeepEP 分发重叠。代理追踪了跨越 Python/C++ 边界的调用链,发现节点内路径从未释放 GIL。修复后,传输开销从超过 30% 降至不到 1%。
Third, a decode kernel recomputing the same normalization four times because of how it was chunked. The agent restructured it and got a 1.71× speedup. The idea came from "optimization skeletons" it had distilled by reading existing kernels across SGLang, FLA, and DeepGEMM.
第三,一个解码内核由于分块方式的原因,对相同的归一化操作重新计算了四次。智能体对其进行了重构,实现了1.71倍的速度提升。这一想法源自它通过阅读SGLang、FLA和DeepGEMM中现有内核所提炼出的“优化骨架”。
To be clear about the boundaries: humans still defined the goals, built the feedback environment, and reviewed every high-risk change.
明确边界:人类仍然定义了目标,构建了反馈环境,并审查了每一个高风险的变更。
But the engineer's role is changing, from the person who solves the problem to the person who designs the feedback.
但工程师的角色正在发生变化,从解决问题的人转变为设计反馈的人。
There's a deeper implication too. A layered, verifiable feedback environment built on real infrastructure tasks is exactly what training the next generation of models needs most. Every task the agent completes can become training ground for its successor.
这里还有更深层的含义。建立在真实基础设施任务之上的分层、可验证的反馈环境,正是训练下一代模型最需要的。智能体完成的每一项任务都可以成为其继任者的训练场。
We are still far from recursive self-improvement.
我们距离递归式自我改进仍有很长的路要走。
But the smallest loop now exists.
但最小的循环现在已经存在。
The model optimizes the system. The system serves the model.
模型优化系统,系统服务于模型。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力