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] DisableKVCache Context #834

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

Conversation

kylesayrs
Copy link
Collaborator

@kylesayrs kylesayrs commented Oct 9, 2024

Purpose

Changes

  • Use a no kv cache context which checks for use_cache and text_config.use_cache in cases like MllamaConfig

Testing

  • Previously, attempting to forward pass meta-llama/Llama-3.2-11B-Vision-Instruct would lead to attribute error. Now runs normally with model.config.text_config.use_cache == False
  • Regression tested cache disabling with meta-llama/Meta-Llama-3-8B-Instruct

Copy link

github-actions bot commented Oct 9, 2024

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

@kylesayrs kylesayrs changed the title Use Cache DisableKVCache Context Oct 9, 2024
@kylesayrs kylesayrs self-assigned this Oct 9, 2024
@kylesayrs kylesayrs marked this pull request as ready for review October 10, 2024 18:09
Copy link
Collaborator

@dsikka dsikka left a comment

Choose a reason for hiding this comment

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

test?

@kylesayrs kylesayrs changed the title DisableKVCache Context [Bugfix] DisableKVCache Context Oct 17, 2024
rahul-tuli
rahul-tuli previously approved these changes Oct 17, 2024
src/llmcompressor/utils/helpers.py Outdated Show resolved Hide resolved
Comment on lines +1071 to +1075
# unknown config structure
else:
raise NotImplementedError(
f"Cannot find `use_cache` for config of type {type(model.config)}"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you try this on other models that doesn't have a use_cache in their config? Such as Llava https://huggingface.co/llava-hf/llava-1.5-7b-hf

@kylesayrs
Copy link
Collaborator Author

There are likely many ways to achieve this, including using the use_cache argument during the forward pass. However, this is known to at least work on the models we've tested

@kylesayrs
Copy link
Collaborator Author

Pending testing with llava models

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.

AttributeError: 'MllamaConfig' object has no attribute 'use_cache'
4 participants