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

Function load

light-eval/src/eval_humaneval.py:50–75  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 4

MetaModelClass · 0.90
quantizeFunction · 0.90
printFunction · 0.85

Tested by

no test coverage detected