Class Fp8Linear
java.lang.Object
smile.llm.quant.Fp8Linear
- All Implemented Interfaces:
AutoCloseable, LinearOp
Weight-only FP8 linear layer using cuBLASLt via LibTorch
_scaled_mm.
Holds Float8_e4m3fn weights in [N,K] layout expected by
at::_scaled_mm, plus a float weight scale. Activations are cast to
FP8 with a dynamic (or fixed) scale; output is BF16 or FP16.
-
Constructor Summary
ConstructorsConstructorDescriptionFp8Linear(Tensor weight, Tensor weightScale, Tensor bias, ScalarType outDtype) Creates a weight-only FP8 linear layer. -
Method Summary
-
Constructor Details
-
Fp8Linear
Creates a weight-only FP8 linear layer.- Parameters:
weight- FP8 weight[outFeatures, inFeatures].weightScale- float scale forweight.bias- optional bias (same compute dtype), ornull.outDtype- output dtype (ScalarType.BFloat16orScalarType.Half).
-
-
Method Details
-
inFeatures
public int inFeatures()Returns the input feature count.- Returns:
- input feature count.
-
outFeatures
public int outFeatures()Returns the output feature count.- Returns:
- output feature count.
-
weight
Returns the FP8 weight tensor.- Returns:
- FP8 weight
[outFeatures, inFeatures].
-
weightScale
-
forward
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-