Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import argparse
- from safetensors import safe_open
- if __name__ == "__main__":
- parser = argparse.ArgumentParser(description="Prints model precision.")
- parser.add_argument("model_path")
- args = parser.parse_args()
- # Load the model weights header
- with safe_open(args.model_path, framework="pt") as f:
- # Get a list of all tensor names in the file
- keys = f.keys()
- # Look for a main weight layer, or fallback to the very first key
- # (This avoids picking up scalar/metadata tensors)
- sample_key = next((k for k in keys if "weight" in k and "lora" not in k), keys[0])
- # Look up the data type using the tensor name
- tensor_slice = f.get_slice(sample_key)
- print(f"Inspected Tensor: {sample_key}")
- print(f"Model Data Type: {tensor_slice.get_dtype()}")
Advertisement
Add Comment
Please, Sign In to add comment