perf(app): reduce peak memory usage #8090
Open
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.
Summary
Reduce peak memory usage by Invoke process. See commits for details.
TL;DR: We thought we had a memory leak. Not sure about that. I think we may just have a slowly climbing memory usage that eventually peaks and plateaus. Before we plateau, it looks like we have a memory leak.
Once the process allocates memory from the OS, it can never give it back, but it can re-use it. So the apparent memory leak is actually internal poor management of allocations, stemming frmo our usage patterns
Changes
del
patched tokenizer and related objects in compel nodes so python can free up the arenas used by themResults
Sampled process memory usage after each queue item (SDXL t2i nothing extra). First column is memory at that time, second is delta from prev sample. Invocation cache is disabled for the testing bc that would really confound the results.
Top graph is usage, bottom is delta.
Notes
Related Issues / Discussions
QA Instructions
Merge Plan
Checklist
What's New
copy (if doing a release after this PR)