Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions docs/options/mtmd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
####> This option file is used in:
####> ramalama run, ramalama sandbox goose, ramalama sandbox opencode, ramalama sandbox pi, ramalama serve
####> If this file is edited, make sure the changes
####> are applicable to all of those.
#### **--mtmd**=*BOOL*
Enable or disable multimodal support.
If enabled and a multimodal projector file is detected, `--mmproj` is
added to the llama-server command-line.
When omitted, multimodal support is automatically detected.
10 changes: 10 additions & 0 deletions docs/ramalama-run.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ Make sure the sampling parameters like top_k on the web UI are set correctly.
[//]: # (END included file options/model-draft.md)


[//]: # (BEGIN included file options/mtmd.md)
#### **--mtmd**=*BOOL*
Enable or disable multimodal support.
If enabled and a multimodal projector file is detected, `--mmproj` is
added to the llama-server command-line.
When omitted, multimodal support is automatically detected.

[//]: # (END included file options/mtmd.md)


[//]: # (BEGIN included file options/name.md)
#### **--name**, **-n**
Name of the container to run the Model in.
Expand Down
2 changes: 2 additions & 0 deletions docs/ramalama-run.1.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ the execution. URL support means if a model is on a web site or even on your loc

@@option model-draft

@@option mtmd

@@option name

@@option ncmoe
Expand Down
10 changes: 10 additions & 0 deletions docs/ramalama-sandbox-goose.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ Only used when invoked in router mode (zero or multiple models).
[//]: # (END included file options/models-max.md)


[//]: # (BEGIN included file options/mtmd.md)
#### **--mtmd**=*BOOL*
Enable or disable multimodal support.
If enabled and a multimodal projector file is detected, `--mmproj` is
added to the llama-server command-line.
When omitted, multimodal support is automatically detected.

[//]: # (END included file options/mtmd.md)


[//]: # (BEGIN included file options/name.md)
#### **--name**, **-n**
Name of the container to run the Model in.
Expand Down
2 changes: 2 additions & 0 deletions docs/ramalama-sandbox-goose.1.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Otherwise only the agent container starts using the given url for the openai com

@@option models-max

@@option mtmd

@@option name

@@option ncmoe
Expand Down
10 changes: 10 additions & 0 deletions docs/ramalama-sandbox-opencode.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ Only used when invoked in router mode (zero or multiple models).
[//]: # (END included file options/models-max.md)


[//]: # (BEGIN included file options/mtmd.md)
#### **--mtmd**=*BOOL*
Enable or disable multimodal support.
If enabled and a multimodal projector file is detected, `--mmproj` is
added to the llama-server command-line.
When omitted, multimodal support is automatically detected.

[//]: # (END included file options/mtmd.md)


[//]: # (BEGIN included file options/name.md)
#### **--name**, **-n**
Name of the container to run the Model in.
Expand Down
2 changes: 2 additions & 0 deletions docs/ramalama-sandbox-opencode.1.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Otherwise only the agent container starts using the given url for the openai com

@@option models-max

@@option mtmd

@@option name

@@option ncmoe
Expand Down
10 changes: 10 additions & 0 deletions docs/ramalama-sandbox-pi.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,16 @@ Only used when invoked in router mode (zero or multiple models).
[//]: # (END included file options/models-max.md)


[//]: # (BEGIN included file options/mtmd.md)
#### **--mtmd**=*BOOL*
Enable or disable multimodal support.
If enabled and a multimodal projector file is detected, `--mmproj` is
added to the llama-server command-line.
When omitted, multimodal support is automatically detected.

[//]: # (END included file options/mtmd.md)


[//]: # (BEGIN included file options/name.md)
#### **--name**, **-n**
Name of the container to run the Model in.
Expand Down
2 changes: 2 additions & 0 deletions docs/ramalama-sandbox-pi.1.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Otherwise only the agent container starts using the given url for the openai com

@@option models-max

@@option mtmd

@@option name

@@option ncmoe
Expand Down
10 changes: 10 additions & 0 deletions docs/ramalama-serve.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ Only used when invoked in router mode (zero or multiple models).
[//]: # (END included file options/models-max.md)


[//]: # (BEGIN included file options/mtmd.md)
#### **--mtmd**=*BOOL*
Enable or disable multimodal support.
If enabled and a multimodal projector file is detected, `--mmproj` is
added to the llama-server command-line.
When omitted, multimodal support is automatically detected.

[//]: # (END included file options/mtmd.md)


[//]: # (BEGIN included file options/name.md)
#### **--name**, **-n**
Name of the container to run the Model in.
Expand Down
2 changes: 2 additions & 0 deletions docs/ramalama-serve.1.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ appending the path to the type, e.g. `--generate kube:/etc/containers/systemd`.

@@option models-max

@@option mtmd

@@option name

@@option ncmoe
Expand Down
9 changes: 9 additions & 0 deletions ramalama/plugins/runtimes/inference/llama_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class LlamaCppConfig:
backend: Literal["auto", "vulkan", "rocm", "cuda", "sycl", "openvino", "cann", "musa"] = "auto"
cache_reuse: Optional[int] = None
gguf_quantization_mode: GGUF_QUANTIZATION_MODES = DEFAULT_GGUF_QUANTIZATION_MODE # type: ignore[assignment]
mtmd: Optional[bool] = None
ngl: Optional[str] = None
ncmoe: Optional[int] = None
spec_type: Optional[str] = None
Expand Down Expand Up @@ -116,6 +117,8 @@ def __post_init__(self):
self.threads = int(self.threads)
if self.thinking is not None:
self.thinking = coerce_to_bool(self.thinking)
if self.mtmd is not None:
self.mtmd = coerce_to_bool(self.mtmd)


def _positive_int(value: str) -> int:
Expand Down Expand Up @@ -506,6 +509,12 @@ def _add_inference_args(self, parser: "argparse.ArgumentParser", command: str) -
help="min speculative decoding probability (default: 0.0)",
completer=suppressCompleter,
)
parser.add_argument(
"--mtmd",
default=None,
Comment thread
ueno marked this conversation as resolved.
help="enable/disable multimodal mode (default: on)",
action=CoerceToBool,
)
self._add_threads_arg(parser)
if command == "serve":
parser.add_argument(
Expand Down
3 changes: 2 additions & 1 deletion ramalama/plugins/runtimes/inference/llama_cpp_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def _cmd_run(self, args: argparse.Namespace) -> list[str]:
model_path = model._get_entry_model_path(is_container, should_generate, dry_run)
cmd += ["--model", model_path]

mmproj_path = model._get_mmproj_path(is_container, should_generate, dry_run)
mtmd = getattr(args, 'mtmd', None)
mmproj_path = model._get_mmproj_path(is_container, should_generate, dry_run) if mtmd is not False else None
if mmproj_path:
cmd += ["--mmproj", str(mmproj_path)]

Expand Down
47 changes: 47 additions & 0 deletions test/unit/test_inference_engine_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def make_ns(
spec_draft_n_max=None,
spec_draft_n_min=None,
spec_draft_p_min=None,
mtmd=None,
runtime_args=None,
engine_args=None,
gguf=None,
Expand Down Expand Up @@ -80,6 +81,7 @@ def make_ns(
spec_draft_n_max=spec_draft_n_max,
spec_draft_n_min=spec_draft_n_min,
spec_draft_p_min=spec_draft_p_min,
mtmd=mtmd,
runtime_args=runtime_args or [],
engine_args=engine_args or [],
gguf=gguf,
Expand Down Expand Up @@ -159,6 +161,7 @@ def test_defaults(self):
assert config.temp == 0.8
assert config.thinking is None
assert config.threads > 0
assert config.mtmd is None

def test_coerces_string_values(self):
config = LlamaCppConfig(ngl="4", ncmoe="128", cache_reuse="512", temp="0.5", threads="8", thinking="false")
Expand Down Expand Up @@ -338,6 +341,50 @@ def test_serve_thinking_default(self, mock_colorize):

assert "--reasoning" not in cmd

@patch("ramalama.plugins.runtimes.inference.llama_cpp_commands.New")
@patch("ramalama.plugins.runtimes.inference.llama_cpp_commands.should_colorize", return_value=False)
def test_serve_mtmd_disabled(self, mock_colorize, mock_new):
mock_model = make_transport_model(mmproj_path="/mnt/models/mmproj.file")
mock_new.return_value = mock_model

ns = make_ns(MODEL="ollama://mymodel", mtmd=False)
cmd = self.plugin.handle_subcommand("serve", ns)

assert "--mmproj" not in cmd

@patch("ramalama.plugins.runtimes.inference.llama_cpp_commands.New")
@patch("ramalama.plugins.runtimes.inference.llama_cpp_commands.should_colorize", return_value=False)
def test_serve_mtmd_enabled(self, mock_colorize, mock_new):
mock_model = make_transport_model(mmproj_path="/mnt/models/mmproj.file")
mock_new.return_value = mock_model

ns = make_ns(MODEL="ollama://mymodel", mtmd=True)
cmd = self.plugin.handle_subcommand("serve", ns)

assert "--mmproj" in cmd

@patch("ramalama.plugins.runtimes.inference.llama_cpp_commands.New")
@patch("ramalama.plugins.runtimes.inference.llama_cpp_commands.should_colorize", return_value=False)
def test_serve_mtmd_enabled_without_mmproj(self, mock_colorize, mock_new):
mock_model = make_transport_model(mmproj_path=None)
mock_new.return_value = mock_model

ns = make_ns(MODEL="ollama://mymodel", mtmd=True)
cmd = self.plugin.handle_subcommand("serve", ns)

assert "--mmproj" not in cmd

@patch("ramalama.plugins.runtimes.inference.llama_cpp_commands.New")
@patch("ramalama.plugins.runtimes.inference.llama_cpp_commands.should_colorize", return_value=False)
def test_serve_mtmd_default(self, mock_colorize, mock_new):
mock_model = make_transport_model(mmproj_path="/mnt/models/mmproj.file")
mock_new.return_value = mock_model

ns = make_ns(MODEL="ollama://mymodel", mtmd=None)
cmd = self.plugin.handle_subcommand("serve", ns)

assert "--mmproj" in cmd

@patch("ramalama.plugins.runtimes.inference.llama_cpp_commands.should_colorize", return_value=False)
def test_serve_ctx_size(self, mock_colorize):
ns = make_ns(ctx_size=4096)
Expand Down
Loading