A GPU-resident Memory-Aware Algorithm for Accelerating Bidiagonalization of Banded Matrices
Ringoot, Alomairy, Edelman
The reduction of a banded matrix to a bidiagonal form is a crucial step in the Singular Value Decomposition (SVD), a cornerstone of scientific computing and AI. Despite being a highly parallel algorithm, it was previously believed to be unsuitable for GPU computation because it is memory bandwidth-bound. Recent developments in GPU hardware, including larger L1 memory per Streaming Multiprocessor/Compute Unit, have changed that. We present the first GPU algorithm for reducing a banded matrix to bidiagonal form as part of the NextLA.jl open-source software package. Our algorithm is based on previous CPU-based multicore parallel cache-efficient bulge chasing algorithms and adapted to optimize for GPU throughput. We leverage Julia Language's Array abstractions and KernelAbstractions to implement a single hardware- and data precision-agnostic function on NVIDIA, AMD, Intel, and Apple Metal GPUs for half, single, and double precision, and examine performance optimization across hardware architectures and data precision. We also develop a hardware-aware performance model and identify key hyperparameters, such as inner tilewidth and block concurrency, that govern optimal GPU execution for bandwidth-bound workloads. We demonstrate highly parallel bandwidth-bound algorithm on the GPU can outperform CPU-based implementations: the GPU algorithm outperforms multithreaded CPU High-Performance libraries PLASMA and SLATE as of matrix size 1024 x 1024 and by a factor over 100 for matrices of 32k x 32k. In addition, the performance of the algorithm increases linearly with matrix bandwidth size, making faster reduction of larger matrix bandwidths now also possible. With this work, we break memory bandwidth barriers, as well as matrix bandwidth barriers, resulting in orders-of-magnitude faster algorithms for the reduction of banded matrices to bidiagonal form on the GPU.
본 논문은 특이값 분해(SVD)의 핵심 단계인 대역 행렬에서 쌍대각 행렬로의 축약을 가속화하기 위한 첫 번째 GPU 상주 메모리 인식 알고리즘을 제시합니다. 이 알고리즘은 높은 병렬성을 가지고 있지만, 메모리 대역폭 제약 특성으로 인해 이전에는 GPU 계산에 부적합한 것으로 간주되었습니다. GPU 하드웨어의 발전, 특히 각 스트림 멀티프로세서/계산 단위당 더 큰 L1 메모리로 인해 이 상황이 변경되었습니다. 저자들은 이전의 CPU 멀티코어 병렬 캐시 효율적인 bulge-chasing 알고리즘을 기반으로 하며, GPU 처리량에 맞게 최적화했습니다. 이 알고리즘은 NVIDIA, AMD, Intel 및 Apple Metal GPU에서 하드웨어 및 데이터 정밀도에 관계없는 단일 함수로 구현되며, 반정밀도, 단정밀도 및 배정밀도 계산을 지원합니다. 실험 결과는 GPU 알고리즘이 1024×1024 행렬 규모부터 멀티스레드 CPU 고성능 라이브러리 PLASMA 및 SLATE를 능가하며, 32k×32k 행렬에서 100배 이상의 성능 향상을 달성함을 보여줍니다.
첫 번째 단계와 세 번째 단계의 GPU 구현이 광범위하게 연구되었지만, 두 번째 단계는 현대 GPU에서 여전히 충분히 탐색되지 않았습니다. Dongarra 등은 2014년에 "가속기는 bulge chasing과 같은 메모리 제약 세분화 계산 작업을 처리할 때 성능이 저하되어 GPU 구현 두 번째 단계의 잠재적 이득을 제한한다"고 지적했습니다.
첫 번째 GPU 상주 메모리 인식 bulge-chasing 알고리즘: 대역 행렬에서 쌍대각 행렬로의 축약을 위한 첫 번째 GPU 네이티브 알고리즘을 제시하며, 최신 세대 고성능 GPU의 우수한 메모리 특성을 충분히 활용하여 최적화된 CPU 구현 대비 10-100배의 성능 향상을 달성합니다.
대역폭 큰 행렬의 캐시 효율적 bulge-chasing 전략: 점진적 대역폭 축약의 새로운 캐시 효율적 대역폭 전략을 통해 GPU 알고리즘은 이전보다 더 큰 대역폭을 처리할 수 있으며, 대규모 SVD에서 첫 번째 단계와 두 번째 단계 간의 최적 대역폭 균형을 변경합니다.
오픈소스 하드웨어 무관 및 데이터 정밀도 무관 구현: Julia 언어 추상화를 기반으로 한 오픈소스 라이브러리로, 단일 함수 정의가 NVIDIA, AMD, Intel 및 Apple GPU에서 단정밀도, 반정밀도 및 배정밀도 계산을 지원합니다.
알고리즘 1: Householder 벡터를 사용한 대역 행렬에서 쌍대각 행렬로의 축약
입력: 대역폭 BW, 내부 타일 너비 TW, 행렬 크기 n
1: for 대역폭 축약 i = (BW-1)/TW → 1 do
2: 목표 대역폭 TBW = 1 + i·TW
3: for 병렬: 각 행 R = 1→n do
4: 행 bulge k = R
5: for 각 행 bulge: j = 0, j+=1 do
6: if 3(R-1) < j and k ≤ n then
7: k행의 HH 벡터를 계산하여 TW개 요소를 제거하고 아래 행에 적용
8: 가장 왼쪽 생성 열 bulge의 HH 벡터를 계산하고 오른쪽 열에 적용
9: k값 업데이트
10: end if
11: end for
12: end for
13: end for
알고리즘 2: 메모리 인식 GPU 커널, 블록당 TPB개 스레드
1: 스레드 메모리: Ai (TW+1)
2: 블록 메모리: X (TW+1)
3: 블록 내 모든 스레드 협력: X ← A[k,..]
4: 스레드 동기화
5: 블록 내 모든 스레드 협력: HH(X)
6: 블록 내 모든 스레드 협력: A[k,..]← X
7: 스레드 동기화
8: for l: 0→(CBW + TW)/TPB - 1 do
9: 스레드 i: 행 r = k + l·CPB + i 계산
10: Ai ← A[r, ...]
11: HH(X, Ai)
12: A[r, ...]← Ai
13: end for
각 GPU 실행 단위의 동시 스레드 블록 수를 제한하는 Max blocks 매개변수를 도입합니다. 알고리즘에 필요한 bulge-chasing 블록 수가 제한을 초과할 때, 소프트웨어 수준 루프 언롤링을 채택하며, 단일 블록에 여러 작업이 할당되고 동일한 커널 시작에서 순차적으로 실행됩니다.