Command Palette

Search for a command to run...

Назад к скиллам
скилл № 22583

extreme-quantization-mastery

Use when the user asks about FP8, INT4, NVFP4, MXFP4, GPTQ, AWQ, SmoothQuant, W4A16, W8A8, NF4 or bitsandbytes for LLMs on NVIDIA GPUs. Produces a…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить extreme-quantization-mastery в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Extreme Quantization (sub-16-bit LLMs)

Purpose

Shrink LLM weights, activations and KV cache to 8, 4 or fewer bits so models fit in less memory and run faster. Weight-only quantization speeds up memory-bound decoding; weight+activation quantization speeds up compute-bound prefill and large batches. Every scheme must be validated on task evals, not just perplexity.

Agent Protocol

Trigger

"quantize", "int4", "int8", "fp8", "fp4", "nvfp4", "mxfp4", "gptq", "awq", "smoothquant", "w4a16", "w8a8", "nf4", "bitsandbytes", "kv cache fp8".

Input Context

  • Model + size, target GPU generation (Ampere sm_80, Ada sm_89, Hopper sm_90, Blackwell sm_100/sm_120).
  • Serving engine (vLLM, SGLang, TensorRT-LLM, llama.cpp) and batch profile (latency vs throughput).
  • Accuracy budget and evaluation set.

Output Artifact

Quantization recipe + command/code + evaluation plan. No file unless requested.

Response Format

Scheme: {W4A16|W8A8-INT8|W8A8-FP8|NVFP4|...} group={size}
Method: {GPTQ|AWQ|SmoothQuant|RTN|dynamic FP8}
Hardware path: {kernel/tensor-core type}
Memory: {before} -> {after}
Eval: {tasks, max allowed drop}

Completion Criteria

  • Target engine + GPU support the chosen format natively (otherwise it is slower, not faster).
  • Calibration data resembles production prompts.
  • Baseline vs quantized evaluated on the same harness and seeds.
  • Sensitive layers (lm_head, embeddings, sometimes first/last blocks) excluded or kept higher precision.

Formats

Format Bits Notes
BF16/FP16 16 Baseline.
INT8 8 Per-channel weights, per-token activations. Tensor cores since Turing.
FP8 E4M3 8 4 exp / 3 mantissa, max 448. Weights + activations (forward). Tensor cores on Ada and Hopper and later.
FP8 E5M2 8 5 exp / 2 mantissa, max 57344. Wider range; used for gradients in FP8 training.
INT4 (W4A16) 4 Weight-only, group-wise scales (group size 128 typical). Dequantized in the GEMM kernel (e.g. Marlin/Machete).
MXFP4 4 OCP microscaling: E2M1 values, one E8M0 (power-of-two) scale per 32 elements.
NVFP4 4 E2M1 values, one FP8 E4M3 scale per 16 elements plus a per-tensor FP32 scale. Native on Blackwell tensor cores.
NF4 4 bitsandbytes NormalFloat for QLoRA; storage format, not a fast inference path.

Methods

  • RTN (round-to-nearest): no calibration. Fine at 8-bit, often poor at 4-bit.
  • GPTQ (Frantar et al., 2022): quantizes weights column by column and updates the remaining columns to compensate the error, using second-order information from the layer-input Hessian (H = 2XXᵀ); a Cholesky factorization of H⁻¹ makes it numerically stable and fast. Needs a few hundred calibration samples.
  • AWQ (Lin et al., 2023): observes that a small fraction of weight channels (those multiplied by large activations) matter most. Instead of keeping them in FP16 (mixed precision is hardware-unfriendly), it scales those channels up before quantization and folds the inverse scale into the preceding op, so all weights stay uniformly 4-bit.
  • SmoothQuant (Xiao et al., 2022): for W8A8, migrates activation outliers into weights with a per-channel scale s_j = max|X_j|^α / max|W_j|^(1-α) (α≈0.5), making both tensors quantizable to INT8.
  • FP8 dynamic/static: per-tensor or per-channel scales; nearly lossless for most LLMs and the default first choice on Hopper/Blackwell.
  • KV-cache FP8: halves KV memory vs BF16, raising batch size/context; validate on long-context tasks.

Decision Rules

GPU is Hopper/Blackwell and engine supports FP8? → W8A8-FP8 first (lowest risk)
Memory-bound decoding, small batch, need max compression → W4A16 (AWQ or GPTQ)
High-throughput serving, large batches on Ampere → W8A8-INT8 (SmoothQuant + GPTQ)
Blackwell, aggressive throughput → NVFP4 (validate carefully; consider QAT)
Fine-tuning on limited memory → QLoRA (NF4 base + BF16 adapters)

Weight-only 4-bit can be slower than BF16 at large batch sizes because dequantization adds work to a compute-bound GEMM.

Example: GPTQ W4A16 with llm-compressor (vLLM ecosystem)

from llmcompressor import oneshot
from llmcompressor.modifiers.quantization import GPTQModifier

recipe = GPTQModifier(targets="Linear", scheme="W4A16", ignore=["lm_head"])
oneshot(
    model="meta-llama/Llama-3.1-8B-Instruct",
    dataset="open_platypus",
    recipe=recipe,
    max_seq_length=2048,
    num_calibration_samples=512,
    output_dir="Llama-3.1-8B-Instruct-W4A16",
)
vllm serve ./Llama-3.1-8B-Instruct-W4A16          # format detected from the saved config
vllm serve meta-llama/Llama-3.1-8B-Instruct --quantization fp8 --kv-cache-dtype fp8   # dynamic FP8

Example: 4-bit loading for QLoRA (transformers + bitsandbytes)

import torch
from transformers import AutoModelForCausalLM, BitsAndBytesConfig

bnb = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dt
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл extreme-quantization-mastery?

Use when the user asks about FP8, INT4, NVFP4, MXFP4, GPTQ, AWQ, SmoothQuant, W4A16, W8A8, NF4 or bitsandbytes for LLMs on NVIDIA GPUs. Produces a quantization recipe, code and accuracy-eval plan matched to the GPU and serving engine. Not for format/GGUF basics (use llm-model-quantization) or TensorRT engines (use tensorrt-optimization).

Как установить скилл extreme-quantization-mastery?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл extreme-quantization-mastery запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить extreme-quantization-mastery с