Files
nvfp4-megamoe-kernel/dump_checkpoint_keys.py
2026-05-31 21:25:31 +00:00

33 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Dump checkpoint key names for specific layers only."""
import json
from pathlib import Path
from safetensors.torch import load_file
CHECKPOINT_DIR = "/root/nvidia-meeting/DeepSeek-V4-Pro"
def main():
cdir = Path(CHECKPOINT_DIR)
index_path = cdir / "model.safetensors.index.json"
with open(index_path) as f:
weight_map = json.load(f).get("weight_map", {})
# Only show layer 0, 2, and 60 keys (non-expert)
for li in [0, 2, 60]:
prefix = f"model.layers.{li}."
keys = sorted(k for k in weight_map if k.startswith(prefix))
# Filter out individual expert weights
filtered = [k for k in keys if '.experts.' not in k]
print(f"\n=== Layer {li} keys ({len(filtered)} non-expert) ===")
for k in filtered:
print(f" {k}")
# Non-layer keys (short list)
other_keys = sorted(k for k in weight_map if not k.startswith("model.layers."))
print(f"\n=== Non-layer keys ({len(other_keys)}) ===")
for k in other_keys:
print(f" {k}")
if __name__ == "__main__":
main()