Class Fp8BlockLinear
java.lang.Object
smile.llm.quant.Fp8BlockLinear
- All Implemented Interfaces:
AutoCloseable, LinearOp
Block-scaled FP8 linear for DeepSeek / Qwen fine-grained FP8 checkpoints
(
weight_block_size=[128,128] + weight_scale_inv).
Uses LibTorch at::_scaled_mm_v2 with activation BlockWise1x128 and
weight BlockWise128x128 scales.
-
Constructor Summary
ConstructorsConstructorDescriptionFp8BlockLinear(Tensor weight, Tensor weightScaleInv, Tensor bias, ScalarType outDtype) Creates a block-scaled FP8 linear layer. -
Method Summary
-
Constructor Details
-
Fp8BlockLinear
Creates a block-scaled FP8 linear layer.- Parameters:
weight- FP8 weight[outFeatures, inFeatures].weightScaleInv- float32 block inverse scales[ceil(out/128), ceil(in/128)].bias- optional bias, ornull.outDtype- output dtype (BF16 or FP16).
-
-
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].
-
weightScaleInv
Returns the block inverse scale tensor.- Returns:
- block inverse scales.
-
forward
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-