C.W.K.
Stream
Lesson 01 of 05 · published

What Is BLAS

~10 min · blas, history, intro

Level 0Beginner
0 XP0/38 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

The 1979 spec that runs the modern AI stack

Would you rebuild NumPy from scratch just to add two vectors? No. So why hand-roll GPU kernels when BLAS already exists?

BLAS (Basic Linear Algebra Subprograms) is the bedrock API of numerical computing. Conceived in 1979 for Fortran supercomputers, it specifies ~60 routines covering vector ops (Level 1), matrix-vector ops (Level 2), and matrix-matrix ops (Level 3). Almost every scientific library today layers on top of it — directly or indirectly.

Why it matters:

  1. Optimization centralization — vendors pour years of tuning into one tiny set of kernels; everyone inherits the speedups for free.
  2. Portability — a Fortran program from 1982 still compiles and runs on an M3 Ultra in 2025. The interface didn't change.
  3. Composability — NumPy, PyTorch, JAX, MLX, Core ML all call BLAS underneath. They differ in the language above, not the kernels below.
LevelOperand shapesGPU suitability
1vector ⊗ vector (AXPY, dot)Poor — bandwidth-bound
2matrix ⊗ vector (GEMV)Meh — still bandwidth-bound
3matrix ⊗ matrix (GEMM)Excellent — compute-bound, what GPUs are for

Who ships what?

  • NVIDIA: cuBLAS (and cuBLASLt for Tensor Core integration).
  • AMD: rocBLAS / hipBLAS.
  • Intel / CPU: oneAPI MKL, OpenBLAS.
  • Apple: Accelerate (CPU) + Metal Performance Shaders' MPSMatrixMultiplication (GPU).

Code

The same call shape, four backends·python
# All of these call vendor BLAS GEMM under the hood.

# NumPy (CPU) — uses OpenBLAS or MKL depending on your wheel
import numpy as np
C = np.matmul(A, B)

# PyTorch CUDA — calls cuBLAS
import torch
C = torch.matmul(A_cuda, B_cuda)

# PyTorch MPS — calls MPSMatrixMultiplication
C = torch.matmul(A_mps, B_mps)

# MLX — calls MPSMatrixMultiplication directly
import mlx.core as mx
C = mx.matmul(A_m, B_m); mx.eval(C)

External links

Exercise

On any environment with NumPy installed, run np.show_config(). Look for 'openblas_info' or 'mkl_info' — that's the actual BLAS library NumPy is linked against on your machine. Compare the build info if you have multiple Python environments. The same NumPy code can be 2-3× faster on MKL-linked builds; that's BLAS choice, not NumPy code.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.