Expand description
2026-09-25: cuBLASLt FFI for out[M,N] = act[M,K] @ weight[N,K]ᵀ: BF16 GEMMs
with BF16 or FP32 output here, FP8 E4M3 GEMMs in fp8, and the FP8
scale-tensor layout math in scale_layout.
Owner: gpu-runtime (cuBLASLt wrapper). Invariants:
CTXholds a single cuBLASLt handle and 64 MiB workspace for the process, allocated withcuMemAlloc_v2, outside the backend’s allocation ledger.- Every GEMM here passes the whole workspace to
cublasLtMatmul, so two GEMMs must not run concurrently.
Modules§
- scale_
layout - 2026-09-25: Index math for the FP32 scale tensors of the block-scaled
FP8 GEMM (
super::fp8_gemm_act_weight_t_blkscaled): the activation scales in the layout it passes to cuBLASLt, in the quantizer’s layout, and the weight-scale stride check.
Functions§
- bf16_
gemm_ act_ weight_ t - 2026-09-25: Row-major
out[M,N] = act[M,K] @ weight[N,K]ᵀ, all BF16, FP32 accumulation. In cuBLASLt’s column-major terms:D[N,M] = opT(weightᶜ[K,N]) · opN(actᶜ[K,M]). - bf16_
gemm_ act_ weight_ t_ f32_ out - 2026-09-25:
bf16_gemm_act_weight_twith an FP32out. Only the D layout’s type differs; both useCUBLAS_COMPUTE_32F. - fp8_
gemm_ act_ weight_ t_ blkscaled - 2026-09-25: FP8 E4M3
out[M,N] = act[M,K] @ weight[N,K]ᵀ, BF16 output, with FP32 block scales:BLK128x128_32Fon the weight (cuBLASLt’s A) andVEC128_32Fon the activation (B). The scale layouts are insuper::scale_layout: - fp8_
gemm_ act_ weight_ t_ blkscaled_ ldc - 2026-09-25:
fp8_gemm_act_weight_t_blkscaledwith output rowsldcBF16 elements apart: D is column-major[N, m]with leading dimensionldc, i.e. row-major[m, N]with row pitchldc. The multi-seq decode Q/K/V projections use it to write each row into its sequence’s slot of the QKV buffer (w8a8_decode.rsqkv_decode_w8a8_plans,ldc=per_seq_qkvin BF16 elements). - fp8_
gemm_ act_ weight_ t_ rowwise - 2026-09-25: FP8 E4M3
out[M,N] = act[M,K] @ weight[N,K]ᵀ, BF16 output, with FP32OUTER_VECscales on both operands:weight_scale[N]per weight row (cuBLASLt’s A) andact_scale[M]per token (B). - prewarm
- 2026-09-25: Run one 64x64x64 BF16 GEMM on
streamat model load (serve_load.rs), so the first cuBLASLt call, includingctx’scublasLtCreateand workspace allocation, happens before the first request.