← 回到 Reading
Daily Dose of DS 2026-08-13

Continuous Batching in LLMs

Google 的 Agents CLI 透過將 scaffolding、deployment、security 和 evaluation 整合至自然語言介面中,簡化了 agentic engineering lifecycle。它讓開發者能透過簡單的 prompts,管理從本地構想轉換為受控企業級資產的過程。此工具與 Claude Code 和 Cursor 等現有 coding agents 整合,以自動化複雜任務(例如 identity provisioning 和 prompt injection screening)。透過運用 Agent Runtime 和 Gemini Enterprise,它確保 agents 具備 stateful 特性、安全性,並可在整個企業組織內存取。Continuous batching(亦稱 iteration-level scheduling)透過在每次 forward pass 時重建 batch,而非等待 static batch 中的所有 requests 完成,以此最佳化 LLM inference。這種方法允許已完成的 requests 立即退出,並讓等待中的 requests 立即加入,避免 GPU 資源浪費在因輸出長度不一所產生的 empty slots 上。像 vLLM 和 TensorRT-LLM 這樣的 serving engines 便採用此方法大幅提升 throughput,並通常在統一的 scheduling loop 中管理 chunked prefill 和 KV cache allocation 等複雜任務。

閱讀原文 ↗
目錄 2 段
  1. 01清楚解析 Karpathy 的 agentic engineering lifecycle
  2. 02LLM 中的 Continuous batching
AGENTS

清楚解析 Karpathy 的 agentic engineering lifecycle

Google 的 Agents CLI 透過將 scaffolding、deployment、security 和 evaluation 整合至自然語言介面中,簡化了 agentic engineering lifecycle。它讓開發者能透過簡單的 prompts,管理從本地構想轉換為受管企業資產的過程。此工具與現有的 coding agents(如 Claude Code 和 Cursor)整合,以自動化複雜任務(例如 identity provisioning 和 prompt injection screening)。透過運用 Agent Runtime 和 Gemini Enterprise,它確保 agents 具備 stateful 特性、安全性,並能在整個組織中存取。

  • Google 的 Agents CLI 使用自然語言 prompts 自動化 AI agents 的 end-to-end lifecycle。
  • 該 CLI 與熱門 coding tools 整合,包括 Claude Code、Cursor、Codex 與 Antigravity。
  • 安全性功能包含用於 prompt injection screening 的 Model Armor,以及 least-privilege identities 的配置(provisioning)。
  • 部署至 Agent Runtime 則可透過 Sessions 與 Memory Bank 功能實現 state persistence。
  • Evaluation 階段特別針對 grounding、hallucination prevention 以及 prompt optimization 進行評估與優化。
  • 完成定案的 agent 可以直接註冊並發布至 Gemini Enterprise,供組織內部使用。
LLMOPS

LLM 中的 Continuous batching

Continuous batching(亦稱為 iteration-level scheduling)透過在每次 forward pass 時重新建構 batch,而非等待 static batch 中的所有 request 完成,藉此優化 LLM inference。這種做法讓已完成的 request 立即退出,並讓等待中的 request 立即加入,避免 GPU 資源因輸出長度不一所產生的 empty slots 而浪費。像 vLLM 與 TensorRT-LLM 這類 serving engine 便採用此方法大幅提升 throughput,並通常在統一的 scheduling loop 中管理 chunked prefill 與 KV cache 配置等複雜任務。

  • Static batching 對 LLM 而言效率低落,因為 output length 無法預測,導致整個 batch 只能以最慢 request 的速度執行。
  • Continuous batching 會在每次 iteration 更新 batch 成員,以便立即替換已完成的 sequence。
  • Selective batching 在執行 linear operations 時會將 token 展平(flatten)為單一 sequence,而在進行 attention 時則將其拆分以處理各自獨立的 KV cache。
  • vLLM scheduler 透過管理 token budget 與 sequence cap,在 throughput 與 inter-token latency 之間取得平衡。
  • 當 KV cache 記憶體耗盡時就會發生 preemption,在預設的 vLLM 設定下,這會迫使 request 必須從頭重新計算。
  • Anyscale 的 benchmarks 顯示,在 OPT-13B 模型上,vLLM 的 throughput 可達原生 Hugging Face serving 的 23 倍。
  • 監控 scheduler 健康狀況的關鍵指標包含 Prometheus 中的 total_cumulative_preemption_cnt。