计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
quantization-integrations【效率与协作】Choose and validate Transformers quantization methods, backend integrations, device placement, PEFT/Accelerate/DeepSpeed/FSDP/kernel interactions, and no-download config smoke checks.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the task is to reduce model memory, load or create quantized checkpoints, choose a quantization backend, combine quantization with PEFT/training/serving, or diagnose backend-specific optional dependency and device placement failures.
Transformers inspected version: 5.13.0.dev0. Import package: transformers. A minimal environment can import base Transformers, but most quantization workflows require torch plus backend packages such as accelerate, bitsandbytes, gptqmodel, autoawq, torchao, peft, deepspeed, or hardware-specific kernels.
BitsAndBytesConfig, GPTQConfig, AwqConfig, TorchAoConfig, GGUF/GGML loading, compressed-tensors, Quanto, HQQ, AQLM, EETQ, FP8, Quark, VPTQ, SpQR, SINQ, Metal, or other quantization_config methods.AutoModelForCausalLM.from_pretrained(..., quantization_config=..., device_map=..., dtype="auto") without downloading models during planning.device_map, CPU/disk offload, DeepSpeed, FSDP, tensor parallelism, or custom kernels.torch.compile.pipeline(...) kwargs, and pipeline output behavior: inference-pipelines.GenerationConfig, streamers, and generation-only continuous batching concepts: generation.Trainer, TrainingArguments, datasets, collators, and ordinary fine-tuning loops: training.transformers CLI commands, HTTP serving, and endpoint routing: serving-cli.bitsandbytes for common 4/8-bit GPU workflows, torchao for PyTorch/compile-oriented paths, HQQ/SINQ/Quanto when their backend matches the host.dtype="auto" and device_map="auto" deliberate: they are useful for large models but can conflict with tensor parallelism, offload, or unsupported backends.scripts/quantization_config_smoke.py.from transformers import AutoModelForCausalLM, BitsAndBytesConfig
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype="bfloat16",
)
model = AutoModelForCausalLM.from_pretrained(
"org/model",
quantization_config=quantization_config,
device_map="auto",
dtype="auto",
)
Use this as a shape, not a universal default. Replace BitsAndBytesConfig when the checkpoint already declares another method, when the host is CPU-only and GGUF is the intended format, or when the backend requires calibration, specialized kernels, or a different package.
Run the bundled helper from this sub-skill directory or pass its path explicitly:
python scripts/quantization_config_smoke.py --method bitsandbytes-4bit --print-json
python scripts/quantization_config_smoke.py --method gptq --bits 4 --dataset c4
python scripts/quantization_config_smoke.py --method awq --bits 4 --fuse-max-seq-len 512
Expected success signal: OK quantization config validated plus a summary of the config class and options. Expected optional-dependency signal: MISSING optional dependency with install guidance. Expected validation failure: nonzero exit with ERROR and the invalid option.
For quantization tasks, return the selected method, required packages, required hardware/backend, exact quantization_config or loading skeleton, device_map/offload decisions, PEFT/training/serving interaction notes, smoke-check command, expected success signals, and remaining risks such as calibration time, unsupported kernels, serialization limits, or checkpoint metadata mismatch.
A base transformers import is not enough for real quantized model execution. Many config classes can be inspected or constructed without downloading a model, but model loading typically requires torch, accelerate, and the backend package. Missing dependencies commonly raise optional dependency ImportErrors at class import, config validation, or model load time.