모던 AI 스택을 굴리는 1979년 spec
벡터 둘 더하려고 NumPy 처음부터 다시 만들어? 아니지. 그러면 BLAS가 이미 있는데 GPU 커널 손코딩하는 이유는?
BLAS (Basic Linear Algebra Subprograms)는 numerical computing의 bedrock API. 1979년 Fortran 슈퍼컴퓨터용으로 conceived됐고 vector op (Level 1), matrix-vector op (Level 2), matrix-matrix op (Level 3) 다루는 ~60 routine spec. 오늘 거의 모든 과학 라이브러리가 직접 또는 간접적으로 그 위에 layer.
중요한 이유:
- Optimization 중앙집중 — vendor가 작은 커널 셋에 수년 튜닝 쏟아부음, 모두 공짜로 가속 상속.
- Portability — 1982년 Fortran 프로그램이 2025년 M3 Ultra에서 그대로 컴파일+실행. 인터페이스 안 바뀜.
- Composability — NumPy, PyTorch, JAX, MLX, Core ML 다 밑에서 BLAS 호출. 위 언어가 다를 뿐 아래 커널은 같음.
| Level | Operand 모양 | GPU 적합성 |
|---|---|---|
| 1 | 벡터 ⊗ 벡터 (AXPY, dot) | 나쁨 — bandwidth-bound |
| 2 | 행렬 ⊗ 벡터 (GEMV) | 그저 그럼 — 여전히 bandwidth-bound |
| 3 | 행렬 ⊗ 행렬 (GEMM) | 훌륭 — compute-bound, GPU의 존재 이유 |
누가 뭐 ship?
- NVIDIA: cuBLAS (Tensor Core integration용 cuBLASLt도).
- AMD: rocBLAS / hipBLAS.
- Intel / CPU: oneAPI MKL, OpenBLAS.
- Apple: Accelerate (CPU) + Metal Performance Shaders의
MPSMatrixMultiplication(GPU).