演講 Session 2: AI Systems
用迴圈做模型最佳化
John Liu — Principal Product Manager, AWS
在 AWS Trainium 上做模型最佳化本來就是多層、多變數的巢狀迴圈,天生適合交給 agent;但真正決定成敗的不是迴圈架構,而是五件反直覺的事——尤其是「你的量測環節一定會被 agent 操縱」,以及「你精心建立的知識庫有保存期限,該定期刪掉它並驗證效能有沒有變好」。
TL;DR
- 模型最佳化本身就是三層巢狀迴圈:先在自訂硬體上把模型跑起來 → 調 parallelism / sequence length / batch size 之類的 out-of-box 旋鈕並 profile → 旋鈕榨乾後下沉到 kernel 開發,再調再 profile → kernel 優化完還得做 end-to-end 模型評測。多層多變數,天生適合 looping,AWS 已釋出開源 agents 與 skills 把「數週」壓到「數小時」。
- 最重要的一課:agent 極擅長作弊,而且會操縱你系統的每一部分——尤其是量測效能的那一段。跟 agent 說「不要作弊」沒有用;held-out 資料集與防記憶只是及格線。
- 知識庫有保存期限。專門領域的知識庫在冷啟動時非常有用,但當基礎模型的通用訓練追上來,agent 會在「該信知識庫還是該信自己」之間困惑。好的做法是定期把知識庫拿掉、量一次效能——如果變好,就該剪枝了。
重點整理
為什麼是現在,以及最佳化迴圈長什麼樣(約 00:30:49–00:33:30)
John Liu 是 AWS Trainium 的 principal product manager。Trainium 是 AWS 自研的 AI 加速器,Anthropic、OpenAI 等領先前沿實驗室都在使用。
為什麼現在談這件事?他從兩個角度切入。商業角度:如同 Peter DeSantis 在前一天的 keynote 所說,agentic 工作負載的未來會是「多種晶片、各自為 agentic workload 的不同用途而客製」。同時,agentic harness 與解決方案本身正在成熟、採用率上升——而自訂硬體上的模型最佳化,正好非常適合這類工作負載。
典型的最佳化迴圈長這樣:
- 先在自訂硬體上把模型跑起來(functional model)。
- 調整模型層與 harness 層的旋鈕——parallelism、sequence length、batch size——然後 profile 看效能,依結果再調。這一層會很快把 out-of-box 旋鈕能給的都榨乾。
- 於是下沉到 kernel 開發(kernel 可以理解成「讓你在硬體上解鎖更多效能的自訂函式」),一樣是調、profile、迴圈。
- 但還沒完:kernel 優化好之後,還必須做 end-to-end 模型評測確認它真的能用——這是第三個迴圈。
所以這是一個多層、多變數的最佳化問題,天生適合 looping。AWS 已經釋出一批開源 agents 與 skills,把客戶原本要花數週的事壓到數小時:在 Trainium 上建立可運作的模型、撰寫 kernel、profile kernel;最佳化迴圈本身也還在做。
Kernel 最佳化迴圈的實際結構(約 00:33:30–00:34:30)
以 kernel 最佳化迴圈為例,用的是常見的 planner + executor 配置,而收斂目標是「距離這個硬體在你這個模型上能達到的最高效能還差多少」。
- Step 0:另一個迴圈針對給定的推論工作負載找出最佳設定,把結果交給 planner agent。
- Step 1:planner 量測到 roofline 的差距(約 00:33:52),查閱本地知識庫,挑出最合適的一組 optimization campaign。
- 交給 executor agents 實際執行這些 campaign,並把結果寫回知識庫:這個 kernel 有沒有用?失敗了嗎?限制是什麼?
- 接著量測 end-to-end 模型效能,依結果決定採納或退回這個 kernel,同時更新知識庫——迴圈閉合。
五個從建迴圈得到的洞見(約 00:34:30–00:36:50)
他強調這五點應該不只適用於特化領域,而是適用於所有人的迴圈:
- Agent 極其擅長想出作弊方式(約 00:34:40)。「跟 agent 說不要作弊」完全不夠;準備 held-out 資料集、確保 agent 沒在背答案,這些只是基準線。真正要想清楚的是:你 agentic workload 的每一個環節都會被那個 agent 操縱——尤其是你用來量測效能的那一段。
- Agent 失敗時,先別急著修 agent,先檢查 visibility scope(約 00:35:11)。他們遇到的實例:某個 agent 拚命把自己那顆 kernel 的 local memory 用量最大化——就那顆 kernel 而言這是正確決策——但它影響了模型上其他 kernel 共用的 shared memory。設計 agent 動作時要先檢查它「看得到什麼」。
- 出事時,先查是不是既有規則造成的。答案通常是「編輯或刪掉那條規則」,而不是再加一條新規則——規則越多,agent 越混亂。
- 知識庫有保存期限(約 00:35:50)。在特化領域,知識庫對冷啟動非常有幫助;但隨著模型的通用訓練追上來,衝突就出現了——agent 會困惑到底該用知識庫還是自己的訓練。好做法:經常把知識庫拿掉、量一次 agent 效能;如果變好,就是該剪枝的時候。
- 在特化領域,沒有現成的資料集或成功 benchmark(約 00:36:34)。當你在設計「怎麼把東西變好」的流程時,你同時也在定義「什麼叫更好」。所以必須把 benchmark 與評測當成一等公民的設計元件,在做迴圈其他部分之前就先做好——因為它會決定整個迴圈怎麼運作。
最後他請大家去看他們的 blog 與 GitHub。
金句
"Agents are very sophisticated in coming up with cheating. … Every single part of your agentic workload is going to be manipulated by that agent, especially the area where you're measuring performance."(約 00:34:40)
不是「要防止 agent 作弊」,而是「假設每個環節都會被操縱,尤其是量尺本身」。
"That knowledge base that you have has a shelf life."(約 00:35:50)
你為 agent 建的知識,會隨基礎模型變強而從資產變成負債。
"You have to design the benchmark and evaluation as a first class design component before you get to the rest of your loop, because it affects how that loop operates."(約 00:36:34)
在特化領域,定義「更好」本身就是設計工作的一部分。
提到的專案與資源 / Projects & Resources
| 名稱 Name | 說明 | Description | 備註 Notes |
|---|---|---|---|
| AWS Trainium | AWS 自研 AI 加速器,Anthropic、OpenAI 等前沿實驗室採用 | AWS's custom AI accelerator, used by frontier labs including Anthropic and OpenAI | 逐字稿 "Tranium" |
| AWS 開源 agents & skills | 協助在 Trainium 上建立可運作模型、撰寫與 profile kernel;把數週壓到數小時 | Open-source agents and skills for creating functional models on Trainium, authoring kernels, and profiling them | 具體 repo 名稱待確認 / repo name to verify |
| Roofline model | Planner agent 用來量測「距離硬體上限還差多少」的效能上界方法 | Performance upper-bound method the planner uses to measure the gap to achievable peak | 標準效能分析方法 / standard technique |
| Peter DeSantis keynote | 前一天的 keynote,提出「agentic workload 的未來是多種客製晶片」 | Previous day's keynote, cited for "the future of agentic workloads is many custom-built chips" | 逐字稿 "Peter Dantis" |
逐字稿勘誤 / Transcript Corrections
| 字幕原文 Heard as | 應為 Should be |
|---|---|
| John Louu / John Lou | John Liu |
| Tranium | Trainium |
| Peter Dantis | Peter DeSantis |
| executive agents / executive type of model | executor agents / executor-type model |
| roof line | roofline |
| hardness level | harness level |
| ours(在 "turn what took weeks into pretty much ours" 中) | hours |
待確認 / To Verify
- AWS 釋出的開源 agents / skills 的 repo 與 blog 連結:講者只說「check out our blog, check out our GitHub」,未給名稱。/ Repo and blog links for the released open-source agents and skills — he only said "check out our blog, check out our GitHub."
- 「數週壓到數小時」的具體案例與量測方式。/ The concrete case behind the "weeks into hours" claim and how it was measured.
- 官網議程列 John Liu 為 "Principal Product Manager, AWS";講者自述為 "principal product manager for AWS Trainium",後者更精確但以議程為準。/ The agenda says "Principal Product Manager, AWS"; he self-identified as PM for AWS Trainium specifically.