Skip to content

Conversation

@brian-dellabetta
Copy link
Collaborator

@brian-dellabetta brian-dellabetta commented Apr 1, 2025

SUMMARY:
Users may ignore some layers in configuration, meaning list indices may not correspond to a given layer index when values are being appended to a list for each layer. We must account for that case by padding list so that index of lists always corresponds to layer_idx

Resolves #1295 . I can confirm i see the error original poster is reporting, using their recipe with meta-llama/Meta-Llama-3-8B-Instruct, and that this PR resolves it. I am able to run lm_eval on the quantized model. I will move this to ready for review to get feedback.

TEST PLAN:
Add doctests to unit test new helper function, not sure if these get tested though.

@github-actions
Copy link

github-actions bot commented Apr 1, 2025

👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review.

Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed.

Copy link
Collaborator

@kylesayrs kylesayrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be better if self.k_observers was of type dict?

@brian-dellabetta brian-dellabetta marked this pull request as ready for review April 2, 2025 20:15
@brian-dellabetta brian-dellabetta added the ready When a PR is ready for review label Apr 2, 2025
@brian-dellabetta brian-dellabetta force-pushed the bdellabe/kv_cache_ignore_layer_bugfix branch from 9d7b26e to 8bc85a9 Compare April 2, 2025 20:15
@brian-dellabetta
Copy link
Collaborator Author

Would this be better if self.k_observers was of type dict?

@kylesayrs I originally started with that, but since this is always incremented it ends up being a smaller footprint and we can still get by with easy access with self.k_observers[layer_idx].

@brian-dellabetta brian-dellabetta requested a review from kylesayrs May 5, 2025 15:39
Copy link
Collaborator

@kylesayrs kylesayrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This illustrates that we should really replace these list data structures with dicts, but this is a good change to fix the issue!

Signed-off-by: Brian Dellabetta <[email protected]>
@brian-dellabetta brian-dellabetta force-pushed the bdellabe/kv_cache_ignore_layer_bugfix branch from 8bc85a9 to aad85a3 Compare May 5, 2025 16:06
@brian-dellabetta brian-dellabetta enabled auto-merge (rebase) May 5, 2025 16:20
@brian-dellabetta brian-dellabetta merged commit 0a21794 into main May 5, 2025
8 checks passed
@brian-dellabetta brian-dellabetta deleted the bdellabe/kv_cache_ignore_layer_bugfix branch May 5, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready When a PR is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't quantize kv cache: observer = self.k_observers[layer_idx] liste index out of range

4 participants