Repository navigation
Conversation
ONNX Runtime's memory pattern plans buffers from the first run's allocations and keeps them resident for reuse. For the YoloX layout model this costs about 120 MiB of RSS per session without making later runs faster. Disable it for YoloX and Detectron2 sessions, and keep the CPU memory arena, which saves no further memory here. A 16-page YoloX run's peak RSS drops from about 1010 MiB to 892 MiB with identical output across two paired runs. Supersedes Unstructured-IO#495, which disabled both options behind the ONNX_DISABLE_MEMORY_ARENA env var. Co-authored-by: wtfyd-agent[bot] <328989958+wtfyd-agent[bot]@users.noreply.github.com>
Contributor
Author
|
Combined effect of #530, #531, #532 and #533 merged together onto
|
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.
Summary
ONNX Runtime's memory pattern (
SessionOptions.enable_mem_pattern) plans buffers from the first run's allocations and keeps them resident for reuse. For the YoloX layout model this keeps about 120 MiB more RSS per session without making later runs faster. This disables it for the YoloX and Detectron2 sessions and keeps the CPU memory arena on.Supersedes #495, which disabled both
enable_mem_patternandenable_cpu_mem_arenabehind anONNX_DISABLE_MEMORY_ARENAenv var. Measured separately, the arena doesn't save memory here, and the pattern is safe to turn off by default, so this drops the arena change and the env var. #495 also could no longer be updated in place, and its tip had an unresolved conflict marker inCHANGELOG.md.Impact
Single YoloX session, 1×3×1024×768 input, warm runs (macOS, CPU provider):
enable_mem_pattern=False(this PR)enable_cpu_mem_arena=FalseonlyEnd to end,
process_file_with_modelonsample-docs/layout-parser-paper.pdf(16 pages, YoloX), two paired runs:main34aee4cf5cdb34aee4cf5cdbThe hash covers every page's element coordinates, probabilities and class ids. Wall time was no slower; it was noisy on a busy machine.
Verification
enable_mem_pattern=Falseandenable_cpu_mem_arena=True. They fail onmainand pass here.make test: 381 passed, 1 skipped.ruff check/ruff format --checkclean.Measured only with the CPU execution provider;
enable_mem_patternis a CPU-side planning option, but a CUDA/TensorRT check before release would confirm.Version bumped to 1.6.17 with a CHANGELOG entry. #530 and #531 also target 1.6.17, so later merges need the next patch version.