Skip to content

[feat] cache allocator warmup for from_single_model - #12305

Merged
sayakpaul merged 4 commits into
mainfrom
single-file-cache-allocator
Sep 10, 2025
Merged

[feat] cache allocator warmup for from_single_model#12305
sayakpaul merged 4 commits into
mainfrom
single-file-cache-allocator

Conversation

@sayakpaul

@sayakpaulsayakpaul commented Sep 9, 2025

Copy link
Copy Markdown
Member

What does this PR do?

fromdiffusersimportFluxTransformer2DModelimporttorchimporttimeckpt_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 DN6September 9, 2025 10:08
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

DN6
DN6 approved these changes Sep 9, 2025
@sayakpaul

Copy link
Copy Markdown
MemberAuthor

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

@DN6 test needed to be added this PR?

@stevhliu

Copy link
Copy Markdown
Member

Added a note about it in #12256 👍

@sayakpaul

Copy link
Copy Markdown
MemberAuthor

Included a test too.

@sayakpaul
sayakpaul merged commit 9e7ae56 into mainSep 10, 2025
13 of 14 checks passed
@sayakpaul
sayakpaul deleted the single-file-cache-allocator branch September 10, 2025 07:25
@stevhliustevhliu mentioned this pull request Sep 22, 2025
Sign up for freeto 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.

4 participants

@sayakpaul@HuggingFaceDocBuilderDev@stevhliu@DN6