Class QuantLinearFactory
java.lang.Object
smile.llm.quant.QuantLinearFactory
-
Method Summary
Modifier and TypeMethodDescriptionstatic LinearOpdense(int inFeatures, int outFeatures, boolean bias) Builds a denseLinearLayerwrapped asLinearOp.static LinearOpfp8(Tensor weightFp8, Tensor weightScale, Tensor bias, ScalarType outDtype) Builds an FP8 linear from native FP8 weight + tensor scale.static LinearOpfp8Block(Tensor weightFp8, Tensor weightScaleInv, Tensor bias, ScalarType outDtype) Builds a block-scaled FP8 linear (DeepSeek / Qwen block-128 layout).static LinearOpmarlinFromAwq(Tensor qweight, Tensor scales, Tensor qzeros, int groupSize, Device device) Packs AWQ tensors and buildsMarlinLinearvia direct AWQ→Marlin pack.static LinearOpmarlinFromGptq(Tensor qweight, Tensor scales, Tensor qzeros, Tensor gIdx, int groupSize, Device device) Packs GPTQ tensors and buildsMarlinLinear(Ampere/Ada only).static LinearOpBuilds an NVFP4 linear (may throw at forward until LibTorch NVFP4 is wired).
-
Method Details
-
dense
Builds a denseLinearLayerwrapped asLinearOp.- Parameters:
inFeatures- input features.outFeatures- output features.bias- whether to include bias.- Returns:
- dense linear op.
-
fp8
Builds an FP8 linear from native FP8 weight + tensor scale.- Parameters:
weightFp8- FP8 weight.weightScale- float scale.bias- optional bias, ornull.outDtype- output dtype.- Returns:
- FP8 linear op.
-
fp8Block
public static LinearOp fp8Block(Tensor weightFp8, Tensor weightScaleInv, Tensor bias, ScalarType outDtype) Builds a block-scaled FP8 linear (DeepSeek / Qwen block-128 layout).- Parameters:
weightFp8- FP8 weight.weightScaleInv- block inverse scales.bias- optional bias, ornull.outDtype- output dtype.- Returns:
- block FP8 linear op.
-
nvfp4
-
marlinFromGptq
public static LinearOp marlinFromGptq(Tensor qweight, Tensor scales, Tensor qzeros, Tensor gIdx, int groupSize, Device device) Packs GPTQ tensors and buildsMarlinLinear(Ampere/Ada only). Uses direct GPTQ→Marlin pack (act-order checkpoints fail fast).- Parameters:
qweight- GPTQ packed weights.scales- group scales.qzeros- packed zeros, ornull.gIdx- GPTQg_idx, ornull.groupSize- quantization group size.device- destination device.- Returns:
- Marlin linear op.
-
marlinFromAwq
public static LinearOp marlinFromAwq(Tensor qweight, Tensor scales, Tensor qzeros, int groupSize, Device device) Packs AWQ tensors and buildsMarlinLinearvia direct AWQ→Marlin pack.- Parameters:
qweight- AWQ packed weights.scales- group scales.qzeros- packed zeros, ornull.groupSize- quantization group size.device- destination device.- Returns:
- Marlin linear op.
-