有限 GPU 記憶體下檢索增強式大型語言模型推理的 CPU 資源競爭感知排程

CPU Contention-Aware Scheduling for Retrieval-Augmented LLM Inference under Limited GPU Memory

檔案

日期

2026

類型

語言

中文

摘要

檢索增強生成(Retrieval-Augmented Generation, RAG)已成為提升大型語言模型(Large Language Model, LLM)回答事實性與時效性的重要技術,而反覆檢索方法更會在生成過程中多次觸發向量檢索,以持續取得與目前推理狀態相關的證據。然而,大規模外部知識庫通常需部署於 CPU 記憶體並由 CPU 執行查詢,當系統同時透過 CPU 輔助 LLM 解碼以緩解 GPU 記憶體壓力時,檢索與 CPU 解碼注意力運算將競爭相同的記憶體頻寬、快取容量與執行緒資源,導致檢索延遲與解碼延遲互相增加,進而降低整體服務吞吐量並提高排隊延遲。

本研究聚焦於單機、GPU 記憶體受限且採用反覆檢索之 RAG 線上服務情境,提出一套同時考量 CPU/GPU 協同解碼、階層式 KV cache 配置與檢索排程的系統設計。首先,系統依據 GPU 記憶體用量與工作量估計模型,動態決定各請求的解碼工作量分配於 CPU 或 GPU,並將 CPU 解碼注意力安排於可與 GPU 主要運算重疊的時間區間,以提高兩者並行度並降低彼此阻塞。其次,本研究設計 CPU pinned memory 與 CPU pageable memory 構成的二階層記憶體管理機制,僅以有限 pinned memory 作為 GPU 與 CPU 間的傳輸緩衝區,並於服務過程中動態調整 KV cache 在不同記憶體層級間的放置,藉以在有限 GPU 記憶體下容納較大批次,並降低因記憶體容量壓力所造成的排隊延遲。最後,針對檢索與 CPU 解碼注意力的資源競爭問題,本研究提出基於共享狀態的分段式檢索機制,將檢索工作切分為多個子任務並安排於 CPU 解碼負載較低的時間區間執行,以降低檢索對解碼注意力與其他請求排隊延遲的干擾,同時避免延長檢索完成時間。

本研究於配備 48 GB A6000 GPU 與 64 核心 CPU 之單機平台上,以 Llama 系列模型搭配 IVFSQ 向量索引建構評估環境,並以僅使用 GPU、搭配分塊預填(chunked prefill)之 Sarathi 作為基準系統,比較不同到達率下的吞吐量、TTFT、TPOT 與端到端延遲。實驗結果顯示,在檢索更新間隔為 128 個輸出詞元的主要設定下,本文系統能將吞吐量飽和點與 TTFT 膝點延後至更高到達率,於高負載時吞吐量較基準系統提升約 11\%--14\%,p99 端到端延遲降低約 7\%--11\%;此效益主要以 CPU 解碼注意力造成之 TPOT 與平均端到端延遲增加作為代價。此外,分段式檢索消融實驗顯示,在 64--128 個輸出詞元的檢索更新間隔範圍內,相較完整批次檢索,分段式檢索在不增加檢索完成時間的前提下,同時小幅提升整體吞吐量約 1.08\%--1.82\%、改善平均 TPOT 約 0.97\%--2.41\%,並降低中高負載下的平均 TTFT 與排隊延遲約 2.7\%--6.8\%,且此效益在已測試的間隔範圍內並未隨檢索觸發頻率提高而減弱。上述結果顯示,透過協調 CPU 解碼、檢索與 KV cache 搬移之排程設計,可在 GPU 記憶體受限的環境下有效緩解 CPU 資源競爭,並提升反覆檢索 RAG 服務系統之吞吐量與延遲表現。
Retrieval-Augmented Generation (RAG) has become an important technique for improving the factuality and timeliness of Large Language Model (LLM) responses. Iterative retrieval further triggers vector search multiple times during generation, allowing the system to continuously obtain evidence relevant to the current reasoning state. However, large-scale external knowledge bases are typically deployed in CPU memory and queried by the CPU. When the system also relies on CPU-assisted LLM decoding to mitigate GPU memory pressure, retrieval and CPU decoding attention contend for the same memory bandwidth, cache capacity, and thread resources. This contention increases both retrieval and decoding latency, thereby reducing overall serving throughput and increasing queueing delay.

This thesis targets a single-node, GPU-memory-constrained online RAG serving scenario with iterative retrieval, and proposes a system design that jointly considers CPU/GPU collaborative decoding, hierarchical KV cache placement, and retrieval scheduling. First, based on GPU memory usage and a workload estimation model, the system dynamically assigns each request's decoding workload to the CPU or GPU, and schedules CPU decoding attention in time intervals that can overlap with major GPU computation, improving parallelism and reducing mutual blocking. Second, this thesis designs a two-tier memory management mechanism composed of CPU pinned memory and CPU pageable memory. With only a limited amount of pinned memory serving as the transfer buffer between the GPU and CPU, the system dynamically adjusts KV cache placement across memory tiers during serving, allowing larger batches to be accommodated under limited GPU memory and reducing queueing delay caused by memory capacity pressure. Finally, to address resource contention between retrieval and CPU decoding attention, this thesis proposes a shared-state-based stepwise retrieval mechanism. It divides retrieval work into multiple subtasks and schedules them during periods with lower CPU decoding load, reducing retrieval interference with decoding attention and other requests' queueing delay without prolonging retrieval completion time.

The proposed system is evaluated on a single-node platform equipped with a 48 GB A6000 GPU and a 64-core CPU, using Llama-family models with an IVFSQ vector index. A GPU-only Sarathi baseline with chunked prefill is used for comparison, and throughput, TTFT, TPOT, and end-to-end latency are measured under different arrival rates. Experimental results show that, under the primary setting with a retrieval update interval of 128 output tokens, the proposed system shifts both the throughput saturation point and the TTFT knee to higher arrival rates. Under high load, it improves throughput by approximately 11\%--14\% over the baseline and reduces p99 end-to-end latency by approximately 7\%--11\%, mainly at the cost of increased TPOT and average end-to-end latency caused by CPU decoding attention. In addition, ablation experiments across retrieval update intervals ranging from 64 to 128 output tokens show that, compared to full-batch retrieval, stepwise retrieval, without increasing retrieval completion time, also modestly improves overall throughput by approximately 1.08\%--1.82\% and average TPOT by approximately 0.97\%--2.41\%, while reducing average TTFT and queueing delay under medium-to-high load by approximately 2.7\%--6.8\%, and this benefit does not diminish within the tested interval range as retrieval is triggered more frequently. These results demonstrate that, by coordinating the scheduling of CPU decoding, retrieval, and KV cache migration, the proposed design can effectively mitigate CPU resource contention under limited GPU memory and improve both throughput and latency for iterative-retrieval RAG serving systems.
顯示完整詮釋資料 統計資料

引用此條目

陳宜均 (2026). 有限 GPU 記憶體下檢索增強式大型語言模型推理的 CPU 資源競爭感知排程. https://thesis.lib.nycu.edu.tw/handle/20.500.14371/89137

BibTeX RIS

引用文字依 APA 第 7 版格式自動產生,使用前請再核對。

分享

永久網址:https://thesis.lib.nycu.edu.tw/handle/20.500.14371/89137