invoke-ai/InvokeAI · error · RuntimeError
missing keys after fp8 load: {missing[:10]}
Error message
missing keys after fp8 load: {missing[:10]} What it means
Raised by load_fp8_state_dict after a non-strict load_state_dict of an FP8-quantized checkpoint. When keys expected by the model are absent from the prepared state dict and strict mode is requested, it fails loudly instead of silently leaving weights randomly initialized.
Source
Thrown at invokeai/backend/ideogram4/quantized_loading.py:279
``transformers`` model resolves itself); unexpected keys always raise.
"""
prepared: dict[str, torch.Tensor] = {}
for k, v in state_dict.items():
if v.dtype == FP8_WEIGHT_DTYPE:
prepared[k] = v.to(device=device)
elif k.endswith(FP8_SCALE_SUFFIX):
prepared[k] = v.to(device=device, dtype=torch.float32)
elif v.is_floating_point():
prepared[k] = v.to(device=device, dtype=dtype)
else:
prepared[k] = v.to(device=device)
missing, unexpected = model.load_state_dict(prepared, strict=False, assign=assign)
if unexpected:
raise RuntimeError(f"unexpected keys after fp8 load: {unexpected[:10]}")
if missing:
if strict:
raise RuntimeError(f"missing keys after fp8 load: {missing[:10]}")
warnings.warn(f"missing keys after fp8 load: {missing[:10]}", stacklevel=2)
model.to(device)
View on GitHub (pinned to 0b6a024f2f)
Solutions
- Print the full `missing` list and compare against model.state_dict().keys() to identify the naming mismatch
- Re-export or re-quantize the checkpoint from the matching model version
- Pass strict=False (only if the missing keys are intentionally absent, e.g. buffers computed at runtime)
- Update the loading code's key-remapping/preparation step to translate old key names to new ones
Example fix
# before
load_fp8_state_dict(model, checkpoint, strict=True)
# after
# fix the checkpoint keys or remap before loading
prepared = {remap(k): v for k, v in checkpoint.items() if remap(k) in model.state_dict()}
load_fp8_state_dict(model, prepared, strict=True) Defensive patterns
Strategy: validation
Validate before calling
ckpt_keys = set(checkpoint.keys())
model_keys = set(model.state_dict().keys())
missing = model_keys - ckpt_keys
if missing:
raise ValueError(f"checkpoint lacks {len(missing)} model keys, e.g. {sorted(missing)[:5]}")
load_fp8_state_dict(model, prepared, strict=True) Type guard
def is_complete_state_dict(model, sd) -> bool:
return set(model.state_dict().keys()).issubset(sd.keys()) Try / catch
try:
load_fp8_state_dict(model, prepared, strict=True)
except RuntimeError as e:
if "missing keys after fp8 load" in str(e):
logger.error("checkpoint/model mismatch: %s", e)
raise
raise Prevention
- Save and load checkpoints with the same model revision and transformers version
- Sanity-check key sets before loading in production pipelines
- Keep a key-remapping table when checkpoints change layout
When it happens
Trigger: Loading an FP8 checkpoint whose key names don't match the model (renamed modules, older/newer checkpoint layout, partial checkpoint), with strict=True via _load_one_transformer or _load_text_encoder.
Common situations: Checkpoint saved from a different model revision, quantization script stripped keys, transformers version renamed attention/projection layers, loading a text-encoder checkpoint into a mismatched config.
Related errors
- Unexpected key: {k}
- unable to determine base type from state dict
- unable to determine model variant from state dict
- state dict does not look like a main model
- state dict does not look like bnb quantized nf4
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/e334ad3165c78ddc.
Report an issue: GitHub.