8000 llama : default pooling last for qwen3 by ngxson · Pull Request #14028 · ggml-org/llama.cpp · GitHub
[go: up one dir, main page]

Skip to content

llama : default pooling last for qwen3 #14028

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

Closed
wants to merge 1 commit into from
Closed
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
llama : default pooling last for qwen3
  • Loading branch information
ngxson committed Jun 5, 2025
commit 23c5b57ae3963208ac9e0575c30dd17cdea4e960
5 changes: 3 additions & 2 deletions src/llama-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,8 @@ void llama_model::load_hparams(llama_model_loader & ml) {
case LLM_ARCH_QWEN3:
{
ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps);
hparams.pooling_type = LLAMA_POOLING_TYPE_LAST; // for embeddings model
Comment on lines 822 to +823
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps);
hparams.pooling_type = LLAMA_POOLING_TYPE_LAST; // for embeddings model
hparams.pooling_type = LLAMA_POOLING_TYPE_LAST; // for embeddings model
ml.get_key(LLM_KV_POOLING_TYPE, hparams.pooling_type, false);
ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps);

Copy link
Collaborator
@CISC CISC Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps use metadata if it exists, and add the pooling check to conversion (do they use 1_Pooling)? Ah, the check is already there, guess they don't.

Copy link
Collaborator Author
@ngxson ngxson Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For rerank model, there is be a KV metadata to switch the pooling to "rank"

So yes, it's better to do as you suggested


switch (hparams.n_layer) {
case 28: type = hparams.n_embd == 1024 ? LLM_TYPE_0_6B : LLM_TYPE_1_7B; break;
case 36: type = hparams.n_embd == 2560 ? LLM_TYPE_4B : LLM_TYPE_8B; break;
Expand All @@ -830,8 +832,7 @@ void llama_model::load_hparams(llama_model_loader & ml) {
} break;
case LLM_ARCH_QWEN3MOE:
{
ml.get_key(LLM_KV_EXPERT_FEED_FORWARD_LENGTH, hparams.n_ff_exp, false);

ml.get_key(LLM_KV_EXPERT_FEED_FORWARD_LENGTH, hparams.n_ff_exp, false);
ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps);
switch (hparams.n_layer) {
case 48: type = LLM_TYPE_30B_A3B; break;
Expand Down
Loading
0