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

Chunk adapter for fused qkv_proj #1705

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

Conversation

yxli2123
Copy link
Contributor

@yxli2123 yxli2123 commented May 3, 2024

As microsoft/Phi-3-mini-4k-instruct is using fused qkv_proj and up_gate_proj, LoRA adapters should be applied to each chunk instead of the entire fused matrix.

The change lies in (1) adapter initialization and (2) forward computing.

For (1), we create n_chunk adapters for one fused matrix, default-chunk-0, default-chunk-1, ... for both lora_A and lora_B.

For (2), we iterate the adapter by adapter_name. Once we find its chunk, we only update the associated dense result.

We have run the make style and make quality.

@BenjaminBossan
Copy link
Member

Thanks for providing this PR. Indeed, as of now, we don't have any special provision for LoRA to deal with fused QKV layers (or any fused layers). For some models that used fused QKV, we just apply the LoRA adapter on the whole fused layer. I haven't thought this through completely, but I wonder if this should not be good enough. Do we really need to chunk the LoRA adapter?

Where there is definitely a problem is if we have fused QKV but we want to apply LoRA only to Q and V, for instance. This is currently not possible, but AFAICT, your PR wouldn't change that situation, is that right?

Copy link

github-actions bot commented Jun 2, 2024

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

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.

None yet

2 participants