diffusers
Use this skill for Hugging Face Diffusers tasks: pipeline inference, schedulers, adapters/loaders, training recipes, modular pipelines, conversion helpers, CLI checks, and repo maintenance.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- diffusers
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use this skill for Hugging Face Diffusers tasks: pipeline inference, schedulers, adapters/loaders, training recipes, modular pipelines, conversion helpers, CLI checks, and repo maintenance.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/repo-provenance.md3.1 KB
- 参考文档references/repo-routing-metadata.json517 B
- 参考文档references/troubleshooting.md4.7 KB
- 脚本scripts/check_diffusers_environment.py3.9 KB
03 SKILL.md 正文
Diffusers
Use this skill when a task involves Hugging Face Diffusers APIs, pipeline wiring, model loading, scheduler configuration, adapters, training command planning, modular pipelines, checkpoint conversion, or maintaining the Diffusers repository.
Start Here
- Check whether the user is using Diffusers as a package, editing a Diffusers checkout, or converting/training model assets.
- Verify install and optional backends with
scripts/check_diffusers_environment.pywhen imports, CUDA, CLI availability, or optional dependencies are uncertain. - Route to the narrowest sub-skill below instead of reading every reference.
- Keep model downloads, Hub pushes, training runs, and conversion jobs opt-in; many Diffusers workflows are network-, credential-, GPU-, or memory-sensitive.
- Read
references/repo-provenance.mdbefore deciding whether this skill is stale for a current Diffusers checkout. - Use
references/troubleshooting.mdfor cross-cutting install/import/backend failures before diving into workflow-specific troubleshooting.
Installation Baseline
For normal package use, install Diffusers with the backend needed for the task:
python -m pip install diffusers torch accelerate transformers safetensors
For source-checkout development, install editable package dependencies in an isolated environment:
python -m pip install -e .
python -m pip install torch accelerate transformers safetensors
Add extras only when the selected workflow needs them:
- Training recipes commonly need
accelerate,datasets,protobuf,tensorboard,Jinja2,peft, andtimm. - Quantization and accelerator paths may need
bitsandbytes,gguf,optimum-quanto,torchao,nvidia-modelopt, xFormers, ONNX Runtime, OpenVINO, or vendor-specific packages. - Flax/JAX, ONNX, TensorRT, Core ML, and other backend workflows require separate backend-specific installs.
Minimal import check:
python - <<'PY'
import diffusers
print(diffusers.__version__)
from diffusers import DiffusionPipeline, DDPMScheduler
print(DiffusionPipeline, DDPMScheduler)
PY
Route by Task
- Pipeline inference and serving: use
sub-skills/pipelines-and-inference/SKILL.mdforDiffusionPipeline.from_pretrained,AutoPipeline*, text-to-image, img2img, inpainting, ControlNet/T2I-Adapter/IP-Adapter execution context, callbacks, batching, seeds, device maps, offload, local/offline loading, and server-safe invocation. - Schedulers and sampling: use
sub-skills/schedulers/SKILL.mdfor DDIM/DDPM/Euler/DPM-Solver/FlowMatch/LCM schedulers,set_timesteps, custom timesteps/sigmas,prediction_type, Karras/AYS settings, scheduler config round-trips, and sampler troubleshooting. - Adapters and loaders: use
sub-skills/adapters-and-loaders/SKILL.mdfor LoRA/PEFT, textual inversion, IP-Adapter, T2I-Adapter, ControlNet loading, single-file checkpoints, adapter fusion/unloading, state-dict validation, and local-file loading plans. - Training recipes: use
sub-skills/training-recipes/SKILL.mdfor DreamBooth, LoRA, textual inversion, text-to-image, ControlNet, T2I-Adapter, InstructPix2Pix, SDXL, SD3, Flux, dataset layout checks, andaccelerate launchplanning. - Modular pipelines: use
sub-skills/modular-pipelines/SKILL.mdforModularPipeline, pipeline blocks, states, component managers, sequential/loop blocks, custom block packaging, and modular-pipeline tests. - Conversion, CLI, and maintenance: use
sub-skills/conversion-and-maintenance/SKILL.mdfordiffusers-cli, environment reports, safe conversion planning, ONNX/export notes, copied-code maintenance, dummy dependency checks, style, and focused repo tests.
Boundary Rules
- Do not start training, conversion, Hub upload, benchmark, or long inference jobs without explicit user confirmation.
- Do not assume a GPU-specific package is installed just because the host has GPUs; run the environment checker and inspect
torch.cuda.is_available(). - Do not rely on original Diffusers repo docs, examples, or scripts when using this skill as a standalone runtime skill. The sub-skills include distilled references and safe helpers.
- When the user is editing a Diffusers checkout, follow the repo's copied-code policy: do not edit
# Copied from ...blocks directly unless intentionally breaking the copy link; run copy/style checks before PR handoff. - Keep pipeline execution guidance separate from training and conversion guidance. Loading an adapter for inference belongs to adapters/loaders plus pipelines; training that adapter belongs to training recipes.
- Treat original repo tests and examples as native verification candidates for a checkout, not as runtime dependencies for this skill.
High-Value Helpers
scripts/check_diffusers_environment.py: verifies Diffusers import, distribution metadata, optional packages, torch/CUDA status, anddiffusers-clihelp/env availability.sub-skills/pipelines-and-inference/scripts/pipeline_invocation_template.py: prints safe no-download pipeline invocation skeletons.sub-skills/schedulers/scripts/scheduler_smoke.py: checks common scheduler construction and tiny deterministic behavior.sub-skills/adapters-and-loaders/scripts/adapter_state_check.py: validates local adapter/checkpoint paths and optional dependency availability.sub-skills/training-recipes/scripts/training_command_builder.py: builds safe training argument plans for user-provided entrypoints.sub-skills/modular-pipelines/scripts/modular_block_skeleton.py: generates a minimal custom block skeleton.sub-skills/conversion-and-maintenance/scripts/conversion_command_builder.py: builds safe conversion argument plans for user-provided entrypoints.
Common Decision Points
- Package use vs repo maintenance: package use usually routes to pipelines, schedulers, adapters, training, or modular pipelines. Editing source, dependency tables, copied code, or CLI modules routes to conversion/maintenance.
- Local/offline vs Hub access: prefer
local_files_only=True, local config paths, and safetensors for offline or untrusted-file work. Ask before using gated models or private tokens. - CPU vs CUDA: CPU is suitable for import checks and skeleton planning. Real generation/training/conversion may need CUDA, bf16/fp16, offload, or smaller fixtures.
- Adapters vs full model changes: LoRA/textual inversion/IP-Adapter/T2I-Adapter loading is usually reversible and belongs to adapters/loaders; merging or extracting weights belongs to conversion/maintenance; training new adapters belongs to training recipes.
- Classic vs modular pipelines: use classic pipelines for most user generation tasks; use modular pipelines when the user needs block/state/component customization or custom block packaging.
Verification Expectations
For generated code or guidance, prefer the smallest safe check first:
- Import and CLI help checks for environment issues.
- Parser/help or dry-run checks for skill-owned helper scripts.
- Tiny local fixtures for dataset or adapter path validation.
- Focused native pytest selections only when working in a Diffusers checkout and the commands are short, deterministic, and safe.
- Skip and document checks that require network, credentials, real model weights, long training, destructive writes, or unavailable hardware.
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).