nunchaku
Route and operate the Nunchaku repo skill for CUDA-accelerated 4-bit Diffusers image-generation workflows, quantized transformers, LoRA/adapters, and performance controls.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- nunchaku
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Route and operate the Nunchaku repo skill for CUDA-accelerated 4-bit Diffusers image-generation workflows, quantized transformers, LoRA/adapters, and performance controls.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/api-and-entrypoints.md6.2 KB
- 参考文档references/installation-build-runtime.md5.5 KB
- 参考文档references/repo-provenance.md3.9 KB
- 参考文档references/repo-routing-metadata.json432 B
- 参考文档references/troubleshooting.md5.5 KB
- 脚本scripts/inspect_nunchaku_install.py10.4 KB
03 SKILL.md 正文
nunchaku
Use this repo skill when a task involves the nunchaku Python package: loading Nunchaku quantized .safetensors/.sft assets, replacing Diffusers transformer/UNet components, choosing INT4 vs FP4 assets, debugging CUDA/build/runtime issues, composing FLUX LoRAs, or adapting Nunchaku examples/tests into bounded user workflows.
Do not use this skill for generic Diffusers work that does not use Nunchaku, CPU-only image generation, unsupported GPU architectures, training new models, or Qwen custom LoRA workflows. Qwen custom LoRA support is documented as under development.
First steps
- If Nunchaku is not installed, prefer a prebuilt wheel that matches the user's Python, PyTorch, CUDA, OS, and GPU architecture; use
references/installation-build-runtime.mdfor source builds and compatibility repairs. - Check installation and backend with
scripts/inspect_nunchaku_install.py --device cuda:0 --prettyor theperformance-and-memorychecker before promising CUDA-specific behavior. - Identify the model family and route to the smallest matching sub-skill.
- Require explicit model assets or Hugging Face IDs from the task. Do not assume source-checkout example defaults are available.
- Treat repo-native tests/examples as verification candidates unless they have been run in the current task.
- If model downloads or private gated assets are required, ask for credentials/cache policy or use local paths.
Route by task
| User task | Load |
|---|---|
| FLUX.1-dev/schnell/krea, FLUX Kontext, FLUX tools, FLUX v2 transformer replacement | sub-skills/flux-pipelines/SKILL.md |
| Qwen-Image, Qwen-Image-Edit, Qwen Lightning, Qwen 2509, Qwen ControlNet/offload | sub-skills/qwen-image-workflows/SKILL.md |
| Sana, Sana PAG, Z-Image, SDXL, SDXL-Turbo | sub-skills/sana-zimage-sdxl/SKILL.md |
| Cache, offload, FP16 attention, quantized T5 encoder, CUDA architecture/precision checks, speed/memory planning | sub-skills/performance-and-memory/SKILL.md |
| FLUX LoRA loading/composition/conversion, safetensor merge, IP-Adapter, PuLID | sub-skills/lora-and-adapters/SKILL.md |
Core package facts
- Public root exports include
NunchakuFluxTransformer2dModel,NunchakuFluxTransformer2DModelV2,NunchakuQwenImageTransformer2DModel,NunchakuSanaTransformer2DModel,NunchakuZImageTransformer2DModel, andNunchakuT5EncoderModel. - Important non-root helpers live under package modules:
nunchaku.caching.diffusers_adapters.apply_cache_on_pipe,nunchaku.models.ip_adapter.diffusers_adapters.apply_IPA_on_pipe,nunchaku.lora.flux.compose.compose_lora,nunchaku.lora.flux.nunchaku_converter.to_nunchaku, andnunchaku.merge_safetensors.merge_safetensors. - Nunchaku quantized inference is a CUDA-backed workflow. CPU-only is not a full substitute for selected package capabilities.
- Precision is architecture-sensitive: current guidance is INT4 for Turing/Ampere/Ada and FP4 for Blackwell-class GPUs. Use
nunchaku.utils.get_precision()when possible. - Build/source installs require compatible Python, PyTorch, CUDA, compiler, and initialized submodules; prefer a prebuilt wheel when the task is only runtime usage.
Root references and scripts
references/repo-provenance.md— source commit, package version, evidence paths, and staleness signals.references/repo-routing-metadata.json— structured router metadata for managed repo-skill import tooling.references/api-and-entrypoints.md— public API, helper functions, CLI/module entry points, and native candidate map.references/installation-build-runtime.md— supported Python/CUDA/GPU/PyTorch combinations and source-build troubleshooting.references/troubleshooting.md— cross-cutting install/import, asset, backend, and workflow failure diagnoses.scripts/inspect_nunchaku_install.py— safe JSON probe for the current Python environment.
Safety and verification boundaries
- Do not copy local checkout paths, private environment names, or construction logs into user code.
- Do not run long image generation, benchmark, or model-download workflows unless the user authorizes time, storage, credentials, and output handling.
- Native verification candidates from
tests/andexamples/should be selected narrowly and run only after task-specific setup is clear. - IP-Adapter support is documented as deprecated in March 2026; surface this before recommending new long-lived IP-Adapter integrations.
04 同仓库更多 Skills
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.
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.
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.
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.
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.
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).