作者/机构: Dongha Yoon (Virginia Tech), Younghoon Min (SK Hynix America), Hoshik Kim (SK Hynix America), Sam H. Noh (Virginia Tech), Jongryool Kim (SK Hynix America)
CXL共享内存基础与挑战。Compute Express Link (CXL) 【1,CXL specification+URL: https://computeexpresslink.org/cxl-specification/ 】 建立在PCIe之上,在CPU和设备之间提供高带宽、低延迟的通信。特别是CXL Type-3设备,通过CXL.mem协议提供主机可访问的内存。在当前系统中,CXL Type-3设备通常作为一个支持DAX的内存区域暴露出来,可以映射到用户空间作为字节寻址内存。从单节点软件的角度来看,它的行为类似于本地DRAM,支持正常的load/store和DMA读写。然而,当多个主机连接到同一个CXL设备时,硬件并不会自动在主机间保持缓存一致性。近期的研究表明,即使存在一致性,也仅限于特定设备的小区域,无法扩展到设备的全部容量 【8,Tigon: a distributed database for a cxl pod+2025+OSDI】,【9,Memory sharing with cxl: Hardware and software design approaches+2024】。因此,将CXL用作共享内存池的应用程序必须显式地管理跨节点的同步和数据可见性 【8,Tigon: a distributed database for a cxl pod+2025+OSDI】,【21,Partial failure resilient memory management system for (cxl-based) distributed shared memory+2023+SOSP】。CXL为机架级系统提供了无网络栈的内存通信语义,但缺乏跨节点原子操作和全设备一致性,这要求软件必须仔细处理缓存行状态、刷新和排序。
LLM推理的两阶段特性与KV缓存。现代LLM(如GPT、Gemini和Llama 【7,Gemini 2.5: Pushing the frontier with advanced reasoning, multimodality, long context, and next generation agentic capabilities+2025】,【11,The llama 3 herd of models+2024】,【12,Chatgpt (gpt-5)+URL: https://openai.com/chatgpt】)是仅解码器(decoder-only)的Transformer,自回归地生成token。推理分为Prefill和Decode两个阶段。在Prefill期间,长度为$N$的完整输入提示在一次前向传播中被处理,计算$O(N^2)$的注意力交互,此阶段是计算密集型的。模型生成第一个输出token以及$N$个K/V张量,形成初始KV缓存。在Decode阶段,模型逐个生成token,在步骤$t$时,模型仅计算新token的Q/K/V向量,并与之前存储在KV缓存中的$N+t-1$个张量进行注意力计算,此阶段转变为内存受限。为了避免重计算,系统缓存每一层的中间K和V张量。对于大模型,KV缓存占据了极大的内存(例 如Llama3 405B每token需$504\mathrm{KB}$)。
LLM推理中KV张量的演变
KV管理与分离式架构的耦合。在单节点内,系统如vLLM通过操作系统分页机制解决GPU内存碎片化,SGLang引入RadixAttention实现前缀共享 【10,Efficient memory management for large language model serving with pagedattention+2023+SOSP】,【22,Sglang: efficient execution of structured language model programs+2025+NIPS】。在多节点分离式架构中(如Splitwise、DistServe、Preble和Dynamo 【3,NVIDIA Dynamo+URL: https://github.com/ai-dynamo/dynamo】,【13 ,Splitwise: Efficient generative llm inference using phase splitting+2024+ISCA】,【17,Preble: Efficient distributed prompt scheduling for LLM serving+2025+ICLR】,【23,Distserve: disaggregating prefill and decoding for goodputoptimized large language model serving+2024+OSDI】),Prefill和Decode被拆分到不同worker,这改善了资源扩展,但每次请求都依赖RDMA等网络路径将KV块从Prefill传输到Decode worker。即使LMCache 【6,Lmcache: An efficient kv cache layer for enterprise-scale llm inference+2025】 和Mooncake 【14,Mooncake: Trading more storage for less computation — a KVCache-centric architecture for serving LLM chatbot+2025+FAST】 支持跨节点KV复用,它们依然保留了基于网络的KV张量移动。TraCT探索使用CXL共享内存直接作为机架级KV缓存和传输层,消除网络跳数。
TraCT的设计目标与挑战。TraCT旨在实现三个目标:1. 无网络的KV传输,用GPU与CXL间的直接DMA替代RDMA;2. 机架级KV复用,将KV块及前缀缓存元数据直接存入CXL共享内存;3. 去中心化KV管理,避免集中式元数据服务器,worker通过load/store直接管理状态。实现这些目标面临三大挑战:首先,必须在没有硬件原子操作和全局一致性的情况下确保共享内存区域的互斥访问。现有方法要么依赖极小的硬件一致性区域,要么使用消耗$O(N^2)$内存的队列(如cMPI 【18,cmpi: Using cxl memory sharing for mpi one-sided and two-sided inter-node communications+2025+SC】),或者引入违背CXL初衷的集中式服务器(如Beluga 【19,Beluga: A cxlbased memory architecture for scalable and efficient llm kvcache management+2025】)。其次,在缺乏硬件缓存一致性的情况下,必须处理缓存刷新以保证数据可见性。最后,需要一种不依赖进程私有虚拟地址指针的共享对象管理机制。
避免错误可见性的clflush选择:虽然clflushopt指令开销较低且异步 【15,Persistent memory programming+2017】,【18,cmpi: Using cxl memory sharing for mpi one-sided and two-sided inter-node communications+2025+SC】,但配合mfence并不能保证刷新已到达CXL设备,这会导致锁释放后其他节点读到未落盘的旧值。为了保证节点间的绝对正确性,TraCT强制使用clflush指令,该指令能确保在指令完成前缓存行被强制从本地缓存层次结构中驱逐。
分离式LLM推理:近期工作如Splitwise 【13,Splitwise: Efficient generative llm inference using phase splitting+2024+ISCA】、DistServe 【23,Distserve: disaggregating prefill and decoding for goodputoptimized large language model serving+2024+OSDI】、Preble 【17,Preble: Efficient distributed prompt scheduling for LLM serving+2025+ICLR】 和 Dynamo 【3,NVIDIA Dynamo+URL: https://github.com/ai-dynamo/dynamo 】 探索了分离计算密集的Prefill和延迟敏感的Decode阶段。然而,这些系统均将KV传输视为基于RDMA的网络操作,网络跳数始终处于关键路径中。TraCT通过CXL Type-3共享内存和GPU-CXL DMA彻底消除了主机间拷贝和网络序列化。
多层KV缓存:LMCache/CacheBlend 【6,Lmcache: An efficient kv cache layer for enterprise-scale llm inference+2025】,【20,Cacheblend: Fast large language model serving for rag with cached knowledge fusion+2025+EuroSys】 和 Mooncake 【14,Mooncake: Trading more storage for less computation — a KVCache-centric architecture for serving LLM chatbot+2025+FAST】 实现了跨分离式服务器的KV状态共享,但它们仍然依赖网络进行跨节点传输。TraCT与这些工作互补,但将前缀感知的KV缓存放置在支持DMA直接访问的CXL共享内存中,改变了性能包络。
基于CXL的内存系统:CXL-SHM 【21,Partial failure resilient memory management system for (cxl-based) distributed shared memory+2023+SOSP】、Tigon 【8,Tigon: a distributed database for a cxl pod+2025+OSDI】、cMPI 【18,cmpi: Using cxl memory sharing for mpi one-sided and two-sided inter-node communications+2025+SC】 和 Beluga 【19,Beluga: A cxlbased memory architecture for scalable and efficient llm kvcache management+2025】 探索了CXL共享内存。但它们的同步设计要么依赖特定设备的硬件一致性区域,要么使用队列避免互斥,或者使用集中式元数据服务器。TraCT首次展示了针对非一致性、TB级CXL内存的去中心化KV缓存设计,完全通过软件管理的缓存行刷新和两层锁机制实现机架级共享。
【16】Ucx: an open source framework for hpc network apis and beyond (2015 High-Performance Interconnects)。在实验环境中引用,作为NIXL底层依赖的网络传输库。
【17】Preble: Efficient distributed prompt scheduling for LLM serving (2025 ICLR)。在背景和相关工作中引用,作为分离式架构调度的相关系统。
【18】cmpi: Using cxl memory sharing for mpi one-sided and two-sided inter-node communications (2025 SC)。在设计挑战和方法细节中多次引用,指出了其生产者-消费者队列同步机制存在$O(N^2)$内存开销,以及其Arena对象分配器对层次结构的低效性。
【19】Beluga: A cxlbased memory architecture for scalable and efficient llm kvcache management (2025)。在设计挑战中引用,指出其采用集中式元数据服务器违背了CXL load/store初衷。
【20】Cacheblend: Fast large language model serving for rag with cached knowledge fusion (2025 EuroSys)。在相关工作中引用,作为多层KV缓存的补充研究。
【21】Partial failure resilient memory management system for (cxl-based) distributed shared memory (2023 SOSP)。在背景和相关工作中引用,说明早期CXL共享内存系统依赖特定设备的硬件一致性或原子操作。
【22】Sglang: efficient execution of structured language model programs (2025 NIPS)。在背景中引用,说明SGLang通过RadixAttention实现了单节点前缀共享。
【23】Distserve: disaggregating prefill and decoding for goodputoptimized large language model serving (2024 OSDI)。在背景和相关工作中引用,作为解耦Prefill和Decode worker的经典架构。