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).
    Block-scaled FP8 linear for DeepSeek / Qwen fine-grained FP8 checkpoints (weight_block_size=[128,128] + weight_scale_inv).
    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.
    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.