How to Save an SDXL Model into a Single File safetensors file

A member of my team has trained a custom SDXL model. To use this custom model we must create a single file that can replace this file in the official SDXL 1.0 Hugging Face repository.

However, I can not find documentation on how to create a single file like this one in the official SDXL repository that includes the UNet, CLIP, and VAE weights saved into a single safetensors format file.

How can I create a file that can serve as a drop-in replacement for sd_xl_base_1.0.safetensors?

This code example does not produce any single file containing the UNet, CLIP, and VAE weights:

pipe = StableDiffusionXLPipeline.from_pretrained(
    "Our-Custom-Model",
)

pipe.save_pretrained(
    save_directory="tmp",
    push_to_hub=True,
    repo_id="Our-Custom-Model",
)

1 Like

For additional context, these Hugging Face loaders exist to load single file models but I can not find corresponding methods to write/save hugging face diffuser models in this format: Single files

1 Like

hi! I’m currently pondering this question as well. Have you found a solution?

1 Like

ComfyUI has node CheckpointSave (Add Node > advanced > model_merging).

  1. Find a simple workflow (they usually have node to load checkpoint, you can delete it).
  2. Add nodes to load each of models’ components (Add Node > loaders, or Add Node > advanced > loaders)
  3. Connect them to the node CheckpointSave.
  4. Queue a simple prompt (you can set steps to 1 in KSampler).

That’s the only workaround I have found