[Accelerate model loading] Fix meta device and super low memory usage#1016
Merged
patrickvonplaten merged 2 commits intomainfrom Oct 27, 2022
Merged
[Accelerate model loading] Fix meta device and super low memory usage#1016patrickvonplaten merged 2 commits intomainfrom
patrickvonplaten merged 2 commits intomainfrom
Conversation
Contributor
Author
|
The tests: are currently failing on main. Also this PR renames: Related original PR: #850 @piEsposito does this work for you? |
| assert np.abs(ddpm_images - ddim_images).max() < 1e-1 | ||
|
|
||
| @require_torch_gpu | ||
| def test_stable_diffusion_accelerate_load_works(self): |
Contributor
Author
There was a problem hiding this comment.
this test doesn't do anything so let's delete it
|
The documentation is not available anymore as the PR was closed or merged. |
patil-suraj
approved these changes
Oct 27, 2022
Contributor
patil-suraj
left a comment
There was a problem hiding this comment.
thanks for fixing this, looks good to me!
| self.enable_attention_slicing(None) | ||
|
|
||
| def cuda_with_minimal_gpu_usage(self): | ||
| def enable_sequential_cpu_offload(self): |
Comment on lines
+736
to
+751
| pipeline_id = "CompVis/stable-diffusion-v1-4" | ||
|
|
||
| start_time = time.time() | ||
| pipeline_normal_load = StableDiffusionPipeline.from_pretrained( | ||
| pipeline_id, revision="fp16", torch_dtype=torch.float16, use_auth_token=True | ||
| ) | ||
| pipeline_normal_load.to(torch_device) | ||
| normal_load_time = time.time() - start_time | ||
|
|
||
| start_time = time.time() | ||
| _ = StableDiffusionPipeline.from_pretrained( | ||
| pipeline_id, revision="fp16", torch_dtype=torch.float16, use_auth_token=True, device_map="auto" | ||
| ) | ||
| meta_device_load_time = time.time() - start_time | ||
|
|
||
| assert 2 * meta_device_load_time < normal_load_time |
Contributor
|
@patrickvonplaten great naming choice, I love it! |
yoonseokjin
pushed a commit
to yoonseokjin/diffusers
that referenced
this pull request
Dec 25, 2023
…huggingface#1016) * [Accelerate model loading] Fix meta device and super low memory usage * better naming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The tests:
are currently failing on main.
Also this PR renames:
cuda_with_minimal_gpu_usagetoenable_sequential_cpu_offloadas it's a more fitting name and disentangledenable_attention_slicingfromcpu_offloadRelated original PR: #850
@piEsposito does this work for you?