Class Nvfp4Linear

java.lang.Object
smile.llm.quant.Nvfp4Linear
All Implemented Interfaces:
AutoCloseable, LinearOp

public final class Nvfp4Linear extends Object implements LinearOp, AutoCloseable
NVFP4 weight-only linear for Blackwell (sm_100+).

Wraps LibTorch / cuBLASLt NVFP4 GEMM when available. Until the linked LibTorch exposes a stable NVFP4 scaled-mm entry point, forward(Tensor) throws a clear error (no Marlin fallback on Blackwell).

  • Constructor Details

    • Nvfp4Linear

      public Nvfp4Linear(Tensor weight, Tensor weightScale, Tensor bias)
      Creates an NVFP4 weight-only linear layer.
      Parameters:
      weight - NVFP4 weight tensor.
      weightScale - weight scale tensor.
      bias - optional bias, or null.
  • Method Details

    • inFeatures

      public int inFeatures()
      Returns the input feature count.
      Returns:
      input features.
    • outFeatures

      public int outFeatures()
      Returns the output feature count.
      Returns:
      output features.
    • forward

      public Tensor forward(Tensor input)
      Description copied from interface: LinearOp
      Applies the linear transformation.
      Specified by:
      forward in interface LinearOp
      Parameters:
      input - activations (caller retains ownership).
      Returns:
      owned output tensor (caller must close).
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable