{"record":{"id":"f200a9913e6ebda7","repo":"sgl-project/sglang","slug":"some-weights-are-not-initialized-from-checkpoints","errorCode":null,"errorMessage":"Some weights are not initialized from checkpoints: {unloaded_params}","messagePattern":"Some weights are not initialized from checkpoints: (.+?)","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/models/deepseek_ocr.py","lineNumber":1887,"sourceCode":"                weight_loader = param.weight_loader\n                weight_loader(param, loaded_weight, shard_id)\n                break\n            else:\n                # Skip loading extra bias for GPTQ models.\n                if name.endswith(\".bias\") and name not in params_dict:\n                    continue\n                # Skip experts that are not assigned to this worker.\n                if (\n                    \"mlp.experts.\" in name or \"mlp.shared_experts.\" in name\n                ) and name not in params_dict:\n                    continue\n                param = params_dict[name]\n                weight_loader = getattr(param, \"weight_loader\", default_weight_loader)\n                weight_loader(param, loaded_weight)\n            loaded_params.add(name)\n        unloaded_params = params_dict.keys() - loaded_params\n        if unloaded_params:\n            raise RuntimeError(\n                f\"Some weights are not initialized from checkpoints: {unloaded_params}\"\n            )\n        self.post_load_weights()\n\n    def post_load_weights(self):\n        if _is_cpu and _is_cpu_amx_available:\n            from sglang.srt.layers.amx_utils import _amx_process_weight_after_loading\n\n            layer_ids = int(self.config.num_hidden_layers)\n            first_k_dense_replace_id = (\n                self.config.first_k_dense_replace\n                if hasattr(self.config, \"first_k_dense_replace\")\n                else -1\n            )\n            moe_layer_freq_id = (\n                self.config.moe_layer_freq\n                if hasattr(self.config, \"moe_layer_freq\")\n                else 1","sourceCodeStart":1869,"sourceCodeEnd":1905,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/deepseek_ocr.py#L1869-L1905","documentation":"Raised by DeepseekOCRModel.load_weights when, after consuming every checkpoint weight file, some registered parameters were never loaded. This is a strict completeness check: any parameter name the model expects but the checkpoint did not provide aborts weight loading.","triggerScenarios":"Loading a checkpoint whose safetensors/bin files lack tensors matching one or more parameter names in params_dict — e.g. a base-model checkpoint loaded into an OCR-adapted architecture, a quantized/trimmed checkpoint, or a weight-file list that skips a shard.","commonSituations":"Checkpoint and model code version mismatch (model defines new layers the old checkpoint predates), loading DeepSeek base weights into DeepseekOCR, partial or corrupted checkpoint downloads, or wrong --model-path pointing at an incompatible repo.","solutions":["Verify the checkpoint matches this model class exactly (same repo/revision the model file was written for)","Re-download the checkpoint and confirm shard count/sizes match the index JSON","Update sglang to a version where deepseek_ocr.py's parameter names match your checkpoint (or vice versa)","If the gap is only tied/scalar meta weights, confirm your fork's load_weights handles them and the checkpoint actually contains them"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"expected = set(model.named_parameters().keys())\nprovided = set(safetensors keys via safetensors.safe_open per shard)\nmissing = expected - provided\nif missing: raise SystemExit(f\"checkpoint missing: {missing}\")","typeGuard":null,"tryCatchPattern":"try:\n    model.load_weights(weights_iter)\nexcept RuntimeError as e:\n    if \"not initialized from checkpoints\" in str(e):\n        log.error(e); sys.exit(2)  # wrong checkpoint — do not serve partially initialized weights\n    raise","preventionTips":["Never serve a model after a partial load failure — weights are random","Diff checkpoint keys vs model.named_parameters() before launching","Keep model code and checkpoint revision in lockstep"],"tags":["checkpoint-loading","weights","model-init","deepseek-ocr"],"backgroundTag":"model-checkpoint-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}