Repository navigation
fix(model_zoo): keep session options when unpickling a session - #2907
Open
huangkongsheng wants to merge 1 commit into
Open
huangkongsheng wants to merge 1 commit into
huangkongsheng wants to merge 1 commit into
Conversation
PickableInferenceSession dropped the caller's sess_options during a pickle round-trip: __getstate__ did not record them, so __setstate__ rebuilt the session with defaults. A restored session therefore came back with the default thread pool sizing, which oversubscribes the CPU in quota-limited containers (the 185x slowdown reported in deepinsight#2899). __getstate__ now stores the scalar session options (the same attribute list copy_session_options uses) and __setstate__ applies them before re-creating the session. Old pickles without the new key still work. Covered by tests/model_zoo/test_pickable_session_options.py, which uses a tiny programmatically generated Identity ONNX model - no downloads, no sample data.
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.
Fixes #2899 (the pickle part).
@sigma-plus offered to send a PR for this in the issue, so picking it up here - hope that's ok.
PickableInferenceSessiondropped the caller'ssess_optionson a pickle round-trip:__getstate__didn't record them, so__setstate__rebuilt the session with defaults. A restored session came back with the default thread pool sizing, which oversubscribes the CPU in quota-limited containers (the ~185x slowdown in the issue).The fix stores the scalar session options in
__getstate__(reusing the attribute listcopy_session_optionsalready has) and applies them in__setstate__before re-creating the session. Old pickles without the new key still unpickle fine.Tests: new
tests/model_zoo/test_pickable_session_options.py- assertsintra_op_num_threads/inter_op_num_threadssurvive the round-trip, that default-option sessions still pickle, and that states without the new key are still accepted. They build a tiny Identity ONNX model on the fly, so no downloads or sample data are needed. All 3 pass locally; the rest of the model_zoo suite is unchanged (the 19 failures there on Windows are pre-existing symlink/license ones, also present without this change).