{"record":{"id":"9186c749cafc4ce8","repo":"invoke-ai/InvokeAI","slug":"failed-to-load-all-parameters-from-gguf-the-follo","errorCode":null,"errorMessage":"Failed to load all parameters from GGUF. The following remain as meta tensors: {meta_names}. This may indicate missing keys in the GGUF file or a key mapping issue.","messagePattern":"Failed to load all parameters from GGUF\\. The following remain as meta tensors: (.+?)\\. This may indicate missing keys in the GGUF file or a key mapping issue\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"invokeai/backend/model_manager/load/model_loaders/z_image.py","lineNumber":1370,"sourceCode":"                if buffer_name == \"inv_freq\":\n                    # Compute inv_freq from config - keep on CPU, cache system will move to GPU as needed\n                    # NB: transformers 5.x moved rope_theta into the rope_parameters/rope_scaling dict\n                    rope_params = (\n                        getattr(qwen_config, \"rope_parameters\", None)\n                        or getattr(qwen_config, \"rope_scaling\", None)\n                        or {}\n                    )\n                    base = rope_params.get(\"rope_theta\") or getattr(qwen_config, \"rope_theta\", 1000000.0)\n                    inv_freq = 1.0 / (base ** (torch.arange(0, head_dim, 2, dtype=torch.float32) / head_dim))\n                    parent.register_buffer(buffer_name, inv_freq.to(dtype=compute_dtype), persistent=False)\n                else:\n                    logger.warning(f\"Re-initializing unknown meta buffer: {name}\")\n\n        # Final check: ensure no meta tensors remain in parameters\n        meta_params = [(name, p) for name, p in model.named_parameters() if p.is_meta]\n        if meta_params:\n            meta_names = [name for name, _ in meta_params]\n            raise RuntimeError(\n                f\"Failed to load all parameters from GGUF. The following remain as meta tensors: {meta_names}. \"\n                \"This may indicate missing keys in the GGUF file or a key mapping issue.\"\n            )\n\n        return model\n\n    def _convert_llamacpp_to_pytorch(self, sd: dict[str, Any]) -> dict[str, Any]:\n        \"\"\"Convert llama.cpp GGUF keys to PyTorch/HuggingFace format for Qwen models.\n\n        llama.cpp format:\n        - blk.X.attn_q.weight -> model.layers.X.self_attn.q_proj.weight\n        - blk.X.attn_k.weight -> model.layers.X.self_attn.k_proj.weight\n        - blk.X.attn_v.weight -> model.layers.X.self_attn.v_proj.weight\n        - blk.X.attn_output.weight -> model.layers.X.self_attn.o_proj.weight\n        - blk.X.attn_q_norm.weight -> model.layers.X.self_attn.q_norm.weight (Qwen3 QK norm)\n        - blk.X.attn_k_norm.weight -> model.layers.X.self_attn.k_norm.weight (Qwen3 QK norm)\n        - blk.X.ffn_gate.weight -> model.layers.X.mlp.gate_proj.weight\n        - blk.X.ffn_up.weight -> model.layers.X.mlp.up_proj.weight","sourceCodeStart":1352,"sourceCodeEnd":1388,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/z_image.py#L1352-L1388","documentation":"After instantiating the model on the meta device and loading GGUF tensors, the loader checks named_parameters() for any parameter still on the meta device. Meta parameters mean assign_* never populated them — the GGUF file lacks corresponding keys or the model's key mapping doesn't match the file, so silently re-initialized meta buffers were warned but some params remained unassigned.","triggerScenarios":"_load_from_gguf: the GGUF file is missing tensors that the module tree expects (truncated download), key names differ from what the model expects (prefix mismatch, renamed layers), or quantized tensor types unsupported so assignment was skipped.","commonSituations":"Partial GGUF download; GGUF produced for a slightly different architecture revision than the loader's model class; custom quant formats not covered by the dequant path.","solutions":["Re-download the complete GGUF and compare tensor count/names against what the loader expects.","Check the first warning lines ('Re-initializing unknown meta buffer') — the names listed indicate which keys mismatch; remap or re-export the GGUF accordingly.","Update InvokeAI (and its z_image model definition) so the module tree matches your GGUF revision.","Fall back to the safetensors checkpoint if the GGUF was converted from an incompatible architecture version."],"exampleFix":"// before: GGUF missing layer tensors\nmeta_params: ['model.layers.5.self_attn.q_proj.weight', ...]\n// after: complete file\ngguf-dump shows all model.layers.* tensors; load succeeds","handlingStrategy":"try-catch","validationCode":"# pre-check: GGUF tensor count vs expected model parameter count\ntensor_count = len(gguf.GGUFReader(path).tensors)\nexpected = count_expected_qwen3_encoder_tensors()\nif tensor_count < expected:\n    raise ValueError(f\"GGUF {path} looks truncated: {tensor_count}/{expected} tensors\")","typeGuard":"def gguf_covers_model(path: str, model_keys: set[str]) -> bool:\n    names = {t.name for t in gguf.GGUFReader(path).tensors}\n    return all(k in names for k in model_keys)","tryCatchPattern":"try:\n    model = load_text_encoder(cfg)\nexcept RuntimeError as e:\n    if \"remain as meta tensors\" in str(e):\n        # meta names in the message identify the missing/mismatched keys\n        repair_or_redownload_gguf(cfg.path, missing_hint=str(e))\n    else:\n        raise","preventionTips":["Watch for the loader's earlier 'Re-initializing unknown meta buffer' warnings — treat them as red flags.","Re-download truncated GGUFs and verify hashes.","Keep InvokeAI and converted models from the same architecture revision.","Prefer official GGUF releases over ad-hoc conversions."],"tags":["gguf","model-loading","meta-tensor","missing-tensor"],"backgroundTag":"unloaded-meta-tensors","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}