In a recent development, segMoE is an exciting framework for creating Mixture-of-Experts Diffusion models from scratch! SegMoE is comprehensively integrated within the Hugging Face ecosystem and comes supported with diffusers πŸ”₯!

Among the features and integrations being released today:.

According to recent reports, segMoE models follow the same architecture as Stable Diffusion. Like Mixtral 8x7b, a SegMoE model comes with multiple models in one. The way this works is by replacing some Feed-Forward layers with a sparse MoE layer. A MoE layer contains a router network to select which experts process which tokens most efficiently. You can use the segmoe package to create your own MoE models! The process takes just a few minutes. For further information, please visit the Github Repository. We take inspiration from the popular library mergekit to design segmoe. We thank the contributors of mergekit for such a useful library. (Related: Three 'e-waste' Nvidia V100s hit 100 tokens per second ...)

For more details on MoEs, see the Hugging Face πŸ€— post: hf.co/blog/moe.

The SegMoE MoEs are called SegMoE-AxB, where A refers to the number of expert models MoE-d together, while the second number refers to the number of experts involved in the generation of each image. Only some layers of the model (the feed-forward blocks, attentions, or all) are replicated depending on the configuration settings; the rest of the parameters are the same as in a Stable Diffusion model. For more details about how MoEs work, please refer to the "Mixture of Experts Explained" post. (Related: Tech Report: β€œDetermined” woman completes 7 marathons i...)

We release 3 merges on the Hub:.

Images generated using SegMoE 4x2.

Images generated using SegMoE 2x1:.

Images generated using SegMoE SD 4x2.

Recent findings suggest that please, run the following command to install the segmoe package. Make sure you have the latest version of diffusers and transformers installed.

The following loads up the second model ("SegMoE 4x2") from the list above, and runs generation on it.

Alternatively, a local model can also be loaded up, here segmoe_v0 is the path to the directory containing the local SegMoE model. Checkout Creating your Own SegMoE to learn how to build your own!

In a recent development, prompt understanding seems to improve, as shown in the images below. Each image highlights the following models left to right: SegMoE-2x1-v0, SegMoE-4x2-v0, Base Model (RealVisXL_V3.0).

Simply prepare a config.yaml file, with the following structure:.

It has been revealed that any number of models can be combined. For detailed information on how to create a config file, please refer to the github repository.

Note Both Hugging Face and CivitAI models are supported. For CivitAI models, paste the download link of the model, for example: "https://civitai.com/api/download/models/239306".

Then run the following command:.

This will create a folder called segmoe_v0 with the following structure:.

Alternatively, you can also use the Python API to create a mixture of experts model:.

The Model can be pushed to the hub via the huggingface-cli.

The model can also be pushed to the Hub directly from Python:.

Detailed usage can be found here.

It has been revealed that slower Speed: If the number of experts per token is larger than 1, the MoE performs computation across several expert models. This makes it slower than a single SD 1.5 or SDXL model.

Industry observers note that high VRAM usage: MoEs run inference very rapidly but still need a large amount of VRAM (and hence an expensive GPU). This makes it challenging to use them in local setups, but they are great for deployments with multiple GPUs. As a reference point, SegMoE-4x2 requires 24GB of VRAM in half-precision.

In a recent development, we built SegMoE to provide the community a latest tool that can potentially create SOTA Diffusion Models with ease, just by combining pretrained models while keeping inference times low. We're excited to see what you can build with it!

β†’ Read original article