高效计算软动态时间规整,支持任意长序列且内存大幅降低。
SoftDTW-CUDA-Torch: Memory-Efficient GPU-Accelerated Soft Dynamic Time Warping for PyTorch
- 分块反对角线执行,突破1024序列长度限制
- 对数空间反向传播,解决小参数数值不稳问题
- 融合距离计算模式,内存减少达98%适合大序列处理
我们提出 softdtw-cuda-torch,一个开源的 PyTorch 库,用于在 GPU 上高效计算软动态时间规整(SoftDTW)。现有 GPU 实现存在三大缺陷:序列长度硬性上限为 1024、小平滑参数下反向传播时数值不稳定、因生成成对距离张量导致显存消耗过高。本文提出:(1) 分块反对角线核执行,消除序列长度限制;(2) 对数空间反向传播,防止浮点溢出;(3) 融合距离计算模式,避免产生 O(BN M) 的中间距离张量,相比之前工作实现高达 98% 的内存节省。该库支持任意序列长度、完整 PyTorch autograd 集成,并可计算 Soft-DTW 平均形。代码已公开于 https://github.com/BGU-CS-VIL/sdtw-cuda-torch。
原文摘要 · Abstract (English)
We present softdtw-cuda-torch, an open-source PyTorch library for computing Soft Dynamic Time Warping (SoftDTW) on GPUs. Our implementation addresses three key limitations of existing GPU implementations of SoftDTW: a hard sequence-length cap of 1024, numerical instability in the backward pass for small smoothing parameters, and excessive GPU memory consumption from materializing pairwise distance tensors. We introduce (1) tiled anti-diagonal kernel execution that removes the sequence-length constraint, (2) a log-space back-ward pass that prevents floating-point overflow, and (3) a fused distance-computation mode that eliminates the O(BN M ) intermediate distance tensor, achieving up to 98% memory reduction compared to prior work. The library supports arbitrary sequence lengths, full PyTorch autograd integration, and Soft-DTW Barycenter computation. Code is available at https://github.com/BGU-CS-VIL/sdtw-cuda-torch.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。