Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use safetensors API to inspect checkpoint keys
  • Loading branch information
samir-lms committed Nov 25, 2026
commit 8272d1e832f231582a5fb6f6b450951388119df9
9 changes: 4 additions & 5 deletions mlx_engine/utils/unsupported_checkpoints.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Fail fast on checkpoint layouts that the MLX engine cannot load."""

import json
import struct
from pathlib import Path

from safetensors import safe_open

# mlx-lm saves Inkling 2 Mini (`inkling2_loop`) with tensor names under
# `model.language_model.`. mlx-vlm, which loads all vision models here, only
# reads the original checkpoint names and its own converted names, so it would
Expand All @@ -20,10 +21,8 @@ def _weight_names(model_path: Path) -> list[str]:
return list(json.loads(index_path.read_text())["weight_map"])
names = []
for path in sorted(model_path.glob("*.safetensors")):
with path.open("rb") as file:
(header_length,) = struct.unpack("<Q", file.read(8))
header = json.loads(file.read(header_length))
names.extend(name for name in header if name != "__metadata__")
with safe_open(path, framework="numpy") as file:
names.extend(file.keys())
return names


Expand Down
Loading