Skip to content

Conversation

@sayakpaul
Copy link
Member

@sayakpaul sayakpaul commented Sep 9, 2025

What does this PR do?

from diffusers import FluxTransformer2DModel
import torch 
import time

ckpt_path = "https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/flux1-dev.safetensors"

start = time.perf_counter()
transformer = FluxTransformer2DModel.from_single_file(
    ckpt_path, torch_dtype=torch.bfloat16, device_map="cuda"
)
# transformer = FluxTransformer2DModel.from_single_file(
#     ckpt_path, torch_dtype=torch.bfloat16,
# ).to("cuda")
torch.cuda.synchronize()
end = time.perf_counter()

print(f"Take taken to initialize the model on CUDA: {(end - start)} seconds.")

Timing:

CUDA placement manual: 4.86 seconds
Device map: 1.09 seconds

(On an H100)

@sayakpaul sayakpaul requested a review from DN6 September 9, 2025 10:08
@HuggingFaceDocBuilderDev

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.

@sayakpaul
Copy link
Member Author

@stevhliu it would be awesome to also add a doc entry for this.

@DN6 test needed to be added this PR?

@stevhliu
Copy link
Member

stevhliu commented Sep 9, 2025

Added a note about it in #12256 👍

@sayakpaul
Copy link
Member Author

Included a test too.

@sayakpaul sayakpaul merged commit 9e7ae56 into main Sep 10, 2025
13 of 14 checks passed
@sayakpaul sayakpaul deleted the single-file-cache-allocator branch September 10, 2025 07:25
@stevhliu stevhliu mentioned this pull request Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants