37 lines
971 B
Python
37 lines
971 B
Python
#!/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()
|