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

[feature] rope support scaling type #947

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ ppl::common::RetCode DynamicBatchingRotaryPositionEmbeddingKernel::DoExecute(Ker
return ppl::common::RC_UNSUPPORTED;
}

if (param_->scaling_type != param_->SCALING_TYPE_NONE) {
LOG(ERROR) << "currently only support scaling_type == ''";
return ppl::common::RC_UNSUPPORTED;
}

int64_t max_seqlen_val = 0;
if (ppl::common::RC_SUCCESS != max_seqlen->CopyToHost(&max_seqlen_val)) {
LOG(ERROR) << "max_seqlen->CopyToHost() failed";
Expand All @@ -100,6 +95,18 @@ ppl::common::RetCode DynamicBatchingRotaryPositionEmbeddingKernel::DoExecute(Ker
int64_t num_heads = query_shape->GetDim(1);
int64_t num_key_heads = key_shape->GetDim(1);

ppl::kernel::llm::cuda::pmx::rope_scaling_t scaling_type;
if (param_->scaling_type != param_->SCALING_TYPE_NONE) {
scaling_type = ppl::kernel::llm::cuda::pmx::rope_scaling::NONE;
} else if (param_->scaling_type != param_->SCALING_TYPE_LINEAR) {
scaling_type = ppl::kernel::llm::cuda::pmx::rope_scaling::LINEAR;
} else if (param_->scaling_type != param_->SCALING_TYPE_DYNAMIC) {
scaling_type = ppl::kernel::llm::cuda::pmx::rope_scaling::DYNAMIC;
} else {
LOG(ERROR) << "invalid scaling type: " << param_->scaling_type;
return ppl::common::RC_INVALID_VALUE;
}

return ppl::kernel::llm::cuda::pmx::dynamic_batching_rotary_position_embedding(
GetStream(),
query_shape,
Expand All @@ -115,6 +122,9 @@ ppl::common::RetCode DynamicBatchingRotaryPositionEmbeddingKernel::DoExecute(Ker
num_heads,
num_key_heads,
max_seqlen_val,
param_->max_position_embeddings,
scaling_type,
param_->scaling_factor,
rotated_query->GetShape(),
rotated_query->GetBufferPtr(),
rotated_key->GetShape(),
Expand Down
Loading