Skip to content

fix(sdk): enable thinking mode on the llama.cpp VLM path#1161

Draft
Paul Zhu (vinovo) wants to merge 1 commit into
mainfrom
fix/gemma4-thinking
Draft

fix(sdk): enable thinking mode on the llama.cpp VLM path#1161
Paul Zhu (vinovo) wants to merge 1 commit into
mainfrom
fix/gemma4-thinking

Conversation

@vinovo

@vinovo Paul Zhu (vinovo) commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

geniex infer <gemma-4 gguf> --think produced no thinking (<think>) content, even though the model supports reasoning and llama-cli renders it with the same GGUF.

Gemma-4 ships an mmproj file, so it loads as a VLM and runs through sdk/plugins/llama_cpp/src/vlm.cpp — not llm.cpp. That path suppressed thinking in two spots:

  • LlamaVlm::apply_chat_template hardcoded enable_thinking = false (and logged a "not supported" warning), so the chat template never emitted the <|think|> system-turn token that primes Gemma-4 to reason.
  • LlamaVlm::generate called llama_token_to_piece(..., /*special=*/false), so the model's <|channel> / <channel|> reasoning delimiters rendered as empty strings and the CLI's <think> FSM never fired.

This PR passes enable_thinking through on the VLM path and renders special tokens during generation (matching llama.cpp's own mtmd-cli, which renders special tokens by default).

Test plan

  • geniex infer google/gemma-4-E2B-it-qat-q4_0-gguf --think renders a <think>…</think> block
  • --think=false suppresses thinking (direct answer)
  • Qwen3 LLM path with --think still renders <think>

@vinovo Paul Zhu (vinovo) force-pushed the fix/gemma4-thinking branch 2 times, most recently from 41fbc01 to 5937047 Compare July 8, 2026 07:57
Gemma-4 ships an mmproj file so it loads as a VLM and runs through
vlm.cpp, which hardcoded enable_thinking=false and dropped special
tokens in token_to_piece. Pass enable_thinking through and render
special tokens so reasoning channel delimiters reach the caller.

Closes qcom-ai-hub/geniex#1208

Signed-off-by: Paul Zhu <paulzhuzx@gmail.com>
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.

1 participant