Back to blog

ACTA: Automatic Configuration of the Tensor Memory Accelerator for High-End GPUs

A software library that heuristically determines optimal tile sizes and queue configurations for TMA-based GPU kernels using the GPU Specification Table (GST) and Little's Law

ACTA: Automatic Configuration of the Tensor Memory Accelerator for High-End GPUs

一、论文概述

项目内容
标题ACTA: Automatic Configuration of the Tensor Memory Accelerator for High-End GPUs
作者Nicolás Meseguer, Yifan Sun, José L. Abellán, Michael Pellauer, Manuel E. Acacio
机构Universidad de Murcia (Spain), William & Mary (USA), NVIDIA (Boston, USA)
论文https://doi.org/10.1145/3725798.3725802
代码未公开
发布GPGPU ‘25, March 01, 2025, Las Vegas, NV, USA
许可CC-BY-4.0

二、核心思想

问题定义

现代高端GPU(如NVIDIA Hopper H100)引入了Tensor Memory Accelerator (TMA)硬件单元,用于异步全局内存到共享内存的数据传输,并与计算重叠以隐藏内存延迟。然而,TMA的配置极其复杂:程序员必须手动确定tile size、queue slots数量、内存步幅等参数。配置空间随队列数量指数增长(例如Matrix-Matrix核可达 2.6×10¹⁴种组合),穷举调优不切实际。

ACTA的核心洞察是:通过GPU Specification Table (GST)获取硬件参数,结合算术强度(arithmetic intensity)和Little’s Law,可以启发式地推断出接近最优的tile size和queue slots配置。

解决方案概述

ACTA是一个软件库,提供主机端API,在kernel launch之前自动计算TMA OperandQueues的最优配置。其工作流程:

  1. 从GST读取硬件规格(SM数量、时钟频率、共享内存大小、带宽、延迟等)
  2. 接收kernel的算法特征(算术强度、consumer wavefront数量、compute units)
  3. 对每个注册的queue,自动计算最优tile size和slot数量
  4. 返回配置参数供kernel launch使用

三、技术架构

GPU Specification Table (GST)

GPU架构总览

GST是ACTA引入的新硬件结构(图1中标红),位于Command Processor之后,提供以下关键参数:

参数类别具体字段
计算能力SM数量、时钟频率、SIMD/Muls per cycle
缓存层次L1 Vector Cache大小/关联度、L1 Inst Cache、L1 Scalar Cache、L2 Cache大小/关联度
内存DRAM容量、峰值带宽
共享内存可用LDS/Shared Memory总量

ACTA工作流程

Host Side:                          GPU Hardware:
────────────                         ─────────────
1. MemCopyH2D(A, B)       ──►   GST (Query hardware params)
2. CreateCommandQueue()
3. InitACTA(ArI=MEDIUM,    ──►
              WFs=8, CUs=64)
4. RegisterQueue(K, 4, TYPE_STREAMING)
5. RegisterQueue(K, 4, TYPE_STATIONARY)
6. SizeQueue()              ──►   optimal_tile_size() + optimal_num_slots()
7. SizeQueue()
8. EnqueueLaunchKernel()    ──►   Kernel launched with ACTA-configured args

核心算法

算法1:最优Tile Size计算 (optimal_tile_size)

对每个候选tile size(范围[min=64, max=8192]元素),计算:

Merit Factor(处理时间与内存传输时间的比值): meritFactor=procTimememTime\text{meritFactor} = \frac{\text{procTime}}{\text{memTime}}

其中:

处理时间计算 (Algorithm 2): bestScheduling=TileSizeSIMDMulsPerCycle×min⁡(ConsumerWfs,4)\text{bestScheduling} = \frac{\text{TileSize}}{\text{SIMDMulsPerCycle} \times \min(\text{ConsumerWfs}, 4)}

procTime=bestScheduling+(bestScheduling−1)×min⁡(ConsumerWfs−1,WfPools)\text{procTime} = \text{bestScheduling} + (\text{bestScheduling} - 1) \times \min(\text{ConsumerWfs} - 1, \text{WfPools})

内存传输时间计算: latencyTotal=TMACycles+DRAMLatency+L2Latency\text{latencyTotal} = \text{TMACycles} + \text{DRAMLatency} + \text{L2Latency}

memTransferTime=TileSize×ElementSizeBandwidth\text{memTransferTime} = \frac{\text{TileSize} \times \text{ElementSize}}{\text{Bandwidth}}

cacheTransferTime=2×TileSize×ElementSizeCacheLineSize\text{cacheTransferTime} = 2 \times \frac{\text{TileSize} \times \text{ElementSize}}{\text{CacheLineSize}}

memTime=latencyTotal+memTransferTime+cacheTransferTime\text{memTime} = \text{latencyTotal} + \text{memTransferTime} + \text{cacheTransferTime}

最终选择使加权merit score最优的tile size,并根据算术强度调整:

  • 低Ar.I.核(Elementwise/Dot-Product):增大tile size以提高内存吞吐
  • 高Ar.I.核(Matrix-Matrix):减小tile size以平衡内存与计算重叠

算法2:最优Slot数量计算 (optimal_num_slots)

Streaming队列 — 使用Little’s Law: N=λ×TN = \lambda \times T 其中N是队列中的平均项目数(slots),λ是tile加载速率,T是单个tile的处理时间。

具体步骤:

  1. 用Little’s Law计算理想slot数
  2. 向上/下取整到最近的2的幂
  3. 根据compute units数量调整
  4. 验证是否适合可用共享内存

Stationary队列 — 基于算术强度:

  1. 计算剩余共享内存
  2. 按队列数量均分
  3. 确定可容纳的slot数量
  4. 同样取2的幂并调整

OperandQueues抽象

ACTA使用自定义OperandQueues(受Bufets [17]启发)管理TMA操作:

  • Producer warp:使用queue传输数据,通过queue函数同步
  • Consumer warps:从queue获取数据并处理,消费后通知queue加载下一tile
  • 两种queue类型:TYPE_STREAMING(tile尺寸变化)和TYPE_STATIONARY(tile尺寸固定)

四、核心创新

创新点说明理论/实验依据
GST硬件表引入新的硬件结构存储GPU规格参数,供ACTA查询图1所示架构;使ACTA跨架构适用
基于Little’s Law的队列配置首次将排队论应用于TMA queue slots分配理论保证流均衡,避免内存压力
Merit Factor启发式结合处理/内存效率比和成本函数选择tile size算法1+2,单遍配置达到穷举的97.22%性能
双队列类型区分Streaming和Stationary队列分别采用不同分配策略Streaming优先,Stationary使用剩余空间

五、实验结果

基准测试

内核执行结果

评估了6种执行方案 across 5个linear algebra kernels:

Kernel维度#Queues设计空间大小
ElementwiseK16,777,216125
Elementwise16,777,2162625
Sumvectors16,777,2162625
Dot-Product2,097,1522625
Matrix-Vector[2048,2048]×20488+12.6×10¹⁴
Matrix-Matrix[512,2048]×[2048,128]8+12.6×10¹⁴

6种执行方案对比(性能归一化到”Speed of Light”理想TMA上限):

  1. Naive Kernel - Untuned:无TMA,无调优 → 最差
  2. Naive Kernel - Exhaustive:无TMA,穷举调优 → 简单核表现好,复杂核受限
  3. No TMA - Naive Config:有TMA但配置不当 → 性能差
  4. No TMA - NVIDIA Heuristic:有TMA但用启发式固定配置 → 简单核有效,复杂核不足
  5. No TMA - Exhaustive Tuning:穷举搜索最优配置 → 最佳但需2.6×10¹⁴次kernel launch
  6. ACTA:单次launch,自动配置 → 性能达到穷举的97.22%(within 2.78%)

关键结果:

  • ElementwiseK/Elementwise/Sumvectors/Dot-Product:ACTA性能达到最优的99%以上(within 1%)
  • Matrix-Vector:ACTA达到理想性能的90%+
  • Matrix-Matrix:ACTA达到理想性能的35%+(受限于shared memory中数据重用最小)
  • 相比NVIDIA启发式配置(tile 64-256, slots 2-4),ACTA在复杂核上显著优于固定启发式

消融实验

ACTA通过对比不同配置策略(untuned/heuristic/exhaustive/ACTA)间接进行了消融,证明:

  • 自动配置远优于无TMA(即使穷举调优)
  • 自动配置显著优于NVIDIA启发式固定配置
  • 自动配置接近穷举调优(仅差2.78%),但只需一次kernel launch

六、相关工作

工作关系
Singe (PPoPP’14) [1]Warp specialization编译器,ACTA继承其producer-consumer范式
Bufets (ASPLOS’19) [17]显式解耦数据编排idiom,ACTA的OperandQueues受其启发
WASP (HPCA’24) [4]硬件加速自动warp specialization,与TMA互补
CudaDMA (SC’11)Bauer等人的早期工作,2-way warp specialization
NVIDIA Hopper TMA [3, 12]ACTA针对的硬件目标

七、总结

核心贡献

  1. ACTA库:首次实现TMA配置的自动化,通过GST+Little’s Law启发式算法消除手动调优需求
  2. GST硬件结构:提出GPU Specification Table作为硬件抽象层,使配置跨架构可移植
  3. 接近最优的单遍配置:仅需一次kernel launch即达到穷举调优的97.22%性能
  4. 简化开发流程:开发者只需调用InitACTA/RegisterQueue/SizeQueue三个API即可配置TMA

局限性

  • 当前仅在AMD R9 Nano + 模拟TMA上评估(TMA-Like),尚未在真实Hopper GPU上验证
  • Matrix-Matrix核的性能瓶颈在于shared memory重用率极低,这是架构限制而非ACTA算法问题
  • 未来需在多款GPU架构上验证可移植性

技术影响

ACTA代表了GPU编程模型的重要转变:从”程序员手动调优”到”硬件信息+启发式算法自动配置”。随着TMA成为高端GPU的标准特性(Hopper及后续架构),类似ACTA的自动配置工具将大幅降低GPU编程门槛,同时保持高性能。

八、参考资源

  • 论文DOI: https://doi.org/10.1145/3725798.3725802
  • GPGPU ‘25: 17th Workshop on General Purpose Processing Using GPU, Las Vegas, NV, USA
  • MGPUSim: https://github.com/mgpusim/mgpusim (模拟环境)
  • Bufets论文: Pellauer et al., ASPLOS ‘19, “An Efficient and Composable Storage Idiom for Explicit Decoupled Data Orchestration”
  • WASP论文: Crago et al., HPCA ‘24, “Exploiting GPU Pipeline Parallelism with Hardware-Accelerated Automatic Warp Specialization”