From a9b066246d48de509d9d5e0e6dd9e5059af39387 Mon Sep 17 00:00:00 2001 From: Christian Medina <37550954+cmedinasoriano@users.noreply.github.com> Date: Thu, 2 Jul 2026 20:47:11 -0400 Subject: [PATCH] feat: add model size check script --- check_model_size.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 check_model_size.py diff --git a/check_model_size.py b/check_model_size.py new file mode 100644 index 0000000..3cb53d6 --- /dev/null +++ b/check_model_size.py @@ -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()