[GH-ISSUE #11615] GEMMA3N Using matformer, must set intermediate_size of type array #33430

Open
opened 2026-04-22 16:05:06 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @xValentim on GitHub (Jul 31, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/11615

What is the issue?

If you customize the model that use matformer architecture, ollama import models crashes. It happens because in gemma3n model architecture we recieve this:

type gemma3nModel struct {
	ModelParameters

	TextModel struct {
		ActivationSparsityPattern []float32 `json:"activation_sparsity_pattern"`
		AltupActiveIdx            uint32    `json:"altup_active_idx"`
		AltupCoefClip             float32   `json:"altup_coef_clip"`
		AltupCorrectScale         bool      `json:"altup_correct_scale"`
		AltupLRMultiplier         float32   `json:"altup_lr_multiplier"`
		AltupNumInputs            uint32    `json:"altup_num_inputs"`
		HeadDim                   uint32    `json:"head_dim"`
		HiddenSize                uint32    `json:"hidden_size"`
		HiddenSizePerLayerInput   uint32    `json:"hidden_size_per_layer_input"`
		IntermediateSize          uint32    `json:"intermediate_size"`
		MaxPositionEmbeddings     uint32    `json:"max_position_embeddings"`
		NumAttentionHeads         uint32    `json:"num_attention_heads"`
		NumHiddenLayers           uint32    `json:"num_hidden_layers"`
		NumKeyValueHeads          uint32    `json:"num_key_value_heads"`
		NumKVSharedLayers         uint32    `json:"num_kv_shared_layers"`
		RMSNormEPS                float32   `json:"rms_norm_eps"`
		RopeLocalBaseFreq         float32   `json:"rope_local_base_freq"`
		RopeTheta                 float32   `json:"rope_theta"`
		SlidingWindow             uint32    `json:"sliding_window"`
		LayerTypes                []string  `json:"layer_types"`
	} `json:"text_config"`
	VisionModel struct{} `json:"vision_config"`
}

And, if you customize your matformer model, your config.json will be like this:

...
"hidden_activation": "gelu_pytorch_tanh",
    "hidden_size": 2048,
    "hidden_size_per_layer_input": 256,
    "initializer_range": 0.02,
    "intermediate_size": [
      8192,
      8192,
      8192,
      8192,
      8192,
      8192,
      8192,
      8192,
      8192,
      8192,
      16384,
      16384,
      16384,
      16384,
      16384,
      16384,
      16384,
      16384,
      16384,
      16384,
      16384,
      16384,
      16384,
      16384,
      16384,
      8192,
      8192,
      8192,
      8192,
      8192,
      8192,
      8192,
      8192,
      8192,
      8192
    ],
    "laurel_rank": 64,
    "layer_types": [
      "sliding_attention",
      "sliding_attention",
      "sliding_attention",
...

Someone can help me? I tried to run dev mode using go run . serve, but I have many errors.

Relevant log output

ollama create gemma3n-sliced -f Modelfile
gathering model components
copying file sha256:28db4662fe863787861c87bc89ed212b552062819ca0e6fe1723af84de1417ac 100%
copying file sha256:b6c35ee648c07754b44cd9e371c75d4caa05c4504910b7ad29b1847ee9d8ba5d 100%
copying file sha256:9e5d11c5125889bdeca6b91a95359f2dfb578bd147198f3c5ed08870e6155cba 100%
copying file sha256:7d792604c9b2e9796f432bcbb073c4798d5fd0d6dbc69dc3d3eeee955225d4db 100%
copying file sha256:5a630a1f95ef9f8e49ebc8ed5b7aeb1bbd86c695ca5af439ae07187ee5b52fc8 100%
copying file sha256:648419887a29e74bcc9eb6b111734e1bfb569fe4df6ee81c95ee7d6c7864d448 100%
copying file sha256:8521a807b78a86c80140be868c8fab67584c13b7070bdae2e4dd475cfbdc105e 100%
copying file sha256:8d52220a251a5ae826d89741237bd30ede0bd3df398b1f1d7939ad8ac3e39c08 100%
converting model
Error: json: cannot unmarshal array into Go struct field .text_config.intermediate_size of type uint32

OS

Windows

GPU

Nvidia

CPU

Intel

Ollama version

No response

Originally created by @xValentim on GitHub (Jul 31, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/11615 ### What is the issue? If you customize the model that use matformer architecture, ollama import models crashes. It happens because in gemma3n model architecture we recieve this: ```go type gemma3nModel struct { ModelParameters TextModel struct { ActivationSparsityPattern []float32 `json:"activation_sparsity_pattern"` AltupActiveIdx uint32 `json:"altup_active_idx"` AltupCoefClip float32 `json:"altup_coef_clip"` AltupCorrectScale bool `json:"altup_correct_scale"` AltupLRMultiplier float32 `json:"altup_lr_multiplier"` AltupNumInputs uint32 `json:"altup_num_inputs"` HeadDim uint32 `json:"head_dim"` HiddenSize uint32 `json:"hidden_size"` HiddenSizePerLayerInput uint32 `json:"hidden_size_per_layer_input"` IntermediateSize uint32 `json:"intermediate_size"` MaxPositionEmbeddings uint32 `json:"max_position_embeddings"` NumAttentionHeads uint32 `json:"num_attention_heads"` NumHiddenLayers uint32 `json:"num_hidden_layers"` NumKeyValueHeads uint32 `json:"num_key_value_heads"` NumKVSharedLayers uint32 `json:"num_kv_shared_layers"` RMSNormEPS float32 `json:"rms_norm_eps"` RopeLocalBaseFreq float32 `json:"rope_local_base_freq"` RopeTheta float32 `json:"rope_theta"` SlidingWindow uint32 `json:"sliding_window"` LayerTypes []string `json:"layer_types"` } `json:"text_config"` VisionModel struct{} `json:"vision_config"` } ``` And, if you customize your matformer model, your config.json will be like this: ```json ... "hidden_activation": "gelu_pytorch_tanh", "hidden_size": 2048, "hidden_size_per_layer_input": 256, "initializer_range": 0.02, "intermediate_size": [ 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192 ], "laurel_rank": 64, "layer_types": [ "sliding_attention", "sliding_attention", "sliding_attention", ... ``` Someone can help me? I tried to run dev mode using `go run . serve`, but I have many errors. ### Relevant log output ```shell ollama create gemma3n-sliced -f Modelfile gathering model components copying file sha256:28db4662fe863787861c87bc89ed212b552062819ca0e6fe1723af84de1417ac 100% copying file sha256:b6c35ee648c07754b44cd9e371c75d4caa05c4504910b7ad29b1847ee9d8ba5d 100% copying file sha256:9e5d11c5125889bdeca6b91a95359f2dfb578bd147198f3c5ed08870e6155cba 100% copying file sha256:7d792604c9b2e9796f432bcbb073c4798d5fd0d6dbc69dc3d3eeee955225d4db 100% copying file sha256:5a630a1f95ef9f8e49ebc8ed5b7aeb1bbd86c695ca5af439ae07187ee5b52fc8 100% copying file sha256:648419887a29e74bcc9eb6b111734e1bfb569fe4df6ee81c95ee7d6c7864d448 100% copying file sha256:8521a807b78a86c80140be868c8fab67584c13b7070bdae2e4dd475cfbdc105e 100% copying file sha256:8d52220a251a5ae826d89741237bd30ede0bd3df398b1f1d7939ad8ac3e39c08 100% converting model Error: json: cannot unmarshal array into Go struct field .text_config.intermediate_size of type uint32 ``` ### OS Windows ### GPU Nvidia ### CPU Intel ### Ollama version _No response_
GiteaMirror added the bug label 2026-04-22 16:05:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#33430