Skip to content
Back to skills

Performance And Memory

ASecurity

"Use Nunchaku cache, offload, precision, attention, qencoder, CUDA

  • 247 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 8, 2026
developmentpythonbashapibackendperformance

Works with

  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill performance-and-memory --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Performance And Memory?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Performance And Memory
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-performance-and-memory/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-performance-and-memory)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

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

# 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:

```bash
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.

Files in this skill

  • SKILL.md3.8 KB
  • references/performance-controls.md9.8 KB
  • references/troubleshooting.md8.4 KB
  • scripts/check_nunchaku_cuda.py10.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.