Class MxFp8MarlinLinear
java.lang.Object
smile.llm.quant.MxFp8MarlinLinear
- All Implemented Interfaces:
AutoCloseable, LinearOp, MxFp8Layer
Linear layer whose weight stays in MXFP8 (FP8 E4M3 elements, E8M0 scale per 32 elements) in the
Marlin tile layout and is multiplied with bfloat16 activations by the weight-only Marlin kernel.
It works on GPUs without native FP8 (Ampere). The weight takes one byte per element plus 1/32 byte
of scale.
The layer is created empty and receives its weight from the checkpoint through
setWeight(Tensor, Tensor); it owns no module parameters, so LayerBlock.to(device, dtype) never
converts it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Applies the linear transformation.static MxFp8MarlinLinearfuse(MxFp8MarlinLinear... parts) Concatenates the outputs of several loaded layers that share their input into one layer, so a single kernel launch computes all of them.booleanisLoaded()Returns whether the weight has been installed.intReturns the output size N.voidInstalls the weight from checkpoint tensors, repacking them for the kernel.
-
Constructor Details
-
MxFp8MarlinLinear
public MxFp8MarlinLinear(int inFeatures, int outFeatures) Constructor.- Parameters:
inFeatures- reduction size K; a multiple of 128.outFeatures- output size N; a multiple of 64.
-
-
Method Details
-
setWeight
Installs the weight from checkpoint tensors, repacking them for the kernel.- Specified by:
setWeightin interfaceMxFp8Layer- Parameters:
weight- FP8 E4M3[N, K]on the target CUDA device.scale- E8M0 scales as uint8[N, K / 32]on the same device.
-
fuse
Concatenates the outputs of several loaded layers that share their input into one layer, so a single kernel launch computes all of them. Marlin tiles are 64 output columns wide, so packed weights and permuted scales concatenate along the output dimension. The parts are closed.- Parameters:
parts- loaded layers with equalinFeatures; their outputs appear in this order.- Returns:
- the fused layer.
-
outFeatures
public int outFeatures()Returns the output size N.- Returns:
- the output size N.
-
isLoaded
public boolean isLoaded()Returns whether the weight has been installed.- Specified by:
isLoadedin interfaceMxFp8Layer- Returns:
trueoncesetWeight(Tensor, Tensor)has run.
-
forward
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceMxFp8Layer
-