fp4linear
fastvideo.layers.fp4linear.nvfp4_quantize_fenced
nvfp4_quantize_fenced(x: torch.Tensor, global_sf: torch.Tensor, sf_layout: int, do_shuffle: bool = False) -> tuple[torch.Tensor, torch.Tensor]
FlashInfer NVFP4 quantization with the DGX Spark (GB10) ordering fence.
Every FastVideo NVFP4 quantization goes through here, so the GB10 workaround covers inference and the QAT straight-through linear alike.
fastvideo.layers.fp4linear.fp4_linear_forward
fp4_linear_forward(x: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor | None]
Source
def fp4_linear_forward(self, x: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor | None]:
# pass config **positionally**; autograd.Function.apply ignores kwargs
bias = self.bias if not self.skip_bias_add else None
output = _LinearFWD4BWD16Fn.apply(x, self.weight, bias, "cutlass", 16, True)
output_bias = self.bias if self.skip_bias_add else None
return output, output_bias