구조 인지 커널을 통한 빠르고 정확한 상대 위치 어텐션
Fast and Exact Relative-Position Attention via Structure-Aware Kernels
한국어 초록
상대 위치 어텐션 메커니즘은 다양한 트랜스포머 아키텍처에서 RoPE의 매력적인 대안을 제공하며, 오디오와 같은 분야에서 우수한 성능을 보인다. 이러한 메커니즘은 일반적으로 내용-위치 항이나 편향-위치 항을 더하여 어텐션 점수를 수정한다. 쿼리와 키에 토큰별 회전을 직접 적용하여 위치를 인코딩하는 RoPE와 달리, 상대 위치 항은 일반적으로 쌍별 오프셋 의존 계산이나 조회를 필요로 하여 융합 어텐션 커널로의 통합을 복잡하게 만들고 시퀀스가 길어질수록 심각한 메모리, 대역폭, 연산 오버헤드를 초래한다. 이 병목을 해결하기 위해 가산적 상대 위치 항을 FlashAttention 방식의 타일 계산에 통합하는 정확한 어텐션 알고리즘을 제안한다. 본 방법은 (1) 오프셋 인지 타일링으로 중복된 인덱싱과 메모리 접근을 피하고, (2) 필요한 키/쿼리 관계 곱만 계산하여 순전파와 역전파 모두에서 토큰 쌍에 걸쳐 재사용하며, (3) 오프셋 기반 그래디언트 샤딩과 집계를 사용하여 원자적 경합을 제거한다. 다양한 상대 위치 어텐션 메커니즘에 걸쳐 통합되고 효율적인 Triton 구현을 제공하고, 이를 단순 구현 및 특화 구현과 비교 평가한다. 8K 토큰 시퀀스에서 본 방법은 각 메커니즘의 가장 강력한 기준선 대비 순전파(역전파)를 1.8-6.4$\times$(2.0-21$\times$) 가속하고 최대 메모리를 2.9-128$\times$(1.4-54$\times$)까지 줄이며, 이를 통해 1.8$\times$ 더 빠르고 메모리를 2.4$\times$ 적게 사용하는 장문맥 종단 간 전사를 가능하게 한다. 따라서 본 방법은 상대 위치 어텐션 트랜스포머를 확장하기 위한 대체 가능한 하드웨어 효율적 해법을 제공한다.
원문 초록
Relative-position attention mechanisms offer compelling alternatives to RoPE across various transformer architectures, delivering superior performance in domains such as audio. These mechanisms typically modify attention scores by adding content-position or bias-position terms. Unlike RoPE, which encodes position via per-token rotations directly on the queries and keys, relative-position terms generally require pairwise offset-dependent computation or lookups, complicating their integration into fused attention kernels and introducing severe memory, bandwidth, and compute overheads as sequences scale. To address this bottleneck, we propose an exact attention algorithm that incorporates additive relative-position terms into FlashAttention-style tiled computation. Our method (1) uses offset-aware tiling to avoid redundant indexing and memory accesses, (2) computes only the necessary key/query-relation products and reuses them across token pairs in both forward and backward passes, and (3) uses offset-based gradient sharding and aggregation, eliminating atomic contention. We provide a unified, efficient Triton implementation across diverse relative-position attention mechanisms and evaluate it against naive and specialized implementations. For 8K-token sequences, our method speeds up the forward (backward) pass by 1.8-6.4$\times$ (2.0-21$\times$) and reduces peak memory up to 2.9-128$\times$ (1.4-54$\times$) over the strongest baseline for each mechanism, enabling long-context end-to-end transcription that is 1.8$\times$ faster and uses 2.4$\times$ less memory. Our method thus provides a drop-in, hardware-efficient solution for scaling relative-position attention transformers.
제출 이력
확인된 버전만 표시합니다. 전체 제출 이력은 arXiv 원문에서 확인하세요.
- arXiv:2611.01182v1제출 시각 미확인
함께 살펴볼 논문
공통 태그를 근거로 연결했습니다. 실제 인용 관계나 논문의 우수성을 뜻하지 않습니다.
공통 태그로 연결된 공개 논문이 아직 없습니다.
토론
이 논문과 연결된 포럼 글이 아직 없습니다.