diffusers
diffusers copied to clipboard
Follow up for Group Offload to Disk
What does this PR do?
Since we now have multiple offload options available in group offload (standard, low_cpu_mem_usage, offload_to_disk), it would make sense to create separate utility functions for them and try to reuse common patterns e.g. try to use cpu_param_dict and the pinned_memory context manager with streams.
This PR is just to organize the module a bit so that it's a bit easier to add further functionality, e.g. #11758 without having a lot of conditional paths.
Fixes # (issue)
Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the contributor guideline?
- [ ] Did you read our philosophy doc (important for complex PRs)?
- [ ] Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
- [ ] Did you write any new necessary tests?
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.
btw @sayakpaul This line
self.safetensors_file_path = os.path.join(self.offload_to_disk_path, f"group_{id(self)}.safetensors")
Uses the memory address of the group object to create the filename, but that can change across sessions. So you could have the offload directory growing quite substantially if running an inference script multiple times.
Might need to come up with another way to name the files so that new ones aren't created across sessions.
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.