sgl-project/sglang · critical · RuntimeError
Some weights are not initialized from checkpoints: {unloaded
Error message
Some weights are not initialized from checkpoints: {unloaded_params} What it means
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.
Source
Thrown at python/sglang/srt/models/deepseek_ocr.py:1887
weight_loader = param.weight_loader
weight_loader(param, loaded_weight, shard_id)
break
else:
# Skip loading extra bias for GPTQ models.
if name.endswith(".bias") and name not in params_dict:
continue
# Skip experts that are not assigned to this worker.
if (
"mlp.experts." in name or "mlp.shared_experts." in name
) and name not in params_dict:
continue
param = params_dict[name]
weight_loader = getattr(param, "weight_loader", default_weight_loader)
weight_loader(param, loaded_weight)
loaded_params.add(name)
unloaded_params = params_dict.keys() - loaded_params
if unloaded_params:
raise RuntimeError(
f"Some weights are not initialized from checkpoints: {unloaded_params}"
)
self.post_load_weights()
def post_load_weights(self):
if _is_cpu and _is_cpu_amx_available:
from sglang.srt.layers.amx_utils import _amx_process_weight_after_loading
layer_ids = int(self.config.num_hidden_layers)
first_k_dense_replace_id = (
self.config.first_k_dense_replace
if hasattr(self.config, "first_k_dense_replace")
else -1
)
moe_layer_freq_id = (
self.config.moe_layer_freq
if hasattr(self.config, "moe_layer_freq")
else 1View on GitHub (pinned to 0132848349)
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
Defensive patterns
Strategy: validation
Validate before calling
expected = set(model.named_parameters().keys())
provided = set(safetensors keys via safetensors.safe_open per shard)
missing = expected - provided
if missing: raise SystemExit(f"checkpoint missing: {missing}") Try / catch
try:
model.load_weights(weights_iter)
except RuntimeError as e:
if "not initialized from checkpoints" in str(e):
log.error(e); sys.exit(2) # wrong checkpoint — do not serve partially initialized weights
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Duplicate tensor names detected across safetensors files. Re
- Incomplete Diffusers H3 fused parameters: {incomplete}
- qkv weight has incompatible output dim for grouped checkpoin
- The original encoder only has {num_hidden_layers} layers, bu
- RIFE weight file not found: {flownet_path} Expected layout:
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/f200a9913e6ebda7.
Report an issue: GitHub.