Skip to content

Instantly share code, notes, and snippets.

@antferdom
Last active September 15, 2023 09:28
Show Gist options
  • Save antferdom/d2edec70a769aa5ec23e1a1f72c25525 to your computer and use it in GitHub Desktop.
Save antferdom/d2edec70a769aa5ec23e1a1f72c25525 to your computer and use it in GitHub Desktop.
import torch
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained('mosaicml/mpt-7b',
trust_remote_code=True,
torch_dtype=torch.bfloat16,
)
model.eval()
model.cuda()
for name, param in model.named_parameters():
print(f"{name} Modelsize: {param.numel()/1000**2:.1f}M parameters")
if "31" not in name:
param.requires_grad = False
print(name, param.requires_grad)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment