lora-and-adapters
Operate FLUX LoRA loading, composition, conversion, safetensor merge, IP-Adapter, and PuLID workflows with Nunchaku.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- lora-and-adapters
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Operate FLUX LoRA loading, composition, conversion, safetensor merge, IP-Adapter, and PuLID workflows with Nunchaku.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/lora-adapter-workflows.md12.9 KB
- 参考文档references/troubleshooting.md7.5 KB
- 脚本scripts/compose_lora_cli.py2.2 KB
03 SKILL.md 正文
LoRA and adapters with Nunchaku
Use this sub-skill when a task involves FLUX-family LoRA loading, LoRA strength control, multi-LoRA composition, conversion to Nunchaku LoRA format, split-safetensors model merging, FLUX IP-Adapter image prompts, or FLUX PuLID identity conditioning in an installed nunchaku environment.
Do not use this sub-skill for Qwen custom LoRA loading/training. The Qwen docs describe custom LoRA support as under development; route Qwen-Image base and Lightning workflows to the Qwen sub-skill instead.
Fast routing
| Need | Start here |
|---|---|
| Load one FLUX LoRA and tune its global strength | references/lora-adapter-workflows.md#single-flux-lora |
| Combine several FLUX LoRAs with independent strengths | references/lora-adapter-workflows.md#multiple-flux-loras |
| Pre-compose LoRAs from a shell command | scripts/compose_lora_cli.py and references/lora-adapter-workflows.md#compose-cli |
| Convert a Diffusers-format FLUX LoRA to Nunchaku format | references/lora-adapter-workflows.md#conversion-to-nunchaku-format |
| Merge split quantized model safetensors | references/lora-adapter-workflows.md#merge-safetensors-utility |
| Add IP-Adapter image prompt conditioning | references/lora-adapter-workflows.md#ip-adapter-image-prompts |
| Add PuLID identity conditioning | references/lora-adapter-workflows.md#pulid-identity-conditioning |
| Diagnose format, strength, asset, or adapter failures | references/troubleshooting.md |
Core operating pattern
- Build the FLUX pipeline with
NunchakuFluxTransformer2dModel.from_pretrained(...)and a compatible Diffusers FLUX pipeline class. - For a single LoRA, call
transformer.update_lora_params(lora_path_or_state_dict)and thentransformer.set_lora_strength(strength). - For multiple LoRAs, call
compose_lora([(path_or_state_dict, strength), ...]), then pass the returned dict or saved composed safetensors toupdate_lora_params. Do not rely onset_lora_strengthfor per-LoRA control after composition. - Use
python -m nunchaku.lora.flux.composeor the bundledscripts/compose_lora_cli.pyto save a reusable composed Diffusers-format LoRA. Usepython -m nunchaku.lora.flux.convertorto_nunchaku(...)only when you intentionally want Nunchaku-format LoRA weights tied to a quantized base checkpoint. - Treat Nunchaku-format LoRAs as terminal artifacts: do not compose them with other LoRAs, and remember that composition strengths are baked into the composed weights.
- For IP-Adapter, initialize the pipeline, call Diffusers
load_ip_adapter(...), then callapply_IPA_on_pipe(...); pass an RGBip_adapter_imageduring generation. IP-Adapter support is documented as deprecated in March 2026. - For PuLID, instantiate
PuLIDFluxPipeline, then bindpulid_forwardontopipeline.transformer.forwardwithMethodTypebefore generation; pass an identity reference image asid_imageand tuneid_weight.
Minimal snippets
Single LoRA:
import torch
from diffusers import FluxPipeline
from nunchaku import NunchakuFluxTransformer2dModel
from nunchaku.utils import get_precision
precision = get_precision()
transformer = NunchakuFluxTransformer2dModel.from_pretrained(
f"nunchaku-tech/nunchaku-flux.1-dev/svdq-{precision}_r32-flux.1-dev.safetensors"
)
pipe = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev", transformer=transformer, torch_dtype=torch.bfloat16
).to("cuda")
transformer.update_lora_params("owner/repo/my_lora.safetensors")
transformer.set_lora_strength(0.8)
image = pipe("a compact product photo of a blue ceramic teapot", num_inference_steps=25, guidance_scale=3.5).images[0]
Multiple LoRAs:
from nunchaku.lora.flux.compose import compose_lora
composed = compose_lora([
("owner/style-lora/style.safetensors", 0.7),
("owner/speed-lora/turbo.safetensors", 1.0),
])
transformer.update_lora_params(composed)
For complete adapter workflows, CLI syntax, and caveats, use references/lora-adapter-workflows.md.
Evidence base
Distilled from docs/source/usage/lora.rst, docs/source/usage/ip_adapter.rst, docs/source/usage/pulid.rst, LoRA/IP-Adapter/PuLID source modules, live public API inspection, and native test/example candidates. Native tests and examples are verification candidates for later integration; this sub-skill does not claim they were run during drafting.
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).