Skip to content

fix(runtime): convert_gguf.py vocab fallback is dead-coded with if False #637

Description

@kurosawareiji7007-hub

Summary

runtime/tools/convert_gguf.py claims to take vocab from token_embd.weight when writing config.txt, but the assignment is disabled:

if "token_embd.weight" in ten:
    cfg["vocab"] = int(ten["token_embd.weight"].shape[-1]) if False else cfg["vocab"]

The C++ GGUF path always prefers the embedding tensor (emb->dims[1] in runtime/examples/qwen3_gguf_config.h / qwen35.cpp). The Python converter therefore can write a wrong vocab= into config.txt when metadata is missing or disagrees with the tensor, which breaks downstream load_weights / LM-head sizing for this tool path.

Expected

Prefer vocab from token_embd.weight shape (ggml dims[1] / Python shape[1] for 2D), matching the runtime.

Scope

No GPU required — tooling correctness only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions