Skip to content
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

bugfix kv cache quantization with ignored layers #1312

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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.

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 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].

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
3 participants