Views
No views yet
[!IMPORTANT] This repository is a community-driven quantized version of the original modelmeta-llama/Meta-Llama-3.1-405B-Instructwhich is the BF16 half-precision official version released by Meta AI.
meta-llama/Meta-Llama-3.1-405B-Instruct quantized using bitsandbytes from BF16 down to NF4 with a block size of 64.[!NOTE] In order to run the inference with Llama 3.1 405B Instruct BNB in NF4, around 220 GiB of VRAM are needed only for loading the model checkpoint, without including the KV cache or the CUDA graphs, meaning that there should be a bit over that VRAM available.
transformers, or text-generation-inference.torch and bitsandbytes need to be installed as:pip install "torch>=2.0.0" bitsandbytes --upgradetransformers need to be installed, being 4.43.0 or higher, as:pip install "transformers[accelerate]>=4.43.0" --upgradeAutoModelForCausalLM and run the inference normally.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "hugging-quants/Meta-Llama-3.1-405B-Instruct-BNB-NF4"
5prompt = [
6 {"role": "system", "content": "You are a helpful assistant, that responds as a pirate."},
7 {"role": "user", "content": "What's Deep Learning?"},
8]
9
10tokenizer = AutoTokenizer.from_pretrained(model_id)
11
12inputs = tokenizer.apply_chat_template(prompt, tokenize=True, add_generation_prompt=True, return_tensors="pt").cuda()
13
14model = AutoModelForCausalLM.from_pretrained(
15 model_id,
16 torch_dtype=torch.bfloat16,
17 low_cpu_mem_usage=True,
18 device_map="auto",
19)
20
21outputs = model.generate(inputs, do_sample=True, max_new_tokens=256)
22print(tokenizer.batch_decode(outputs, skip_special_tokens=True))