Skip to content

fix(llm): correctly pass multimodal_projector to LlamaCppModel - #5350

Open
Ricardo-M-L wants to merge 2 commits into
xorbitsai:mainfrom
Ricardo-M-L:fix/llamacpp-multimodal-projector
Open

fix(llm): correctly pass multimodal_projector to LlamaCppModel#5350
Ricardo-M-L wants to merge 2 commits into
xorbitsai:mainfrom
Ricardo-M-L:fix/llamacpp-multimodal-projector

Conversation

@Ricardo-M-L

Copy link
Copy Markdown
Contributor

This PR addresses: fix(llm): correctly pass multimodal_projector to LlamaCppModel

yuj and others added 2 commits April 27, 2026 12:10
When all config attributes (max_sequence_length, seq_length,
max_position_embeddings) are None, the function incorrectly returned
2048 even though max() with all None values would raise ValueError.
Now uses a generator expression with default parameter to properly
handle the case where no values are available.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
LlamaCppModel.__init__ expects `llamacpp_model_config` dict as 4th
positional argument, but was receiving the general `kwargs` dict.
This caused multimodal_projector (and other llamacpp-specific params)
to not be properly passed when launching GGUF models via CLI.

Extract llamacpp-specific params (multimodal_projector, n_ctx, etc.)
and pass them correctly to LlamaCppModel constructor.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@XprobeBot XprobeBot added the bug Something isn't working label Aug 17, 2026
@XprobeBot XprobeBot added this to the v3.x milestone Aug 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces changes to extract LlamaCpp-specific configurations from kwargs when instantiating LlamaCppModel in core.py, and updates get_context_length in utils.py to handle missing sequence length attributes by defaulting them to None and using a fallback value of 2048. A critical bug was identified in the LlamaCppModel check where type(llm_cls).name evaluates to "type" instead of the class name, which would prevent the LlamaCpp-specific configuration block from executing. Using llm_cls.name directly resolves this issue.

if peft_model is not None:

# Extract llamacpp-specific config from kwargs for LlamaCppModel
is_llamacpp = "LlamaCppModel" in type(llm_cls).__name__

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Since llm_cls is a class (e.g., XllamaCppModel), type(llm_cls) evaluates to type, and type(llm_cls).__name__ is always "type". Consequently, the condition "LlamaCppModel" in type(llm_cls).__name__ will always evaluate to False, and the LlamaCpp-specific configuration extraction will never execute. You should check llm_cls.__name__ directly instead.

Suggested change
is_llamacpp = "LlamaCppModel" in type(llm_cls).__name__
is_llamacpp = "LlamaCppModel" in llm_cls.__name__

@Ricardo-M-L Ricardo-M-L changed the title fix: fix(llm): correctly pass multimodal_projector to LlamaCppModel fix(llm): correctly pass multimodal_projector to LlamaCppModel Aug 17, 2026
@qinxuye

qinxuye commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

there is conflict, and pls address gemini comment first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants