Guest User

Untitled

a guest
Aug 21st, 2026
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import argparse
  2. from safetensors import safe_open
  3.  
  4. if __name__ == "__main__":
  5. parser = argparse.ArgumentParser(description="Prints model precision.")
  6. parser.add_argument("model_path")
  7. args = parser.parse_args()
  8.  
  9. # Load the model weights header
  10. with safe_open(args.model_path, framework="pt") as f:
  11. # Get a list of all tensor names in the file
  12. keys = f.keys()
  13.  
  14. # Look for a main weight layer, or fallback to the very first key
  15. # (This avoids picking up scalar/metadata tensors)
  16. sample_key = next((k for k in keys if "weight" in k and "lora" not in k), keys[0])
  17.  
  18. # Look up the data type using the tensor name
  19. tensor_slice = f.get_slice(sample_key)
  20.  
  21. print(f"Inspected Tensor: {sample_key}")
  22. print(f"Model Data Type: {tensor_slice.get_dtype()}")
Advertisement
Add Comment
Please, Sign In to add comment