Skip to content

fix(llamacpp): use --load-mode for llama.cpp v1.0.0 on macOS and Windows - #1116

Merged
ilopezluna merged 2 commits into
mainfrom
fix/llamacpp-v1-load-mode
Nov 23, 2026
Merged

ilopezluna merged 2 commits into
mainfrom
fix/llamacpp-v1-load-mode

Conversation

@ilopezluna

@ilopezluna ilopezluna commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

llama.cpp v1.0.0 replaced --mmap, --no-mmap, --mlock, -dio/--direct-io and -ndio/--no-direct-io with -lm/--load-mode and exits on the old flags. model-runner always passes --no-mmap on macOS, so with the new docker/docker-model-backend-llamacpp:v1.0.0 image every model load on Docker Desktop for Mac fails:

llama.cpp failed: error: invalid argument: --no-mmap

Changes:

  • macOS: drop the --no-mmap default argument and set LLAMA_ARG_LOAD_MODE=none and LLAMA_ARG_MMAP=false in the server environment. v1.0.0 reads the first, older builds read the second, so overriding the server version to an older build (--llama-server-version b9879) keeps working.
  • Runtime flags allowlist: add -lm/--load-mode and drop the removed flags, so users get a validation error instead of a crash.
  • pinnedServerVersion: b9879 → v1.0.0, matching the Linux image pinned in fix(llamacpp): pin stable v1.0.0 with JSON nesting fixes #1113. The v1.0.0-{cpu,cuda,opencl,metal} images are published on Hub.

Validation

  • go test -race ./pkg/inference/... ./pkg/server/... and golangci-lint pass on Linux; the darwin branch is covered by macOS CI.
  • Reproduced the failure on Docker Desktop for Mac with docker model install-runner --backend llama.cpp --llama-server-version v1.0.0. The fix itself still needs a Desktop build with this model-runner to verify end to end.

🤖 Generated with Claude Code

llama.cpp v1.0.0 replaced --mmap, --no-mmap, --mlock and --direct-io
with --load-mode and exits on the old flags. macOS always passed
--no-mmap, so every model load failed. Pass --load-mode none instead,
allow --load-mode in runtime flags, drop the removed flags, and pin the
Desktop download to v1.0.0 to match the Linux image.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@sourcery-ai sourcery-ai 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.

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="pkg/inference/backends/llamacpp/llamacpp_config.go" line_range="26" />
<code_context>
 	// Special case for macOS (Apple), optimization
 	if runtime.GOOS == "darwin" {
-		args = append(args, "--no-mmap")
+		args = append(args, "--load-mode", "none")
 	}

</code_context>
<issue_to_address>
**Older server overrides fail**

When a user selects a pre-v1.0.0 server version, `NewDefaultLlamaCppConfig` adds `--load-mode none`, which older servers reject, while `ValidateRuntimeFlags` rejects legacy flags those servers support. The server cannot load models with the macOS default, and callers cannot use supported legacy flags.

Choose the macOS argument and validate runtime flags according to the selected server version.

Also at `pkg/inference/runtime_flags_allowlist.go:78-81`.
</issue_to_address>

### Comment 2
<location path="pkg/inference/backends/llamacpp/download.go" line_range="36" />
<code_context>
 	// is upgraded, so all platforms ship a consistent, tested build. Users can
 	// override it via LLAMA_SERVER_VERSION or `--llama-server-version`.
-	pinnedServerVersion = "b9879"
+	pinnedServerVersion = "v1.0.0"
 )

</code_context>
<issue_to_address>
**Failed upgrades remove working server**

When an existing installation is upgraded and a filesystem operation fails after the old directories are removed, `downloadLatestLlamaCpp` removes the existing installation before preparing the replacement, so a later filesystem failure leaves the backend without a working server.

Prepare the replacement separately and preserve the existing installation until the replacement is ready to take its place.
</issue_to_address>

### Comment 3
<location path="pkg/inference/runtime_flags_allowlist.go" line_range="78" />
<code_context>
-	"--mmap":  true, "--no-mmap": true,
-	"-dio": true, "--direct-io": true,
-	"-ndio": true, "--no-direct-io": true,
+	"-lm": true, "--load-mode": true,
 	"-cram": true, "--cache-ram": true,
 	"-kvu": true, "--kv-unified": true,
</code_context>
<issue_to_address>
**Legacy environment flags still crash**

When a deployment's `LLAMA_ARGS` still contains a flag removed in llama.cpp v1.0.0, `LLAMA_ARGS` bypasses `ValidateRuntimeFlags`, so a configured removed flag such as `--no-mmap` reaches the v1.0.0 server, which exits on it and causes model loads to fail instead of returning a validation error.

Validate `LLAMA_ARGS` against the current llama.cpp flag allowlist or explicitly reject the removed flags before accepting the environment config.
</issue_to_address>

### Comment 4
<location path="pkg/inference/backends/llamacpp/download.go" line_range="36" />
<code_context>
 	// is upgraded, so all platforms ship a consistent, tested build. Users can
 	// override it via LLAMA_SERVER_VERSION or `--llama-server-version`.
-	pinnedServerVersion = "b9879"
+	pinnedServerVersion = "v1.0.0"
 )

</code_context>
<issue_to_address>
**Platform builds use different pins**

When the `v1.0.0` Hub images resolve to a different upstream build than the Linux pin, macOS and Windows resolve the `v1.0.0` Hub tags, while Linux is built from `v1.0.0-b12359-b1b770d`; that does not ensure the same llama.cpp build across platforms as the description claims.

Use and publish a deferred-download tag matching the Linux build, or document that the platform builds are not identical.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

An explicit --load-mode argument breaks when users override the server
version to a build older than v1.0.0, which rejects the flag. Set
LLAMA_ARG_LOAD_MODE and LLAMA_ARG_MMAP instead; each llama.cpp version
reads its own variable and ignores the other.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ilopezluna
ilopezluna merged commit bca21ba into main Nov 23, 2026
14 checks passed
@ilopezluna
ilopezluna deleted the fix/llamacpp-v1-load-mode branch November 23, 2026 11:04
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.

2 participants