协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
performance-and-memory【开发与工程】Use Nunchaku cache, offload, precision, attention, qencoder, CUDA sanity, and verification-planning controls for speed and memory work.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when a task asks how to reduce VRAM, select quantized precision, enable cache acceleration, choose attention/offload settings, check CUDA compatibility, or plan bounded speed/memory verification for an installed Nunchaku runtime.
Do not use this sub-skill for full image-generation task templates. Route family-specific pipelines to the model-family sub-skills and use this one only for composable performance fragments.
Run the bundled checker in the user's current Python environment before recommending architecture-specific settings:
python scripts/check_nunchaku_cuda.py --device cuda:0 --pretty
The checker imports only torch, nunchaku, and lightweight API modules, allocates at most a scalar CUDA tensor unless --skip-allocation is set, and never downloads model assets.
| User need | Use |
|---|---|
| Pick INT4 vs FP4 weights | nunchaku.utils.get_precision(device="cuda:0"); Blackwell SM 120/121 uses FP4, Turing/Ampere/Ada SM 75/80/86/89 use INT4. |
| Reduce FLUX VRAM | Load NunchakuFluxTransformer2dModel.from_pretrained(..., offload=True) and pair it with Diffusers pipeline.enable_sequential_cpu_offload(); avoid manual .to("cuda") in this mode. |
| Reduce Qwen-Image VRAM | Use Diffusers CPU offload when VRAM is sufficient; for very low VRAM, use NunchakuQwenImageTransformer2DModel.set_offload(True, ...) and exclude the transformer from Diffusers CPU offload. |
| Speed up long FLUX denoising | Apply First-Block Cache with apply_cache_on_pipe(pipe, residual_diff_threshold=0.12) or double FB cache thresholds. |
| Use Cache-DiT | Install cache-dit, then call cache_dit.enable_cache(pipe, cache_config=DBCacheConfig(...)); treat as optional dependency. |
| Try FP16 attention | On FLUX transformers, call transformer.set_attention_impl("nunchaku-fp16"); switch back with "flashattn2". Turing needs FP16 attention. |
| Reduce T5 memory | Replace FLUX T5 with NunchakuT5EncoderModel.from_pretrained(...) and pass it as text_encoder_2; CUDA only and not currently for Turing. |
| Plan evidence-backed checks | Read references/performance-controls.md#verification-planning and treat native tests/examples as candidates, not pre-run evidence. |
torch.float16 for transformer and pipeline, transformer.set_attention_impl("nunchaku-fp16"), and offload if VRAM is tight. Do not select the quantized T5 encoder as a default because the docs state Turing support is pending.torch.bfloat16, default FlashAttention-2 unless comparing FP16 attention, and enable offload/qencoder/cache only when the task needs memory or speed trade-offs.references/performance-controls.md — API fragments, thresholds, offload combinations, precision/device choices, and verification candidates.references/troubleshooting.md — CUDA/build mismatch, architecture, qencoder, cache/offload, and device-placement failure modes.scripts/check_nunchaku_cuda.py — safe JSON probe for installed runtime capabilities.