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

Improvements of KVCache and refactoring of subclasses of classes in model.py #1867

Open
mseeger opened this issue Dec 10, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@mseeger
Copy link

mseeger commented Dec 10, 2024

Studying your codebase (trying to learn about transformers in depth), I noted a few things that can be improved:

  • KVCache: Second dimension of buffers should always be n_query_groups. If 1 < n_query_groups < n_head, you are wasting memory. Easy to fix.
  • KVCache: forward returns tensors with final dimension max_seq_length. This is wasteful for the subsequence dot production attention computation. Can shorten this to a length that just covers all positions in input_pos. Relatively easy to fix.
  • Code in adapter.py, adapter_v2.py, lora.py does a lot of copy and paste, which makes changing anything in model.py hard. I'd refactor that, so that as much common code only lives in model.py.

Let me know if this makes sense.

Thanks for doing this project. I really understand the details of transformer models better now.

@mseeger
Copy link
Author

mseeger commented Dec 12, 2024

Check #1870

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant