feat: add model size check script

This commit is contained in:
Christian Medina
2026-07-02 20:47:11 -04:00
parent fa2f21562f
commit a9b066246d

36
check_model_size.py Normal file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""Check model size and quantization status."""
import torch
from transformers import AutoModelForCausalLM
model_path = "/data/models/Ornith-1.0-35B-bnb-4bit"
print(f"Loading model from: {model_path}")
model = AutoModelForCausalLM.from_pretrained(
model_path,
device_map="cpu",
torch_dtype=torch.float16,
trust_remote_code=True,
)
# Count parameters
total_params = sum(p.numel() for p in model.parameters())
print(f"Total parameters: {total_params / 1e9:.2f}B")
# Check for quantized parameters
bnb_params = 0
bf16_params = 0
for name, p in model.named_parameters():
if hasattr(p, 'quant_state') and p.quant_state is not None:
bnb_params += p.numel()
else:
bf16_params += p.numel()
print(f"BnB 4-bit parameters: {bnb_params / 1e9:.2f}B")
print(f"BF16 parameters: {bf16_params / 1e9:.2f}B")
print(f"Estimated size: {(bnb_params * 0.5 + bf16_params * 2) / 1e9:.2f} GB")
del model
import gc
gc.collect()