flashrt/fp4-gemm

FlashRT native Blackwell NVFP4 W4A16 GEMM kernels.

Functions

  • sfa_size_bytes
  • quantize_fp4_sfa_fp16
  • dequantize_fp4_sfa_fp16
  • fp4_w4a16_linear_bf16

Example

from kernels import get_kernel
import torch

ops = get_kernel("flashrt/fp4-gemm", version=1, trust_remote_code=True)

x = torch.randn((32, 256), device="cuda", dtype=torch.float16)
w = torch.randn((512, 256), device="cuda", dtype=torch.float16)

a, sfa = ops.quantize_fp4_sfa_fp16(x, is_sfb=False)
b, sfb = ops.quantize_fp4_sfa_fp16(w, is_sfb=True)
y = ops.fp4_w4a16_linear_bf16(a, b, sfa, sfb)

Notes

  • Blackwell sm_120a, CUDA 12.8+.
  • Inputs are packed FP4 E2M1 plus CUTLASS Sm1xx SFA/SFB scale buffers.
  • Output is BF16.
  • variant=0/1/2 exposes the default, widen, and pingpong schedules.
Downloads last month
-
Supported hardwares new
CUDA
12.0a
DGX Spark
GB10
128GB
GPU
RTX PRO 6000 WS
96GB
GPU
RTX PRO 6000 Max-Q
96GB
GPU
RTX PRO 5000
48GB
GPU
RTX PRO 4500 WS
32GB
GPU
RTX PRO 4000
24GB
GPU
RTX PRO 4000 SFF
24GB
GPU
RTX PRO 2000
16GB
RTX
RTX 5090
32GB
RTX
RTX 5090 D
32GB
RTX
RTX 5090 Mobile
24GB
RTX
RTX 5080
16GB
RTX
RTX 5080 Mobile
16GB
RTX
RTX 5070
12GB
RTX
RTX 5070 Mobile
8GB
RTX
RTX 5070 Ti
16GB
RTX
RTX 5070 Ti Mobile
12GB
RTX
RTX 5060 Ti
16GB
RTX
RTX 5060
8GB
RTX
RTX 5060 Mobile
8GB
OS
linux
Arch
x86_64