Close Menu
techwavedispatch.com

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    AirDoctor Coupon Codes: 40% Off | November 2026

    November 12, 2026

    Running Privacy-Preserving Inferences on Hugging Face Endpoints

    November 12, 2026

    Hydrow Discount Code: Save Up to $150 | November 2026

    November 12, 2026
    Facebook X (Twitter) Instagram
    Trending
    • AirDoctor Coupon Codes: 40% Off | November 2026
    • Running Privacy-Preserving Inferences on Hugging Face Endpoints
    • Hydrow Discount Code: Save Up to $150 | November 2026
    • Ryght’s Journey to Empower Healthcare and Life Sciences with Expert Support from Hugging Face
    • HelloFresh Promo Codes: 55% Off for November 2026
    • Welcome Llama 3 – Meta’s new open LLM
    • Nike Promo Codes and Discounts: 30% for November 2026
    • Benchmarking Large Language Models in Healthcare
    Facebook X (Twitter) Instagram
    techwavedispatch.com
    Subscribe
    Thursday, November 12
    • Home
    • AI Tools & Software
    • Machine Learning
    • Generative AI
    • Robotics & Automation
    • Future Tech & Hardware
    • AI in Business
    • Ethics & Regulations
    • More
      • Gadgets & Smart Devices
      • Cybersecurity & AI
      • Tech Breakthroughs
    techwavedispatch.com
    Home»AI Tools & Software»Introducing Modular Diffusers – Composable Building Blocks for Diffusion Pipelines
    AI Tools & Software

    Introducing Modular Diffusers – Composable Building Blocks for Diffusion Pipelines

    adminBy adminNovember 8, 2026No Comments7 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Introducing Modular Diffusers – Composable Building Blocks for Diffusion Pipelines
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Modular Diffusers introduces a new way to build diffusion pipelines by composing reusable blocks. Instead of writing entire pipelines from scratch, you can mix and match blocks to create workflows tailored to your needs! This complements the existing DiffusionPipeline class with a more flexible, composable alternative.

    In this post, we’ll walk through how Modular Diffusers works — from the familiar API to run a modular pipeline, to building fully custom blocks and composing them into your own workflow. We’ll also show how it integrates with Mellon, a node-based visual workflow interface that you can use to wire Modular Diffusers blocks together.

    Table of contents



    Quickstart

    Here is a simple example of how to run inference with FLUX.2 Klein 4B using pre-built blocks:

    import torch
    from diffusers import ModularPipeline
    
    
    pipe = ModularPipeline.from_pretrained(
        "black-forest-labs/FLUX.2-klein-4B"
    )
    
    pipe.load_components(torch_dtype=torch.bfloat16)
    pipe.to("cuda")
    
    
    image = pipe(
        prompt="a serene landscape at sunset",
        num_inference_steps=4,
    ).images[0]
    
    image.save("output.png")
    

    You get the same results as with a standard DiffusionPipeline, but the pipeline is very different under the hood: it’s composed of flexible blocks — text encoding, image encoding, denoising, and decoding — that you can inspect directly:

    print(pipe.blocks)
    
    Flux2KleinAutoBlocks(
      ...
      Sub-Blocks:
        [0] text_encoder (Flux2KleinTextEncoderStep)
        [1] vae_encoder (Flux2KleinAutoVaeEncoderStep)
        [2] denoise (Flux2KleinCoreDenoiseStep)
        [3] decode (Flux2DecodeStep)
    )
    

    Each block is self-contained with its own inputs and outputs. You can run any block independently as its own pipeline, or add, remove, and swap blocks freely — they dynamically recompose to work with whatever blocks remain. Use .init_pipeline() to convert blocks into a runnable pipeline, and .load_components() to load the model weights.

    
    blocks = pipe.blocks
    
    
    text_blocks = blocks.sub_blocks.pop("text_encoder")
    
    
    text_pipe = text_blocks.init_pipeline("black-forest-labs/FLUX.2-klein-4B")
    
    
    text_pipe.load_components(torch_dtype=torch.bfloat16)
    text_pipe.to("cuda")
    prompt_embeds = text_pipe(prompt="a serene landscape at sunset").prompt_embeds
    
    
    
    remaining_pipe = blocks.init_pipeline("black-forest-labs/FLUX.2-klein-4B")
    remaining_pipe.load_components(torch_dtype=torch.bfloat16)
    remaining_pipe.to("cuda")
    image = remaining_pipe(prompt_embeds=prompt_embeds, num_inference_steps=4).images[0]
    

    For more on block types, composition patterns, lazy loading, and memory management with ComponentsManager, check out the Modular Diffusers documentation.



    Custom Blocks

    Modular Diffusers really shines when creating your own blocks. A custom block is a Python class that defines its components, inputs, outputs, and computation logic — and once defined, you can plug it into any workflow.



    Writing a Custom Block

    Here’s an example block that extracts depth maps from images using Depth Anything V2.

    class DepthProcessorBlock(ModularPipelineBlocks):
        @property
        def expected_components(self):
            return [
                ComponentSpec("depth_processor", DepthPreprocessor,
                              pretrained_model_name_or_path="depth-anything/Depth-Anything-V2-Large-hf")
            ]
    
        @property
        def inputs(self):
            return [
                InputParam("image", required=True,
                           description="Image(s) to extract depth maps from"),
            ]
    
        @property
        def intermediate_outputs(self):
            return [
                OutputParam("control_image", type_hint=torch.Tensor,
                            description="Depth map(s) of input image(s)"),
            ]
    
        @torch.no_grad()
        def __call__(self, components, state):
            block_state = self.get_block_state(state)
            depth_map = components.depth_processor(block_state.image)
            block_state.control_image = depth_map.to(block_state.device)
            self.set_block_state(state, block_state)
            return components, state
    
    • expected_components defines what models the block needs — in this case, a depth estimation model. The pretrained_model_name_or_path parameter sets a default Hub repo to load from, so load_components automatically fetches the depth model unless you override it in modular_model_index.json.
    • inputs and intermediate_outputs define what goes in and comes out.
    • __call__ is where the computation logic lives.



    Composing Blocks into Workflows

    Let’s use this block with Qwen’s ControlNet workflow. Extract the ControlNet workflow and insert the depth block at the beginning:

    
    pipe = ModularPipeline.from_pretrained("Qwen/Qwen-Image")
    
    print(pipe.blocks.available_workflows)
    
    
    
    
    
    
    
    
    blocks = pipe.blocks.get_workflow("controlnet_text2image")
    
    print(blocks)
    
    
    
    blocks.sub_blocks.insert("depth", DepthProcessorBlock(), 0)
    
    
    blocks.sub_blocks['depth'].doc
    

    Blocks in a sequence share data automatically: the depth block’s control_image output flows to downstream blocks that need it, and its image input becomes a pipeline input since no earlier block provides it.

    blocks_composed

    from diffusers import ComponentsManager, AutoModel
    from diffusers.utils import load_image
    
    
    
    manager = ComponentsManager()
    
    pipeline = blocks.init_pipeline("Qwen/Qwen-Image", components_manager=manager)
    pipeline.load_components(torch_dtype=torch.bfloat16)
    
    
    
    
    controlnet = AutoModel.from_pretrained("InstantX/Qwen-Image-ControlNet-Union", torch_dtype=torch.bfloat16)
    pipeline.update_components(controlnet=controlnet)
    
    
    image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg")
    output = pipeline(
        prompt="an astronaut hatching from an egg, detailed, fantasy, Pixar, Disney",
        image=image,
    ).images[0]
    



    Sharing Custom Blocks on the Hub

    You can publish your custom block to the Hub so anyone can load it with trust_remote_code=True. We’ve created a template to get you started — check out the Building Custom Blocks guide for the full walkthrough.

    pipeline.save_pretrained(local_dir, repo_id="your-username/your-block-name", push_to_hub=True)
    

    The DepthProcessorBlock from this post is published at diffusers/depth-processor-custom-block — you can load and use it directly:

    from diffusers import ModularPipelineBlocks
    
    depth_block = ModularPipelineBlocks.from_pretrained(
        "diffusers/depth-processor-custom-block", trust_remote_code=True
    )
    

    We’ve published a collection of ready-to-use custom blocks here.



    Modular Repositories

    ModularPipeline.from_pretrained works with any existing Diffusers repo out of the box, but Modular Diffusers also introduces a new kind of repo: the Modular Repository.

    A modular repository is able to reference components from their original model repos. For example, diffusers/flux2-bnb-4bit-modular contains a quantized transformer and loads the remaining components from the original repo.

    
    {
        "transformer": [
            "diffusers", 
            "Flux2Transformer2DModel", 
            {
                "pretrained_model_name_or_path": "diffusers/flux2-bnb-4bit-modular",
                "subfolder": "transformer",
                "type_hint": ["diffusers", "Flux2Transformer2DModel"]
            }
        ],
        "vae": [
            "diffusers", 
            "AutoencoderKLFlux2", 
            {
                "pretrained_model_name_or_path": "black-forest-labs/FLUX.2-dev",
                "subfolder": "vae",
                "type_hint": ["diffusers", "AutoencoderKLFlux2"]
            }
        ],
        ...
    }
    

    Modular repositories can also host custom pipeline blocks as Python code and visual UI configurations for tools like Mellon — all in one place.


    Community Pipelines

    The community has already started building complete pipelines with Modular Diffusers and publishing them on the Hub, with model weights and ready-to-run code.

    • Krea Realtime Video — A 14B parameter real-time video generation model distilled from Wan 2.1, achieving 11fps on a single B200 GPU. It supports text-to-video, video-to-video, and streaming video-to-video — all built as modular blocks. Users can modify prompts mid-generation, restyle videos on-the-fly, and see first frames within 1 second.
    import torch
    from diffusers import ModularPipeline
    
    pipe = ModularPipeline.from_pretrained("krea/krea-realtime-video", trust_remote_code=True)
    pipe.load_components(
        trust_remote_code=True, 
        device_map="cuda",
        torch_dtype={"default": torch.bfloat16, "vae": torch.float16}
    )
    
    • Waypoint-1 — A 2.3B parameter real-time diffusion world model from Overworld. It autoregressively generates interactive worlds from control inputs and text prompts — you can explore and interact with generated environments in real time on consumer hardware.

    Teams can build novel architectures, package them as blocks, and publish the entire pipeline on the Hub for anyone to use with ModularPipeline.from_pretrained.

    Check out the full collection of community pipelines for more.



    Integration with Mellon

    💡 Mellon is in early development and not ready for production use yet. Consider this a sneak peek of how the integration works!

    Mellon is a node graph interface integrated with Modular Diffusers. If you’re familiar with node-based tools like ComfyUI, you’ll feel right at home — but there are some key differences:

    • Dynamic nodes — Instead of dozens of model-specific nodes, we have a small set of nodes that automatically adapt their interface based on the model you select. Learn them once, use them with any model.
    • Single-node workflows — Thanks to Modular Diffusers’ composable block system, you can collapse an entire pipeline into a single node. Run multiple workflows on the same canvas without the clutter.
    • Hub integration out of the box — Custom blocks published to the Hugging Face Hub work instantly in Mellon. We provide a utility function to automatically generate the node interface from your block definition — no UI code required.

    This integration is possible because every block exposes the same properties (inputs, intermediate_outputs, expected_components). This consistent API means Mellon can automatically generate a node’s UI from any block definition and compose blocks into higher-level nodes.

    For example, diffusers/FLUX.2-klein-4B-modular contains a pipeline definition, component references, and a mellon_pipeline_config.json — all in one repo. Load it in Python with ModularPipeline.from_pretrained("diffusers/FLUX.2-klein-4B-modular") or in Mellon to create either a single-node or multi-node workflow.

    Here’s a quick example. We add a Gemini prompt expansion node — hosted as a modular repo at diffusers/gemini-prompt-expander-mellon — to an existing text-to-image workflow:

    1. Drag in a Dynamic Block node and enter the repo_id (i.e. diffusers/gemini-prompt-expander-mellon)
    2. Click LOAD CUSTOM BLOCK — the node automatically grows a textbox for your prompt input and an output socket named “prompt”, all configured from the repo
    3. Type a short prompt, connect the output to the Encode Prompt node, and run

    Gemini expands your short prompt into a detailed description before generating the image. No code, no configuration — just a Hub repo id.

    Your browser does not support the video tag.

    This is just one example. For a detailed walkthrough, check out the Mellon x Modular Diffusers guide. You can also check out this video!



    Conclusion

    Modular Diffusers brings the composability and flexibility the community has been asking for, without compromising the features that make Diffusers powerful. It’s still early — we want your input to shape what comes next. Give it a try and tell us what works, what doesn’t, and what’s missing.



    Resources

    Thanks to Chun Te Lee for the thumbnail, and to Poli, Pedro, Lysandre, Linoy, Aritra, and Steven for their thoughtful reviews.

    blocks Building Composable Diffusers Diffusion Introducing Modular Pipelines
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    admin
    • Website

    Related Posts

    Running Privacy-Preserving Inferences on Hugging Face Endpoints

    November 12, 2026

    Ryght’s Journey to Empower Healthcare and Life Sciences with Expert Support from Hugging Face

    November 12, 2026

    Welcome Llama 3 – Meta’s new open LLM

    November 12, 2026
    Leave A Reply Cancel Reply

    Top Posts

    NVIDIA Is Investigating Reports That CEO Jensen Huang Was The Target Of Chinese Spy Efforts

    November 8, 202619 Views

    Anthropic releases new Mythos and Fable models amid RSI concerns

    November 9, 20265 Views

    Efficient Vision-Language-Action Model trained on Lerobot Community Data

    November 10, 20264 Views

    Does a Trading Policy Need to Know What It Trades? Microstructure Invariance and Zero-Shot Transfer of Execution Policies

    November 9, 20264 Views
    Don't Miss
    Gadgets & Smart Devices

    AirDoctor Coupon Codes: 40% Off | November 2026

    By adminNovember 12, 20260

    Thanks to the COVID pandemic and seemingly never-ending wildfires, air purifiers have become an essential home appliance for overall health.…

    Running Privacy-Preserving Inferences on Hugging Face Endpoints

    November 12, 2026

    Hydrow Discount Code: Save Up to $150 | November 2026

    November 12, 2026

    Ryght’s Journey to Empower Healthcare and Life Sciences with Expert Support from Hugging Face

    November 12, 2026
    About Us

    Welcome to TechWave Dispatch

    At TechWave Dispatch, we bring you the latest news, insights, and developments from the ever-evolving world of technology. Our mission is to keep readers informed about the innovations shaping our digital future.

    From artificial intelligence and machine learning to cybersecurity, robotics, smart devices, and groundbreaking technologies, we cover the topics that matter in today's fast-moving tech landscape.

    Our Picks

    AirDoctor Coupon Codes: 40% Off | November 2026

    November 12, 2026

    Running Privacy-Preserving Inferences on Hugging Face Endpoints

    November 12, 2026

    Hydrow Discount Code: Save Up to $150 | November 2026

    November 12, 2026
    Most Popular

    Who Controls Scientific Discovery? – O’Reilly

    November 6, 20260 Views

    After blocking Muse, Amazon now lets users text Alexa to help them shop

    November 6, 20260 Views

    A controlled world for robot learning and evaluation

    November 6, 20260 Views
    Facebook X (Twitter) Instagram Pinterest
    • Terms and Conditions
    • Privacy Policy
    • Contact Us
    • About Us
    © 2026 TechWave Dispatch. All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.