Package smile.llm.quant


package smile.llm.quant
Weight quantization backends: FP8 / NVFP4 (primary) and Marlin (Ampere failover).
  • Class
    Description
    Releases placeholder dense LinearLayer shells after quantized ops are installed, so empty GPU weight storage does not inflate the KV budget.
    Dequantizes DeepSeek / Qwen-style fine-grained FP8 weights (weight_block_size = [128, 128] + weight_scale_inv).
    DeepSeek-style W8A8 block FP8 matrix multiply: activations are quantized on the fly to E4M3 with one float32 scale per 1x128 group, weights are E4M3 with one float32 scale per 128x128 tile.
    Block-scaled FP8 linear for DeepSeek / Qwen fine-grained FP8 checkpoints (weight_block_size=[128,128] + weight_scale_inv).
    Block-scaled FP8 linear for GPUs without native FP8 (Ampere, Ada): DeepSeek / Qwen fine-grained checkpoints (weight_block_size=[128,128] with float32 weight_scale_inv) keep their FP8 weights in device memory and run through the weight-only Marlin kernel with bfloat16 activations.
    Helpers for FP8 KV store/load with per-tensor scales.
    Weight-only FP8 linear layer using cuBLASLt via LibTorch _scaled_mm.
    Shared forward interface for dense, FP8, NVFP4, and Marlin linear layers.
    Marlin FP16Ă—INT4 linear layer (Ampere/Ada failover for GPTQ/AWQ).
    Packs HuggingFace GPTQ / AWQ INT4 tensors into Marlin layout for MarlinLinear.
    Result of packing: Marlin qweight, scales, logical features.
    MXFP8 (OCP microscaling) weights: FP8 E4M3 elements with one shared E8M0 scale per 32 consecutive elements along the reduction dimension.
    Linear layer for MXFP8 weights on the native block-scaled FP8 GEMM of Hopper.
    A linear layer that keeps its weight in MXFP8 form (in a backend-specific layout) and receives it from the checkpoint after construction.
    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.
    NVFP4 weight-only linear for Blackwell (sm_100+).
    Thread-local override for smile.chat.quantization during model load.
    Detected checkpoint quantization format.
    Detects HuggingFace quantization format from config.json.
    Loads HuggingFace GPTQ / AWQ / FP8 / NVFP4 SafeTensors into Llama linears (shard-then-pack for TP when tpSize > 1).
    Installs native FP8 linears into a Qwen hybrid model from HuggingFace SafeTensors.
    Factory for LinearOp backends from checkpoint tensors + selected backend.
    Resolves checkpoint QuantFormat and WeightGemmBackend for load.
    Resolved quant policy for a checkpoint load.
    Shard-then-pack helpers for tensor-parallel quantized linears.
    Weight GEMM backend selected from checkpoint format and GPU capability.