AGENT SKILL

performance-and-memory

Use Nunchaku cache, offload, precision, attention, qencoder, CUDA sanity, and verification-planning controls for speed and memory work.

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

01 前言 Front Matter

name
performance-and-memory
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Use Nunchaku cache, offload, precision, attention, qencoder, CUDA sanity, and verification-planning controls for speed and memory work.
disable-model-invocation
true

02 资源文件 3

03 SKILL.md 正文

Nunchaku performance and memory controls

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.

Start with a safe runtime check

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.

Fast routing

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.

Architecture defaults

  • Turing / RTX 20-series / SM 75: use INT4 weights, 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.
  • Ampere / Ada / SM 80, 86, 89: use INT4 weights, normally torch.bfloat16, default FlashAttention-2 unless comparing FP16 attention, and enable offload/qencoder/cache only when the task needs memory or speed trade-offs.
  • Blackwell / RTX 50-series / SM 120 or 121: use FP4 weights, PyTorch >= 2.7, and CUDA >= 12.8; FP16 attention may be a speed candidate on 50-series.
  • Other GPU architectures or CPU-only: Nunchaku's 4-bit CUDA kernels are not a full CPU workflow; report the unsupported backend instead of inventing CPU substitutes.

Detailed references

  • 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.

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