-
Notifications
You must be signed in to change notification settings - Fork 272
[OpenVINO] Introduce a way to control resetting of the state of stateful OV models #3714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OpenVINO] Introduce a way to control resetting of the state of stateful OV models #3714
Conversation
|
Example usage: huggingface/optimum-intel#1505 |
db81db1 to
5f7518b
Compare
src/nncf/data/dataset.py
Outdated
| # between model inferences. This key can be added to a dataset sample input dictionary with either | ||
| # `True` or `False` value. With `True` value, the model state will be reset before inference on the corresponding | ||
| # sample, and with `False` the state will not be reset. | ||
| RESET_STATE_KEY = "nncf_reset_state" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like incorrect place for definition of variable.
May be better define it in src/nncf/definitions.py ?
And for users add note in docstring of Dataset that it can be use stateful models
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to src/nncf/definitions.py
Changes
Added
nncf.definitions.NNCF_DATASET_RESET_STATE_KEYconstant to specify when to reset model state. This constant is used by OpenVINO backend to control resetting of internal model state between model inferences. This key can be added to a dataset sample input dictionary with eitherTrueorFalsevalue. WithTruevalue, the model state will be reset before inference on the corresponding sample, and withFalsethe state will not be reset.For an example of usage please see huggingface/optimum-intel#1505.
Reason for changes
Without this logic static quantization quality of stateful Whisper models is poor because a state of a stateful model must be cleared with the same schedule as it is done during calibration input data collection.
Related tickets
172705
Tests
Added
tests/openvino/native/test_engine.py::test_stateful_model_inference_with_controlled_resetting.