optimization ConstantFolding memory consumption with periodic cleanup #31545
+197
−18
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.
Details:
OpenVINO ConstantFolding transformation is consuming a lot of memory during model compilation, particularly for large models like GPT2. Memory profiling revealed that ConstantFolding alone consumed ~500MB during transformation pipeline,
contributing to peak memory usage of over 3GB.
Memory profiling identified that ConstantFolding creates large intermediate constant nodes. These nodes are freed by the transformation logic but memory is not immediately returned to the OS due to glibc malloc
behavior - freed memory is kept in internal pools for potential reuse.
Implemented periodic memory cleanup in ConstantFolding transformation using malloc_trim() to force return of unused memory to OS.
Tickets: