Skip to content

Initialize result_scale with default scale in ScaleEstimation#3997

Closed
RinZ27 wants to merge 1 commit intoopenvinotoolkit:developfrom
RinZ27:fix/scale-estimation-uninitialized-variable
Closed

Initialize result_scale with default scale in ScaleEstimation#3997
RinZ27 wants to merge 1 commit intoopenvinotoolkit:developfrom
RinZ27:fix/scale-estimation-uninitialized-variable

Conversation

@RinZ27
Copy link
Copy Markdown

@RinZ27 RinZ27 commented Mar 24, 2026

Changes

Initialized result_scale with the default scale value at the start of the calculate_quantization_params function. I noticed that if both initial_steps and scale_steps are set to zero, the variable remains uninitialized, which would cause an error during the subsequent fns.squeeze call.

Reason for changes

This ensures the algorithm is robust even when optimization steps are disabled by the user. While the default configuration uses several steps, I want to make sure the code doesn't crash if someone decides to skip the estimation process entirely.

Related tickets

None

Tests

Verified the fix by manually checking the logic for the edge case where steps are zero. Everything is green in the local environment and the change is a simple safety initialization that doesn't affect the default behavior.

@AlexanderDokuchaev
Copy link
Copy Markdown
Collaborator

Hi @RinZ27
Thanks a lot for your PR!
However, this change requires a bit more work in the codebase and adding some new tests.
So I went ahead and created a new PR based on this one.

@RinZ27
Copy link
Copy Markdown
Author

RinZ27 commented Apr 16, 2026

@AlexanderDokuchaev Appreciate you taking this forward in #4039 to ensure broader application and proper test coverage. Handling the fix in a more comprehensive PR seems like the right move. I'll be following the progress there. Thanks for the update!

@RinZ27 RinZ27 deleted the fix/scale-estimation-uninitialized-variable branch April 16, 2026 12:39
AlexanderDokuchaev added a commit that referenced this pull request Apr 17, 2026
### Changes

Support initial_steps and scale_steps to be zero for
`calculate_quantization_params`
Add tests case for differ steps

### Reason for changes

#3997

### Related tickets

### Tests

https://github.com/openvinotoolkit/nncf/actions/runs/24425425305
https://github.com/openvinotoolkit/nncf/actions/runs/24425387669
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants