custom-blocks
Skill35k starsChanged 3 months agoApache-2.0View on GitHub
Use when the user has written (or wants to write) a `ModularPipelineBlocks` subclass in a local Python file and needs to package it into a Hub-uploadable directory. Covers the workflow from a single `block.py` file to a published custom-block repo that consumers can load via `ModularPipeline.from_pretrained(<repo>, trust_remote_code=True)`.
- Installs packages
Trending
Quiet since September.about the whole repository
Who's talking about huggingface/diffusers
- A Hacker News story“Diffusers: Modular Diffusion model library from HuggingFace”Hacker News · Jul 21, 2022 · 47 points
- XavierXiao/Dreambooth-Stable-Diffusion“DreamBooth Stable Diffusion training now possible in 10 GB VRAM, and it runs about 2 times faster.”GitHub · Sep 26, 2022 · 42 reactions
- Comfy-Org/ComfyUI“[Feature] Support for SD3 ControlNet”GitHub · Jun 15, 2024 · 28 reactions
- AUTOMATIC1111/stable-diffusion-webui“[Feature Request]: Add newest DPM-Solver++”GitHub · Nov 4, 2022 · 25 reactions
- microsoft/vscode-remote-release“Remote Extension host terminated unexpectedly 3 times within the last 5 minutes.”GitHub · Mar 22, 2025 · 17 reactions
The biggest 5 of 38 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 38
Talked about on GitHub, Hacker News and Bluesky (38 times).
On GitHub · 31
- Sep 26, 2022DreamBooth Stable Diffusion training now possible in 10 GB VRAM, and it runs about 2 times faster. — XavierXiao/Dreambooth-Stable-Diffusion42 reactions · 52 comments
- Jun 15, 2024[Feature] Support for SD3 ControlNet — Comfy-Org/ComfyUI28 reactions · 10 comments
- Nov 4, 2022[Feature Request]: Add newest DPM-Solver++ — AUTOMATIC1111/stable-diffusion-webui25 reactions · 3 comments
- Mar 22, 2025Remote Extension host terminated unexpectedly 3 times within the last 5 minutes. — microsoft/vscode-remote-release17 reactions · 33 comments
- Oct 23, 2022Suggestion: Stable Diffusion Model — ggml-org/ggml13 reactions · 6 comments
26 more on GitHub
- Feb 3, 2026[Feat]: Anima support — Nerogar/OneTrainer12 reactions · 11 comments
- Dec 19, 2025feat: add qwen image layered support — leejet/stable-diffusion.cpp12 reactions · 4 comments
- Sep 9, 2025[RFC] [1.0] 🚀 huggingface_hub 1.0 release checklist — huggingface/huggingface_hub12 reactions · 1 comment
- Sep 28, 2022Support loading models created with diffusers — AUTOMATIC1111/stable-diffusion-webui12 reactions · 6 comments
- Mar 21, 2025🎉Glad to announce SANA-Sprint is available! — NVlabs/Sana10 reactions · 9 comments
- Jan 4, 2026[GLM-Image] AR Model Support for GLM-Image — huggingface/transformers9 reactions · 5 comments
- Dec 21, 2025[WIP] z-image-omni-base support — leejet/stable-diffusion.cpp9 reactions · 2 comments
- Jun 2, 2026feat: Add Anima support — ostris/ai-toolkit7 reactions · 5 comments
- Sep 18, 2026feat: add Qwen Image 2.1 support — leejet/stable-diffusion.cpp6 reactions · 1 comment
- Jan 16, 2026Flux2 Dev+Klein support — Nerogar/OneTrainer6 reactions · 24 comments
- Dec 15, 2025feat: add support for qwen image edit 2511 — leejet/stable-diffusion.cpp6 reactions · 2 comments
- Jun 9, 2026feat(policies): add Cosmos3 drafts — huggingface/lerobot5 reactions
- Dec 31, 2025Increase text length from 256 to 1024 in Qwen-Image — sgl-project/sglang5 reactions · 2 comments
- May 12, 2023[Unity][FX] Add support for PT2.0 scaled_dot_product_attention — apache/tvm5 reactions · 9 comments
- Sep 18, 2026[New model] Qwen-image-2.1 support — vllm-project/vllm-omni4 reactions · 13 comments
- Jun 4, 2024Serialization: support saving torch state dict to disk — huggingface/huggingface_hub4 reactions · 2 comments
- Mar 28, 2024Create pipeline_stable_diffusion_xl_instantid_img2img.py — instantX-research/InstantID4 reactions · 2 comments
- Aug 3, 2026Add MiniMax-H3 BF16 training and inference support — kohya-ss/musubi-tuner3 reactions · 26 comments
- Jan 12, 2026Support Z-image-omni-base — kohya-ss/musubi-tuner3 reactions · 7 comments
- Sep 10, 2024Add `TextToImage`, `StableDiffusion3Backbone` and `StableDiffusion3TextToImage` — keras-team/keras-hub3 reactions · 2 comments
- Apr 25, 2024Added Reward Backpropogation Support — huggingface/trl3 reactions · 12 comments
- Mar 31, 2024Add option to use Scheduled Huber Loss in all training pipelines to improve resilience to data corruption — kohya-ss/sd-scripts3 reactions · 29 comments
- Dec 6, 2023Feature/EulerScheduler — finegrain-ai/refiners3 reactions · 6 comments
- Oct 26, 2023Enable Latent Consistency models OpenVINO export and inference — huggingface/optimum-intel3 reactions · 1 comment
- Aug 19, 2022[Safety Checker] Add Safety Checker Module — CompVis/stable-diffusion3 reactions · 7 comments
- May 20, 2026Bump diffusers from 0.6.0 to 0.38.0 in the pip group across 1 directory — LaloLalo1999/UnstableFusion2 reactions
On Hacker News · 6
- Jul 21, 2022Diffusers: Modular Diffusion model library from HuggingFace47 points · 5 comments
- Apr 12, 2023V0.15.0 Beyond Image Generation7 points · 1 comment
- Aug 22, 2022Stable Diffusion Public Release6 points · 2 comments
- Aug 16, 2022HuggingFace Diffusers 0.2 with Stable Diffusion pipeline2 points · 1 comment
- Dec 7, 2023StableDiffusionSafetyChecker1 point
1 more on Hacker News
- Nov 3, 2022Diffusers 0.7.0: Stable Diffusion up to 2x faster on any hardware (including M1)says it tested it1 point · 1 comment
On Bluesky · 1
- Oct 25, 2024📦 huggingface / diffusers ⭐ 25,737 (+39) 🗒 Python 🤗 Diffusers: State-of-the-art diffusion models for image and audio generation in… — @github-trending.bsky.social7 likes and reposts
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .ai/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- diffusers-cliSkill
- model-integrationSkill
- self-reviewSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Use this skill when:
- Very specific: line 26
Don't use this skill for: running an existing modular pipeline (diffusers-cli run), introspecting one (diffusers-cli schema), or writing …
- Very specific: line 149
If diffusers-cli isn't on PATH after pip install -e ., reinstall with pip install -e .
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
What this skill is for
A ModularPipelineBlocks subclass is a unit of pipeline logic — input/output spec plus a __call__ — that
slots into diffusers' modular pipeline composition. Once you have one defined locally, you almost always want to
publish it as a small Hub repo so others can from_pretrained it. diffusers-cli custom_blocks automates the
packaging step: it parses your Python file, instantiates the chosen block class, and writes a
save_pretrained-style directory in your cwd that's ready to push to the Hub.
Use this skill when:
- The user is writing a custom modular block and asks "how do I publish this?" or "package this for the Hub".
- The user has a
block.py(or similar) file with one or moreModularPipelineBlockssubclasses. - You're scaffolding a new modular pipeline repo and need the on-disk layout that
ModularPipelineBlocks.from_pretrainedexpects.
Don't use this skill for: running an existing modular pipeline (diffusers-cli run), introspecting one
(diffusers-cli schema), or writing the block class itself — this skill packages an already-written block.
The end-to-end workflow
[you: write block.py] → diffusers-cli custom_blocks → [packaged dir in cwd]
↓
hf upload <repo> .
↓
consumers: ModularPipeline.from_pretrained(<repo>, trust_remote_code=True)
diffusers-cli schema --model <repo> --trust-remote-code
diffusers-cli run --model <repo> --trust-remote-code ...The skill covers the middle box. The bookends (writing the block and uploading) are out of scope.
Command surface
diffusers-cli custom_blocks [--block_module_name <file.py>] [--block_class_name <ClassName>]Flags
--block_module_name <file>— Python file containing the block class. Defaults toblock.pyin the cwd.--block_class_name <name>— Which class in the file to package. Optional: if omitted, the CLI parses the file withast, finds every class that inherits fromModularPipelineBlocks, and uses the first one (with an info log naming the others). Specify explicitly when the file defines more than one block and you want a specific one.
What it does
- AST scan: parses
<file>without executing it, walks top-levelClassDefnodes, and collects every class whosebasesincludeModularPipelineBlocks. - Pick a class: uses
--block_class_nameif given, else the first found. Errors with the list of available classes if your name doesn't match. - Load and save: imports the file via
importlib.util.spec_from_file_location(this does execute the module — make sure your block.py is something you trust to run), instantiates the chosen class with no constructor args, and calls.save_pretrained(os.getcwd()).
The result is a Hub-uploadable directory laid out the way ModularPipelineBlocks.from_pretrained expects:
your block source, an auto_map in the config so consumers know to load it with trust_remote_code=True,
and any artifacts save_pretrained writes for that block class.
End-to-end example
Given a block.py like:
from diffusers.modular_pipelines import ModularPipelineBlocks, InputParam, OutputParam
class MyDenoiseBlock(ModularPipelineBlocks):
model_name = "my-denoise"
@property
def inputs(self):
return [
InputParam("latents", type_hint="torch.Tensor", required=True, description="Noisy latents."),
InputParam("guidance_scale", type_hint="float", default=7.5),
]
@property
def intermediate_outputs(self):
return [OutputParam("latents", type_hint="torch.Tensor")]
def __call__(self, components, state):
# ... denoising logic ...
return components, statePackage it:
diffusers-cli custom_blocks --block_module_name block.pyOutput in cwd:
./
├── block.py
├── modular_config.json # contains auto_map → MyDenoiseBlock
└── (any state files MyDenoiseBlock.save_pretrained writes)Upload to the Hub:
hf upload my-user/my-denoise-block .Consumers can now use it:
from diffusers import ModularPipeline
pipe = ModularPipeline.from_pretrained("my-user/my-denoise-block", trust_remote_code=True)Or via CLI:
diffusers-cli schema --model my-user/my-denoise-block --trust-remote-code
diffusers-cli run --model my-user/my-denoise-block --trust-remote-code \
--pipeline-kwargs '{"latents": "...", "guidance_scale": 7.5}'Common errors
Could not parse '<file>': SyntaxError— the file isn't valid Python. Fix the syntax; the AST step runs before any execution.block_class_name could not be retrieved. Available classes from <file>: [ClassA, ClassB]— your--block_class_namedoesn't match anyModularPipelineBlockssubclass found. Pick from the list shown.- No classes found: silent — the command will try to use the first entry in an empty list and raise
IndexError. If you hit that, double-check your class actually inherits fromModularPipelineBlocks(the AST scan looks for that literal base-class name; aliased imports likefrom diffusers import ... as MPBwon't be picked up). - Block requires constructor args: the command calls
<ClassName>()with no args. If your block needs__init__parameters, refactor to take them fromstate/componentsat__call__time instead, or hardcode defaults in__init__.
Verifying the install
If diffusers-cli isn't on PATH after pip install -e ., reinstall with
pip install -e . --force-reinstall --no-deps and check which diffusers-cli. If the binary is missing recent
features (e.g. unrecognized arguments: --lora), reinstall. See the
diffusers-cli skill for more.
Related
- the
diffusers-clidocs — once your block is uploaded,schemaandruncall it from the terminal without writing Python. - diffusers' modular pipelines docs — for writing the block class itself.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

