Uh oh!
There was an error while loading. Please reload this page.
[docs] Model formats - #12256
Conversation
HuggingFaceDocBuilderDev
commented
Aug 28, 2025
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Uh oh!
There was an error while loading. Please reload this page.
| pipeline = DiffusionPipeline.from_single_file( | ||
| "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0.safetensors", | ||
| torch_dtype=torch.float16, | ||
| device_map="cuda" |
There was a problem hiding this comment.
I don't think we support device_map="cuda" in from_single_file yet. Cc: @DN6 should we add support?
There was a problem hiding this comment.
Supported now
Snippet looks good 👍🏽
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| pipeline = StableDiffusionPipeline.from_single_file( | ||
| "https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/blob/main/v1-5-pruned.ckpt" | ||
| ckpt_path = "https://huggingface.co/lightx2v/Qwen-Image-Lightning/blob/main/Qwen-Image-Lightning-8steps-V1.1-bf16.safetensors" | ||
| original_config = "https://raw.githubusercontent.com/Wan-Video/Wan2.2/refs/heads/main/wan/configs/wan_ti2v_5B.py" |
There was a problem hiding this comment.
Oops, just realized Wan doesn't support from_single_file. Reverted to the original code example!
| ## File types | ||
| ## Single-file layout usage | ||
| Models can be stored in several file types. Safetensors is the most common file type but you may encounter other file types on the Hub or diffusion community. |
There was a problem hiding this comment.
Should safetensors be hyperlinked?
There was a problem hiding this comment.
Hyperlinked in the Safetensors section below :)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| pipeline = DiffusionPipeline.from_single_file( | ||
| "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0.safetensors", | ||
| torch_dtype=torch.float16, | ||
| device_map="cuda" |
There was a problem hiding this comment.
Supported now
Snippet looks good 👍🏽
Uh oh!
There was an error while loading. Please reload this page.
| - Easier to download and share a single file. | ||
| Use the [`~loaders.FromSingleFileMixin.from_single_file`] method to load a model with all the weights stored in a single safetensors file. | ||
| Use [`~loaders.FromSingleFileMixin.from_single_file`] to load a single file. Pass `"cuda"` to the `device_map` argument to pre-allocate GPU memory and reduce model loading time (refer to the [parallel loading](../using-diffusers/loading#parallel-loading) docs for more details). |
There was a problem hiding this comment.
Single file does support pre-allocating GPU memory to reduce model loading time, but parallel loading only works for sharded checkpoints (one more spread over multiple files).
There was a problem hiding this comment.
I thought with #12305, it is supported for from_single_file now?
There was a problem hiding this comment.
Parallel loading only works for multiple files (sharded checkpoints) since you load them simultaneously. Since single file is just one file, you won't see any advantage.
There was a problem hiding this comment.
Ah, I see! Ok, removed mention of pre-allocating :)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Refactors the
Model files and layoutsguide to from a more top-down approach, beginning with the formats (Diffusers/single-file) and then discussing the individual file types.