Bug fixes and performance improvements for ComfyUI-WanVideoWrapper#844
Open
programming-pupil wants to merge 10 commits intokijai:mainfrom
Open
Bug fixes and performance improvements for ComfyUI-WanVideoWrapper#844programming-pupil wants to merge 10 commits intokijai:mainfrom
programming-pupil wants to merge 10 commits intokijai:mainfrom
Conversation
Contributor
|
"torch no_grad"s are not needed because ComfyUI sets torch no grad inference mode for the workflow globally |
Author
Okay, I understand. I have restored the code I will be working on. Thank you very much for taking the time to review it again and see if it needs to be merged. I am very grateful for your tremendous contribution to the open source community! |
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.
Bug fixes and performance improvements for ComfyUI-WanVideoWrapper
This PR addresses several bugs and performance issues in the ComfyUI-WanVideoWrapper project:
Bug Fixes
1. Fixed cache state management
Added proper checks to ensure pred_id exists in cache state before accessing it, preventing potential KeyError exceptions.
2. Fixed RoPE implementation
Added dimension checks in apply_rope_comfy_chunked to prevent index errors when freqs_cis dimensions are smaller than seq_dim.
3. Fixed index handling in multitalk audio processing
Added length checks to prevent index errors when processing audio embeddings of different lengths.
Performance Improvements
1. Optimized memory usage in sampling process
Added explicit tensor cleanup and torch.no_grad() contexts to reduce memory usage during sampling.
2. Improved VAE encoding/decoding performance
Optimized tile processing in VAE encoding and decoding to reduce memory overhead and improve speed.
3. Added memory-efficient RoPE computation
Implemented a more memory-efficient version of RoPE computation that reduces peak memory usage.
4. Optimized context window processing
Improved memory efficiency in context window processing by reusing tensors and reducing unnecessary allocations.
Testing
All changes have been tested with various video generation workflows to ensure they don't introduce new issues.