"""Structural validation for a modelopt NVFP4 checkpoint. Checks that every tensor in model.safetensors.index.json exists in the shards (and vice versa) and prints the dtype layout + quant config. Usage: python validate_nvfp4.py [MODEL_DIR] (default: current directory) """ import collections import json import os import struct import sys DD = sys.argv[1] if len(sys.argv) > 1 else "." idx = json.load(open(os.path.join(DD, "model.safetensors.index.json"))) wm = idx["weight_map"] # headers of each shard (no tensor data is read) have = {} for fname in set(wm.values()): with open(os.path.join(DD, fname), "rb") as f: n = struct.unpack("