Description
Loading a gemma4 (Google Gemma 4, e.g. gemma4:e4b) architecture GGUF via the
cuda13-llama-cpp backend fails to load, with the backend process crashing
(exitCode -1) after emitting a tensor-count mismatch from llama.cpp's loader.
This blocks migrating any Ollama-served gemma4-family model onto LocalAI's
llama-cpp backend, since llama.cpp itself is where the incompatibility lives (see
"Root cause" below) — LocalAI is just the messenger here, but the crash-on-load
behavior (full backend process death instead of a clean load-time model
validation error) is a LocalAI/backend robustness gap worth tracking regardless
of when upstream llama.cpp lands full gemma4 support.
LocalAI version
v4.8.2 (5ff25d9), running via Docker image
localai/localai:latest-gpu-nvidia-cuda-13.
Backend: cuda13-llama-cpp, installed today via the gallery from
quay.io/go-skynet/local-ai-backends:latest-gpu-nvidia-cuda-13-llama-cpp
(digest sha256:389b92f825136696f85c548b9dcda65c87a224261d15f0089772dd1d40d5fda0).
Environment
- Docker container
localai/localai:latest-gpu-nvidia-cuda-13, --gpus all,
NVIDIA RTX 5080, nvidia-container-toolkit GPU passthrough verified working
(other models — a llama-3.2-1b test model and a Qwen3.6-35B-A3B MoE model —
load and infer correctly on this same instance via the same cuda13-llama-cpp
backend).
- Host: Linux x86_64.
Model / GGUF
general.architecture (read directly from GGUF header): gemma4
- GGUF header:
tensor_count = 2131, kv_count = 55, GGUF version 3
- This is the exact GGUF blob Ollama 0.32.6 ships/uses for its
gemma4:e4b tag
(extracted byte-identical, sha256-verified, directly from Ollama's own blob
store — same file Ollama's own bundled llama-server process currently loads
and serves successfully with --no-jinja --chat-template chatml).
- Quant: Q4_K_M, ~9.6GB file size, ~8.19B params.
Steps to reproduce
- Place the GGUF under LocalAI's models directory.
- Model YAML:
name: gemma4-e4b
backend: cuda13-llama-cpp
f16: true
mmap: true
context_size: 4096
parameters:
model: gemma4-e4b-q4_k_m.gguf
options:
- jinja
POST /v1/chat/completions with "model": "gemma4-e4b".
Expected behavior
Either the model loads and serves a completion, or LocalAI returns a clean
"unsupported architecture" error without killing the backend process.
Actual behavior
Backend process crashes immediately on load attempt (exitCode -1), and the API
returns a 500 with this llama.cpp loader error:
Failed to load model: /models/gemma4-e4b-q4_k_m.gguf. Error: llama_model_load:
error loading model: done_getting_tensors: wrong number of tensors; expected
2131, got 720; llama_model_load_from_file_impl: failed to load model;
llama_model_load: error loading model: done_getting_tensors: wrong number of
tensors; expected 2131, got 720; llama_model_load_from_file_impl: failed to
load model
Full log excerpt:
INFO BackendLoader starting modelID=gemma4-e4b backend=cuda13-llama-cpp model=gemma4-e4b-q4_k_m.gguf
INFO effective runtime tuning ... context=4096 n_batch=2048 n_gpu_layers=99999999 parallel=1 flash_attention=auto f16=true
WARN Backend process exited unexpectedly id=gemma4-e4b address=127.0.0.1:34875 process=run.sh exitCode=-1
ERROR Failed to load model modelID=gemma4-e4b error=failed to load model with internal loader: could not load model: rpc error: code = Internal desc = Failed to load model: ... (as above)
Root cause (as best I can tell)
The bundled llama.cpp in this backend build only partially recognizes the
gemma4 GGUF architecture — it maps 720 of the declared 2131 tensors before
giving up, rather than either fully supporting the architecture or cleanly
rejecting it up front. This tracks with upstream ggml-org/llama.cpp gemma4
support still being in active flux — several open issues/PRs there reference
gemma4-family loading/eval problems, e.g.:
None of those match this exact "wrong number of tensors; expected 2131, got
720" symptom, so this looks like a distinct manifestation of the same
underlying "gemma4 architecture support isn't finished in llama.cpp yet" gap,
surfaced through LocalAI's bundled backend.
Ask
- If this is purely an upstream llama.cpp support gap, it'd help to have that
stated/tracked here (e.g. a pointer to which llama.cpp PR/milestone brings
full gemma4 tensor support) so downstream LocalAI users know when to
retry.
- Separately: LocalAI/the backend should not let this crash the whole backend
process — a clean "unsupported architecture" load-time error (instead of
exitCode -1 process death class of failure) would make this kind of gap
much easier to diagnose from the API side alone, without digging through
container logs.
Happy to provide the full GGUF metadata dump or test further builds if useful.
Description
Loading a
gemma4(Google Gemma 4, e.g.gemma4:e4b) architecture GGUF via thecuda13-llama-cppbackend fails to load, with the backend process crashing(
exitCode -1) after emitting a tensor-count mismatch from llama.cpp's loader.This blocks migrating any Ollama-served
gemma4-family model onto LocalAI'sllama-cpp backend, since llama.cpp itself is where the incompatibility lives (see
"Root cause" below) — LocalAI is just the messenger here, but the crash-on-load
behavior (full backend process death instead of a clean load-time model
validation error) is a LocalAI/backend robustness gap worth tracking regardless
of when upstream llama.cpp lands full gemma4 support.
LocalAI version
v4.8.2 (5ff25d9), running via Docker image
localai/localai:latest-gpu-nvidia-cuda-13.Backend:
cuda13-llama-cpp, installed today via the gallery fromquay.io/go-skynet/local-ai-backends:latest-gpu-nvidia-cuda-13-llama-cpp(digest
sha256:389b92f825136696f85c548b9dcda65c87a224261d15f0089772dd1d40d5fda0).Environment
localai/localai:latest-gpu-nvidia-cuda-13,--gpus all,NVIDIA RTX 5080,
nvidia-container-toolkitGPU passthrough verified working(other models — a llama-3.2-1b test model and a Qwen3.6-35B-A3B MoE model —
load and infer correctly on this same instance via the same
cuda13-llama-cppbackend).
Model / GGUF
general.architecture(read directly from GGUF header):gemma4tensor_count = 2131,kv_count = 55, GGUF version 3gemma4:e4btag(extracted byte-identical, sha256-verified, directly from Ollama's own blob
store — same file Ollama's own bundled llama-server process currently loads
and serves successfully with
--no-jinja --chat-template chatml).Steps to reproduce
POST /v1/chat/completionswith"model": "gemma4-e4b".Expected behavior
Either the model loads and serves a completion, or LocalAI returns a clean
"unsupported architecture" error without killing the backend process.
Actual behavior
Backend process crashes immediately on load attempt (
exitCode -1), and the APIreturns a 500 with this llama.cpp loader error:
Full log excerpt:
Root cause (as best I can tell)
The bundled llama.cpp in this backend build only partially recognizes the
gemma4GGUF architecture — it maps 720 of the declared 2131 tensors beforegiving up, rather than either fully supporting the architecture or cleanly
rejecting it up front. This tracks with upstream
ggml-org/llama.cppgemma4support still being in active flux — several open issues/PRs there reference
gemma4-family loading/eval problems, e.g.:
gemma4-style model")
type detection", still open)
Gemma4", still open)
None of those match this exact "wrong number of tensors; expected 2131, got
720" symptom, so this looks like a distinct manifestation of the same
underlying "gemma4 architecture support isn't finished in llama.cpp yet" gap,
surfaced through LocalAI's bundled backend.
Ask
stated/tracked here (e.g. a pointer to which llama.cpp PR/milestone brings
full
gemma4tensor support) so downstream LocalAI users know when toretry.
process — a clean "unsupported architecture" load-time error (instead of
exitCode -1process death class of failure) would make this kind of gapmuch easier to diagnose from the API side alone, without digging through
container logs.
Happy to provide the full GGUF metadata dump or test further builds if useful.