MCPcopy Create free account
hub / github.com/Alpha-VLLM/LLaMA2-Accessory / load

Function load

light-eval/src/eval_gsm8k.py:54–79  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

52
53# load model and tokenizer
54def load(args):
55
56 # define the model
57 misc.init_distributed_mode(args)
58 fs_init.initialize_model_parallel(args.model_parallel_size)
59 model = MetaModel(args.llama_type, args.llama_config, args.tokenizer_path, with_visual=True)
60 print(f"load pretrained from {args.pretrained_path}")
61 load_tensor_parallel_model_list(model, args.pretrained_path)
62
63 if args.quant:
64 print("Quantizing model to 4bit!")
65
66 from transformers.utils.quantization_config import BitsAndBytesConfig
67 quantization_config = BitsAndBytesConfig.from_dict(
68 config_dict={
69 "load_in_8bit": False,
70 "load_in_4bit": True,
71 "bnb_4bit_quant_type": "nf4",
72 },
73 return_unused_kwargs=False,
74 )
75 quantize(model, quantization_config)
76
77 #print("Model = %s" % str(model))
78 model.bfloat16().cuda()
79 return model
80
81def is_number(s):
82 try:

Callers 1

mainFunction · 0.70

Calls 4

MetaModelClass · 0.90
quantizeFunction · 0.90
printFunction · 0.85

Tested by

no test coverage detected