AGENT SKILL

transformers-integrations

Use bitsandbytes through Hugging Face Transformers, Diffusers, PEFT, and Accelerate for LLM.int8 inference, 4-bit/NF4 loading, QLoRA preparation, and FSDP-QLoRA planning.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
transformers-integrations
license
MIT
metadata
{ "disco-role": "operating" }
description
Use bitsandbytes through Hugging Face Transformers, Diffusers, PEFT, and Accelerate for LLM.int8 inference, 4-bit/NF4 loading, QLoRA preparation, and FSDP-QLoRA planning.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

Transformers Integrations

Use this sub-skill when the task is about loading or preparing models through Hugging Face ecosystem APIs with bitsandbytes quantization. The key API is usually transformers.BitsAndBytesConfig; it is provided by Transformers, not by the bitsandbytes Python package.

Route Here

  • Build BitsAndBytesConfig for load_in_8bit, load_in_4bit, NF4, double quantization, compute dtype, or quantized storage dtype.
  • Load a model with AutoModelForCausalLM.from_pretrained(..., quantization_config=..., device_map=...).
  • Prepare QLoRA with PEFT using prepare_model_for_kbit_training, LoraConfig, and get_peft_model.
  • Plan FSDP-QLoRA, especially bnb_4bit_quant_storage and dtype alignment.
  • Explain Diffusers, Accelerate, or Transformers integration decisions without direct layer replacement.
  • Validate a quantization config in CI without downloading model weights.

Route Elsewhere

  • For install, import, missing native library, backend visibility, python -m bitsandbytes, or CUDA/XPU/HPU/MPS/CPU diagnostics, use installation-diagnostics.
  • For direct bitsandbytes.nn.Linear8bitLt, Linear4bit, Params4bit, QuantState, or low-level functional APIs, use quantized-modules-functions.
  • For standalone 8-bit or paged optimizer training loops, Trainer(optim=...), or bitsandbytes.optim, use optimizers-training.

Start Points

  • Read references/integration-workflows.md for 8-bit inference, 4-bit/NF4 loading, QLoRA, Diffusers/Accelerate notes, validation, and model-download safety.
  • Read references/fsdp-qlora.md for FSDP-QLoRA dtype, storage, sharding, and state-dict caveats.
  • Read references/troubleshooting.md when integrations fail at import, model loading, device mapping, dtype, offload, or distributed save time.
  • Run scripts/transformers-bnb-config-check.py --mode qlora to validate optional dependency imports and print no-download config snippets.

Working Rules

  • Separate config construction from execution: BitsAndBytesConfig can often be constructed on CPU-only CI, but actual quantized model loading may require a compatible accelerator, memory plan, model access, and network/cache availability.
  • Prefer quantization_config=BitsAndBytesConfig(...) over legacy direct load_in_8bit=True or load_in_4bit=True arguments to from_pretrained.
  • Treat model IDs, tokens, gated repositories, and remote code as deployment inputs; never assume downloads are allowed.
  • Keep backend failures routed to installation diagnostics before changing model-loading code.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351