AISpot

llama.cpp 伺服器新增 --models-memory-max,可按記憶體閾值動態解除安裝模型

llama.cpp releases版本更新地端推論開源開發工具

llama.cpp 伺服器新增 --models-memory-max 引數,當已載入模型超過設定的記憶體上限時自動動態解除安裝。該限制以每臺裝置分別計算的記憶體餘量(margin)形式生效,載入前會把待載入模型的大小計入估算,並用 no_alloc 預估模型載入所需記憶體;只有在記憶體超限且沒有空閒模型可解除安裝時,才拒絕新的載入請求。此次還修正了兩個問題:測量子程序的記憶體統計偏差會使 --fit 下把其他程序佔用算成零,以及排隊載入被閾值阻塞時陷入反覆重試。

為 llama.cpp server 增加了按記憶體閾值自動解除安裝模型的排程能力,並修掉了子程序記憶體統計偏差和排隊載入空轉重試,對在單機多卡上同時跑多個模型的使用者最直接有用。

原標題:b11930
閱讀原文

評分76 / 70(平均 73,門檻 60)
狀態精選

全文翻譯

server:為動態解除安裝新增路由器裝置記憶體餘量引數(#21231) server:新增 --models-memory-max 引數,允許在模型超過記憶體大小閾值時動態解除安裝模型 估算時包含待載入模型的大小 使用 no_alloc 獲取模型載入的記憶體需求 僅在之前未計算過時設定 model memory_mb 使用記憶體餘量而非總大小限制,分別應用於每個裝置 新增伺服器記憶體除錯日誌 將 llama_context_device_memory 函式移至 llama-ext.h 修復模型數量超限檢查 改進 memory_per_device 對映命名 改進變數命名,修正程式碼風格 同時從子程序中剝離模型記憶體餘量 cont:清理 用 buft 記憶體對映替換裝置記憶體對映。使用 llama_get_memory_breakdown 將重複檢查提取為輔助函式 將模型記憶體估算移至子程序 預計算 name->buft 對映,將 GPU 主機型別對映到 CPU buft 清理未使用的變數 移除重複的初始化呼叫 適配上游變更 wip common_memory_reports 介面 SERVER_ROLE_MEASURE server-models-sched 修復建置 server:修復測量子程序的記憶體核算與搶佔自旋 測量子程序執行 no_alloc,因此其報告的可用記憶體不包含其估算值:在此處減去自身會抹除其他程序佔用的記憶體,在啟用 --fit 時降至零,下一次載入可能超出餘量。僅對例項報告減去自身。 排隊的載入在搶佔前僅檢查 --models-max,因此當記憶體餘量將其阻塞在繁忙模型之後時,load() 丟擲異常,等待者在緊密迴圈中重試。在超出限制且沒有空閒模型可解除安裝時拒絕搶佔,使等待者在條件變數上休眠,直到有模型變為空閒。 共同作者:Xuan Son Nguyen [email protected] 共同作者:Pascal [email protected] 網站: https://llama.app 證明: https://github.com/ggml-org/llama.cpp/attestations/60393615 macOS/iOS: macOS Apple Silicon(arm64) macOS Apple Silicon(arm64,啟用 KleidiAI)已停用 macOS Intel(x64) iOS XCFramework Linux: Ubuntu x64(CPU) Ubuntu arm64(CPU) Ubuntu s390x(CPU) Ubuntu x64(Vulkan) Ubuntu arm64(Vulkan) Ubuntu x64(CUDA 12)- CUDA 12.8 庫 Ubuntu x64(CUDA 13)- CUDA 13.4 庫 Ubuntu arm64(CUDA 13)- CUDA 13.4 庫 Ubuntu x64(ROCm 10.0) Ubuntu x64(OpenVINO) Ubuntu x64(SYCL FP32) Ubuntu x64(SYCL FP16) Linux arm64(Snapdragon:CPU、Adreno GPU、Hexagon NPU)- 設定指南 Android: Android arm64(CPU) Android arm64(Snapdragon:CPU、Adreno GPU、Hexagon NPU)- 設定指南 Windows: Windows x64(CPU) Windows arm64(CPU) Windows arm64(OpenCL Adreno) Windows x64(CUDA 12)- CUDA 12.4 DLLs Windows x64(CUDA 13)- CUDA 13.4 DLLs Windows arm64(CUDA 13)- CUDA 13.4 DLLs Windows x64(Vulkan) Windows arm64(Vulkan) Windows x64(OpenVINO) Windows x64(SYCL) Windows x64(ROCm 10.0) openEuler: 停用 openEuler x86(310p) openEuler x86(910b,ACL Graph) openEuler aarch64(310p) openEuler aarch64(910b,ACL Graph) UI: UI

由 AI 翻譯,以原文為準。

原文
server: add router device memory margin parameter for dynamic unloading ( #21231 ) server: add --models-memory-max parameter to allow dynamically unloading models when they exceed a memory size threshold estimate with to-be-loaded model size included use no_alloc to get memory requirements for model load only set model memory_mb if not previously calculated use memory margin instead of total size limit, apply to each device separately add server memory debug logging move llama_context_device_memory function to llama-ext.h fix model count exceeded check improve memory_per_device map naming improve variable naming, fix style also strip models memory margin from child processes cont : clean-up replace device memory map with buft memory map. Use llama_get_memory_breakdown extract duplicated check into helper function move model memory estimation to subprocess precompute name->buft map, map GPU host types to CPU buft cleanup unused variable remove duplicated init calls adapt to upstream changes wip common_memory_reports internface SERVER_ROLE_MEASURE server-models-sched fix build server : fix memory accounting of measure children and claim spin A measure child runs no_alloc, so the free memory it reports does not include its estimate: subtracting self there erased the memory held by other processes, down to zero with --fit on, and the next load could overshoot the margin. Subtract self only for instance reports. A queued load only checked --models-max before claiming, so when the memory margin blocked it behind a busy model, load() threw and the waiter retried in a tight loop. Refuse the claim while the limits are exceeded and no idle model can be unloaded, so the waiter sleeps on the condition variable until one goes idle. Co-authored-by: Xuan Son Nguyen [email protected] Co-authored-by: Pascal [email protected] Website: https://llama.app Attestations: https://github.com/ggml-org/llama.cpp/attestations/60393615 macOS/iOS: macOS Apple Silicon (arm64) macOS Apple Silicon (arm64, KleidiAI enabled) DISABLED macOS Intel (x64) iOS XCFramework Linux: Ubuntu x64 (CPU) Ubuntu arm64 (CPU) Ubuntu s390x (CPU) Ubuntu x64 (Vulkan) Ubuntu arm64 (Vulkan) Ubuntu x64 (CUDA 12) - CUDA 12.8 libraries Ubuntu x64 (CUDA 13) - CUDA 13.4 libraries Ubuntu arm64 (CUDA 13) - CUDA 13.4 libraries Ubuntu x64 (ROCm 10.0) Ubuntu x64 (OpenVINO) Ubuntu x64 (SYCL FP32) Ubuntu x64 (SYCL FP16) Linux arm64 (Snapdragon: CPU, Adreno GPU, Hexagon NPU) - setup guide Android: Android arm64 (CPU) Android arm64 (Snapdragon: CPU, Adreno GPU, Hexagon NPU) - setup guide Windows: Windows x64 (CPU) Windows arm64 (CPU) Windows arm64 (OpenCL Adreno) Windows x64 (CUDA 12) - CUDA 12.4 DLLs Windows x64 (CUDA 13) - CUDA 13.4 DLLs Windows arm64 (CUDA 13) - CUDA 13.4 DLLs Windows x64 (Vulkan) Windows arm64 (Vulkan) Windows x64 (OpenVINO) Windows x64 (SYCL) Windows x64 (ROCm 10.0) openEuler: DISABLED openEuler x86 (310p) openEuler x86 (910b, ACL Graph) openEuler aarch64 (310p) openEuler aarch64 (910b, ACL Graph) UI: UI

相關報導

llama.cpp releasesAI 評分36

llama.cpp 測試提速:模型儲存不再建立 llama_context

llama.cpp 建置 b11934 最佳化了測試流程,重構 save_models 使其只建立模型而不再建立儲存時用不到的 llama_context,並用 splitmix64 加 Box-Muller 生成器替換較慢的 std::normal_distribution 抽樣。張量資料改為用 std::mt19937 預先生成一組正態抽樣池,各張量按名稱迴圈取切片,保證結果確定;每次儲存模型後還會輸出檔名、目標路徑與位元組/MB 體積。

X @ggerganovAI 評分42

llama.cpp v0.7.0 發布,llama serve 新增懶載入與推測解碼

llama.cpp 發布 v0.7.0,作者給出的範例命令是 llama serve -hf ggml-org/Qwen3.8-Flash-Next-GGUF:IQ4_NL --spec-type draft-mtp --lazy-mode on。命令通過 -hf 指定 Hugging Face 上的 Qwen3.8-Flash-Next GGUF 倉庫及 IQ4_NL 量化,並同時開啟 --lazy-mode 懶載入與 --spec-type draft-mtp 推測解碼。