Skip to content

arch : add missing tensor name for Qwen 3.5#21219

Closed
ownia wants to merge 1 commit into
ggml-org:masterfrom
ownia:fix/qwen35_tensor_name
Closed

arch : add missing tensor name for Qwen 3.5#21219
ownia wants to merge 1 commit into
ggml-org:masterfrom
ownia:fix/qwen35_tensor_name

Conversation

@ownia

@ownia ownia commented Mar 31, 2026

Copy link
Copy Markdown

Overview

Fix #21115

Additional information

Add missing tensor names for Qwen 3.5 to avoid the following warnings when running llama-quantize Qwen3.5-4B.gguf Qwen3.5-4B-Q4.gguf Q4_0:

...
llama_model_loader: - kv  33:                         tokenizer.ggml.pre str              = qwen35
llama_model_loader: - kv  34:                      tokenizer.ggml.tokens arr[str,248320]  = ["!", "\"", "#", "$", "%", "&", "'", ...
llama_model_loader: - kv  35:                  tokenizer.ggml.token_type arr[i32,248320]  = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
llama_model_loader: - kv  36:                      tokenizer.ggml.merges arr[str,247587]  = ["Ġ Ġ", "ĠĠ ĠĠ", "i n", "Ġ t",...
llama_model_loader: - kv  37:                tokenizer.ggml.eos_token_id u32              = 248046
llama_model_loader: - kv  38:            tokenizer.ggml.padding_token_id u32              = 248044
llama_model_loader: - kv  39:               tokenizer.ggml.add_bos_token bool             = false
llama_model_loader: - kv  40:                    tokenizer.chat_template str              = {%- set image_count = namespace(value...
llama_model_loader: - type  f32:  177 tensors
                                                                                                                                                                  llama_model_loader: - type bf16:  249 tensors
str: cannot properly format tensor name position_embd with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name token_types with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name position_embd with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name token_types with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name position_embd with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name token_types with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name position_embd with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name token_types with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name position_embd with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name token_types with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name position_embd with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name token_types with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name position_embd with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name token_types with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name position_embd with suffix=weight bid=-1 xid=-1
str: cannot properly format tensor name token_types with suffix=weight bid=-1 xid=-1
...

Requirements

Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
@ownia ownia requested a review from CISC as a code owner March 31, 2026 09:11
@CISC

CISC commented Mar 31, 2026

Copy link
Copy Markdown
Member

This is not the correct fix (Qwen 3.5 does not have these tensors), the log is erroneous and affects all models.

cc/ @JohannesGaessler

@ownia

ownia commented Mar 31, 2026

Copy link
Copy Markdown
Author

Oh sorry indeed there are not, double confirmed with gguf_dump. This is a common issue that affects all models.

@JohannesGaessler

Copy link
Copy Markdown
Contributor

I mean, for now we can also just disable the warning again. The problem is that there is a mismatch between the tensors that a model should have according to llm_get_tensor_names and the tensors that are actually being created which will result in tensors with an incorrectly formatted name. But I don't know why we have llm_get_tensor_names in the first place, it seems to me that it should just be removed and the tensor names just always formatted based on what arguments are being supplied to str().

@CISC

CISC commented Mar 31, 2026

Copy link
Copy Markdown
Member

I guess the real issue is that quantize does this with no check if arch actually has those:

// do not quantize positional embeddings and token types (BERT)
quantize &= name != LLM_TN(arch)(LLM_TENSOR_POS_EMBD, "weight");
quantize &= name != LLM_TN(arch)(LLM_TENSOR_TOKEN_TYPES, "weight");

@CISC

CISC commented Mar 31, 2026

Copy link
Copy Markdown
Member

But I don't know why we have llm_get_tensor_names in the first place, it seems to me that it should just be removed and the tensor names just always formatted based on what arguments are being supplied to str().

I suppose it was meant as a safeguard, but it may be superfluous, we should probably look into if it can just be removed.

@ownia

ownia commented Mar 31, 2026

Copy link
Copy Markdown
Author

I guess the real issue is that quantize does this with no check if arch actually has those:

// do not quantize positional embeddings and token types (BERT)
quantize &= name != LLM_TN(arch)(LLM_TENSOR_POS_EMBD, "weight");
quantize &= name != LLM_TN(arch)(LLM_TENSOR_TOKEN_TYPES, "weight");

Yes, I was just about to post this snippet. If quantize needs to disable the warning and not perform additional checks, there is a way we can revert this to:

    quantize &= name.find("position_embd.weight") == std::string::npos;
    quantize &= name.find("token_types.weight") == std::string::npos;

@CISC

CISC commented Mar 31, 2026

Copy link
Copy Markdown
Member

Yes, I was just about to post this snippet. If quantize needs to disable the warning and not perform additional checks, there is a way we can revert this to:

    quantize &= name.find("position_embd.weight") == std::string::npos;
    quantize &= name.find("token_types.weight") == std::string::npos;

Yes, honestly don't know why it didn't do that in the first place.

@CISC

CISC commented Apr 6, 2026

Copy link
Copy Markdown
Member

@ownia gentle ping, do you want to update this PR?

@ownia

ownia commented Apr 7, 2026

Copy link
Copy Markdown
Author

Hi @CISC , I have created another pull request (#21544) to extand this discussion. We can then close this PR.

@ownia ownia closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eval bug: regression introduced in #20503

3 participants