Skip to content

Commit b9e185c

Browse files
Alcanderianouonline
authored andcommitted
[feature] rope support scaling type
1 parent f1e6df7 commit b9e185c

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/ppl/nn/engines/llm_cuda/kernels/opmx/dynamic_batching/rotary_position_embedding_kernel.cc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ ppl::common::RetCode DynamicBatchingRotaryPositionEmbeddingKernel::DoExecute(Ker
8383
return ppl::common::RC_UNSUPPORTED;
8484
}
8585

86-
if (param_->scaling_type != param_->SCALING_TYPE_NONE) {
87-
LOG(ERROR) << "currently only support scaling_type == ''";
88-
return ppl::common::RC_UNSUPPORTED;
89-
}
90-
9186
int64_t max_seqlen_val = 0;
9287
if (ppl::common::RC_SUCCESS != max_seqlen->CopyToHost(&max_seqlen_val)) {
9388
LOG(ERROR) << "max_seqlen->CopyToHost() failed";
@@ -100,6 +95,18 @@ ppl::common::RetCode DynamicBatchingRotaryPositionEmbeddingKernel::DoExecute(Ker
10095
int64_t num_heads = query_shape->GetDim(1);
10196
int64_t num_key_heads = key_shape->GetDim(1);
10297

98+
ppl::kernel::llm::cuda::pmx::rope_scaling_t scaling_type;
99+
if (param_->scaling_type != param_->SCALING_TYPE_NONE) {
100+
scaling_type = ppl::kernel::llm::cuda::pmx::rope_scaling::NONE;
101+
} else if (param_->scaling_type != param_->SCALING_TYPE_LINEAR) {
102+
scaling_type = ppl::kernel::llm::cuda::pmx::rope_scaling::LINEAR;
103+
} else if (param_->scaling_type != param_->SCALING_TYPE_DYNAMIC) {
104+
scaling_type = ppl::kernel::llm::cuda::pmx::rope_scaling::DYNAMIC;
105+
} else {
106+
LOG(ERROR) << "invalid scaling type: " << param_->scaling_type;
107+
return ppl::common::RC_INVALID_VALUE;
108+
}
109+
103110
return ppl::kernel::llm::cuda::pmx::dynamic_batching_rotary_position_embedding(
104111
GetStream(),
105112
query_shape,
@@ -115,6 +122,9 @@ ppl::common::RetCode DynamicBatchingRotaryPositionEmbeddingKernel::DoExecute(Ker
115122
num_heads,
116123
num_key_heads,
117124
max_seqlen_val,
125+
param_->max_position_embeddings,
126+
scaling_type,
127+
param_->scaling_factor,
118128
rotated_query->GetShape(),
119129
rotated_query->GetBufferPtr(),
120130
rotated_key->GetShape(),

0 commit comments

Comments
 (0)