{"record":{"id":"ae78b86992f8df42","repo":"invoke-ai/InvokeAI","slug":"failed-to-load-all-parameters-from-sdnq-the-follo","errorCode":null,"errorMessage":"Failed to load all parameters from SDNQ. The following remain as meta tensors: {meta_names}.","messagePattern":"Failed to load all parameters from SDNQ\\. The following remain as meta tensors: (.+?)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"invokeai/backend/model_manager/load/model_loaders/z_image.py","lineNumber":1626,"sourceCode":"                if len(parts) == 2:\n                    parent = model.get_submodule(parts[0])\n                    buffer_name = parts[1]\n                else:\n                    parent = model\n                    buffer_name = name\n\n                if buffer_name == \"inv_freq\":\n                    base = qwen_config.rope_theta\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 SDNQ. The following remain as meta tensors: {meta_names}.\"\n            )\n\n        return model\n","sourceCodeStart":1608,"sourceCodeEnd":1631,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/z_image.py#L1608-L1631","documentation":"Raised at the end of the SDNQ Z-Image Qwen3 encoder load path (_load_from_sdnq) when, after load_state_dict with assign=True, tied-weight handling, and meta-buffer re-initialization, model.named_parameters() still contains torch meta tensors. It means the SDNQ checkpoint did not supply materialized weights for every parameter the freshly-initialized Qwen3ForCausalLM declares, so the model would be unusable on device. The loader fails fast rather than producing a model with missing weights.","triggerScenarios":"Loading an SDNQ-quantized Z-Image text-encoder checkpoint whose state dict is missing required parameters (other than the allowed lm_head.weight), or contains keys from an incompatible/contaminated SDNQ export that don't match Qwen3ForCausalLM's expected names; also when load_state_dict(assign=True) leaves parameters unassigned because names/shapes mismatch.","commonSituations":"Using an SDNQ export of the wrong architecture or a partially-converted checkpoint; a library/transformers version where Qwen3 parameter names changed; hand-trimmed or re-saved quantized files that dropped tensors; mismatches between the config's num_hidden_layers/vocab_size and the checkpoint contents.","solutions":["Re-download the SDNQ checkpoint from its official source; the file is likely truncated or from an incompatible export.","Check the meta_names list in the message and compare against the checkpoint's keys (safetensors header / gguf listing) to find which tensors are missing or renamed.","Verify the transformers/accelerate versions match what the model card requires, since Qwen3 parameter names can shift between versions.","If you re-saved the quantized file, redo the conversion so all parameters are written; lm_head.weight is the only acceptable omission (tied weights).","Regenerate the model with the correct Qwen3Config (layer count, vocab size) matching the checkpoint."],"exampleFix":"// before\nmodel = Qwen3ForCausalLM(wrong_config)  # e.g. vocab_size from a different tokenizer\nmissing, unexpected = model.load_state_dict(sd, strict=False, assign=True)\n// after\nmodel = Qwen3ForCausalLM(qwen_config_built_from_checkpoint)  # sizes derived from the SDNQ sd\nmissing, unexpected = model.load_state_dict(sd, strict=False, assign=True)\nraise_on_incomplete_sdnq_load('SDNQ Qwen3 encoder', missing, unexpected, allowed_missing={'lm_head.weight'})","handlingStrategy":"validation","validationCode":"import torch\n\ndef assert_no_meta_params(model: torch.nn.Module) -> None:\n    meta = [n for n, p in model.named_parameters() if p.is_meta]\n    if meta:\n        raise RuntimeError(f'Missing weights for: {meta}')","typeGuard":"def has_meta_params(model: torch.nn.Module) -> bool:\n    return any(p.is_meta for _, p in model.named_parameters())","tryCatchPattern":"try:\n    model = loader._load_from_sdnq(...)\nexcept RuntimeError as e:\n    if 'remain as meta tensors' in str(e):\n        logger.error(f'SDNQ checkpoint incomplete: {e}. Re-download the model file.')\n        raise\n    raise","preventionTips":["Download SDNQ checkpoints only from official sources and verify file hashes","Keep transformers/accelerate versions aligned with the model card requirements","Never hand-edit or partially re-save quantized checkpoints","Compare checkpoint keys against expected Qwen3 parameter names before loading"],"tags":["model-loading","sdnq","quantization","meta-tensor","runtime"],"backgroundTag":"unloaded-model-weights-meta-tensor","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}