Skip to content

Conversation

@evkotov
Copy link
Contributor

@evkotov evkotov commented Sep 18, 2025

This PR fixes the nibble ordering inconsistency in 4-bit types (u4/i4) where ConvertPrecision transformation was not aligned with the current LSB-first packing standard.

Problem

ConvertPrecision transformation was using deprecated MSB-first nibble order (not updated after PR #20371), while Convert operation with ConstantFolding used the correct LSB-first order via element::iterator. This created inconsistencies between
different code paths for the same input.

Path inconsistency before fix:

  Input: u4 constant bytes [0xAB]
               |
               v
        ┌──────┴──────┐
        |             |
        v             v
    ConvertPrecision  Convert → ConstantFolding
    (MSB-first)       (LSB-first via is_lsb_packed)
        |             |
        v             v
     [10, 11]      [11, 10]  <-- Different results!

This led to incorrect values in INT4 quantized models (like Phi-3) when different optimization paths were applied.

Solution

Refactored convert_low_precisions_int() to use Convert::evaluate() instead of custom conversion logic. This ensures consistent LSB-first nibble packing across all conversion paths, aligning with the standard established in PR #20371.

Path consistency after fix:

 Path consistency after fix:
  Input: u4 constant bytes [0xAB]
               |
               v
        ┌──────┴──────┐
        |             |
        v             v
    ConvertPrecision  Convert → ConstantFolding
    (via Convert::evaluate)   (LSB-first)
        |             |
        v             v
     [11, 10]      [11, 10]  <-- Same results!

Tickets:

@evkotov evkotov self-assigned this Sep 18, 2025
@evkotov evkotov requested review from a team as code owners September 18, 2025 10:01
@evkotov evkotov added category: transformations OpenVINO Runtime library - Transformations do_not_review do_not_merge labels Sep 18, 2025
@github-actions github-actions bot added category: Core OpenVINO Core (aka ngraph) category: GPU OpenVINO GPU plugin and removed category: transformations OpenVINO Runtime library - Transformations labels Sep 18, 2025
@evkotov evkotov requested a review from a team as a code owner October 22, 2025 16:09
@evkotov evkotov requested review from CuriousPanCake and removed request for a team October 22, 2025 16:09
@github-actions github-actions bot added category: transformations OpenVINO Runtime library - Transformations and removed category: Core OpenVINO Core (aka ngraph) category: GPU OpenVINO GPU plugin labels Oct 22, 2025
@evkotov evkotov changed the title [NO REVIEW] is_lsb_packed() fix + fix unit test Nibble order for 4-bit types Oct 22, 2025
@evkotov evkotov requested review from mryzhov and praasz October 22, 2025 16:16
@evkotov evkotov changed the title Nibble order for 4-bit types Align ConvertPrecision with LSB-first nibble packing for u4/i4 types Oct 22, 2025
@evkotov evkotov requested a review from praasz November 1, 2025 09:52
@mryzhov mryzhov self-assigned this Nov 3, 2025
@praasz praasz added this to the 2026.0 milestone Nov 5, 2025
@dorloff dorloff added this pull request to the merge queue Nov 6, 2025
Merged via the queue into openvinotoolkit:master with commit 81f0be8 Nov 6, 2025
203 checks passed
@evkotov evkotov deleted the CVS-161778 branch November 6, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: transformations OpenVINO Runtime library - Transformations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants