flashinfer.gemm.PreparedNvFp4LoraAdapter¶
- class flashinfer.gemm.PreparedNvFp4LoraAdapter(b_folded: Tensor, lora_b: Tensor, lora_scale: Tensor, alpha: Tensor, pins: dict, n: int, rank: int)¶
A LoRA adapter prepared for the NVFP4 prepared path of
mm_nvfp4_lora()(lora_adapter=).b_folded=bf16(lora_b * lora_scale / alpha)([N, rank]bf16: ONE bf16 rounding of the fp32 product oflora_band the fp32 ratiodiv.rn.f32(fp32(lora_scale), fp32(alpha))– bit-identical to thel1fold ofmm_nvfp4_svdquant()).lora_scaleis the adapter’s own device scalar; the kernel reads it on the device (lora_scale == 0takes the zero-adapter path, bitwise the adapter-off call). Snapshot semantics: the adapter keeps references to its source tensorslora_b/lora_scale/alphaandpins= their(data_ptr, _version, shape, device)at prepare time; every call compares these host integers (no sync) and raisesStaleAdapterErrornaming the tensor that moved without a re-prepare. Writes that bypass torch’s version counter (NCCL into an existing buffer, a raw memcpy) need an explicit prepare.alphais fixed per prepared adapter: the call requires the SAMEalphatensor (identity) at its pinned version – re-prepare when alpha changes (no value comparison).- __init__(b_folded: Tensor, lora_b: Tensor, lora_scale: Tensor, alpha: Tensor, pins: dict, n: int, rank: int) None¶
Methods
__init__(b_folded, lora_b, lora_scale, ...)check_fresh()Raise
StaleAdapterErrorwhen a source tensor moved since the prepare (host integers only, no sync).Attributes
b_foldedlora_blora_scalealphapinsnrank