-
Notifications
You must be signed in to change notification settings - Fork 753
Diff kv head #8037
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
base: develop
Are you sure you want to change the base?
Diff kv head #8037
Changes from all commits
44f547c
fc06ae2
19a7044
2958fda
303ad42
29dce63
db7d260
94fa1f9
b0a901e
d7bda46
ec0be7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,11 +89,16 @@ def __init__( | |
| fd_config.model_config.num_attention_heads // fd_config.parallel_config.tensor_parallel_size | ||
| ) | ||
| self.head_dim: int = fd_config.model_config.head_dim | ||
| self.layer_id: int = layer_id | ||
| num_key_value_heads = getattr(fd_config.model_config, "num_key_value_heads_list", None) | ||
| if num_key_value_heads is None: | ||
| num_key_value_heads = fd_config.model_config.num_key_value_heads | ||
| else: | ||
| num_key_value_heads = num_key_value_heads[self.layer_id] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Bug 在这个分支里第 i 层 建议把 |
||
| self.kv_num_heads: int = max( | ||
| 1, | ||
| fd_config.model_config.num_key_value_heads // fd_config.parallel_config.tensor_parallel_size, | ||
| int(num_key_value_heads) // fd_config.parallel_config.tensor_parallel_size, | ||
| ) | ||
| self.layer_id: int = layer_id | ||
| self.v_head_dim: int = v_head_dim if v_head_dim > 0 else self.head_dim | ||
| self.rope_type: str = rope_type | ||
| self.qk_head_dim: int = self.head_dim | ||
|
|
@@ -277,7 +282,11 @@ def forward( | |
| if forward_meta.layer_done_counter is not None: | ||
| forward_meta.layer_done_counter.wait_for_layer(self.layer_id) | ||
|
|
||
| return forward_meta.attn_backend.forward( | ||
| attn_backend = forward_meta.attn_backend | ||
| if forward_meta.attn_backends is not None: | ||
| attn_backend = forward_meta.attn_backends[self.layer_id] | ||
|
|
||
| return attn_backend.forward( | ||
| q, | ||
| k, | ||
| v, | ||
|
|
||
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.