Improve the performance and suitable for NPU computing#9631
Closed
leisuzz wants to merge 0 commit intohuggingface:mainfrom
Closed
Improve the performance and suitable for NPU computing#9631leisuzz wants to merge 0 commit intohuggingface:mainfrom
leisuzz wants to merge 0 commit intohuggingface:mainfrom
Conversation
a-r-r-o-w
reviewed
Oct 10, 2024
| model_input = vae.encode(pixel_values).latent_dist.sample() | ||
| model_input = model_input * vae.config.scaling_factor | ||
| return {"model_input": model_input.cpu()} | ||
| return {"model_input": accelerator.gather(model_input)} |
Contributor
There was a problem hiding this comment.
Sorry if my question is stupid, but why do we need to gather here? Doesn't this cause a sync between all ranks, as opposed to npu to cpu memory sync, making it slower overall?
| add_time_ids = list(original_size + crops_coords_top_left + target_size) | ||
| add_time_ids = torch.tensor([add_time_ids]) | ||
| add_time_ids = add_time_ids.to(accelerator.device, dtype=weight_dtype) | ||
| add_time_ids = torch.tensor([add_time_ids], device=accelerator.device, dtype=weight_dtype) |
|
|
||
| hidden_states = hidden_states.transpose(1, 2).reshape(batch_size, -1, attn.heads * head_dim) | ||
| hidden_states = hidden_states.to(query.dtype) | ||
| hidden_states = hidden_states.transpose(1, 2).reshape(batch_size, -1, attn.heads * head_dim).to(query.dtype) |
Contributor
There was a problem hiding this comment.
Why do we need this change? For improvements to the library, feel free to open a separate PR :)
Contributor
|
cc @sayakpaul for training scripts and as original author for the sdxl script |
Member
|
@leisuzz any reason for closing the PR? |
Contributor
Author
|
@sayakpaul Sorry, some conflicts for the commit, I created two new PRs #9642 and #9640 |
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.
What does this PR do?
Improve the performance (FPS) while training, and suitable for NPU computing.
Selection for free memory for CUDA or NPU
Add FlashAttention for NPU in attention processor
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.