Compute matrix multiplication where both matrix A and matrix B are stored in NVFP4 format. The equation below defines conceptual dequantization semantics for correctness:
cij=ℓ=0∑K−1Adequant,iℓBdequant,jℓ.
Note: B is stored in row-major as N×K (i.e. Bdequant is N×K), so the multiplication is effectively
C=AdequantBdequantT.
Input
- qa: packed NVFP4 E2M1 payload bytes for matrix A of logical shape M×K
- scalea: NVFP4 per-block FP8 scale bytes for A, logical shape M×K/16
- qb: packed NVFP4 E2M1 payload bytes for matrix B of logical shape N×K
- scaleb: NVFP4 per-block FP8 scale bytes for B, logical shape N×K/16
- M, N, K: matrix dimensions (K divisible by 16)
- sf_g_a: global NVFP4 scale factor for A
- sf_g_b: global NVFP4 encode factor for B
Output
- c: FP16 matrix of shape M×N, with c=AdequantBdequantT
Notes
- The reference implementation in this problem calls torch.nn.functional.scaled_mm and does not materialize Adequant or Bdequant.
- The
scale_a and scale_b inputs are already in swizzled 32×4×4 layout; do not apply an additional swizzle.
Test Case Sizes
- 1024 x 1024 x 1024
- 2048 x 1024 x 2048
- 4096 x 2048 x 4096
- 4096 x 4096 x 4096
- 8192 x 4096 x 8192