Skip to content

Commit 5b3dd38

Browse files
[BugFix] fix missing kv shard helper in QKVGateParallelLinear (#8056)
1 parent c85291c commit 5b3dd38

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

fastdeploy/model_executor/layers/linear.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,11 @@ def __init__(
12181218
weight_dtype=weight_dtype,
12191219
)
12201220

1221+
def _get_kv_shard_id(self):
1222+
if self.kv_num_heads < self.tp_size:
1223+
return self.local_rank * self.kv_num_heads // self.tp_size
1224+
return self.local_rank // self.num_kv_head_replicas
1225+
12211226
def _get_shard_size_mapping(self, loaded_shard_id: str, head_dim: int):
12221227
shard_size_mapping = {
12231228
"q": self.num_heads_per_rank * head_dim,

0 commit comments

Comments
 (0)