Views
No views yet
1git clone https://github.com/ruikangliu/FlatQuant.git
2
3cd FlatQuant
4
5conda create -n flatquant python=3.10 -y
6conda activate flatquant
7pip install -r requirements.txt
8pip install -e .
9pip install flash-attn --no-build-isolationnvcc --version and install CUDA toolkit or set the path to nvcc correctly.pip install -e . in your environment.1from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
2import torch
3
4model = AutoModelForCausalLM.from_pretrained(
5 "Hyun9junn/Llama-3.1-70B-Instruct-W4A4KV4-FlatQuant", # Update this with your actual HF repo name
6 trust_remote_code = True,
7 torch_dtype = torch.float16,
8
9)
10tokenizer = AutoTokenizer.from_pretrained("Hyun9junn/Llama-3.1-70B-Instruct-W4A4KV4-FlatQuant")
11streamer = TextStreamer(tokenizer)
12
13if torch.cuda.is_available():
14 device = torch.device("cuda:0")
15 model = model.to(device)
16
17prompt = "Summarize Barry Bonds's career so far as a legendary tale told by an old baseball coach.\n"
18
19inputs = tokenizer(prompt, return_tensors = "pt").to(model.device)
20
21with torch.no_grad():
22 outputs = model.generate(
23 **inputs,
24 max_new_tokens = 50,
25 do_sample = False,
26 temperature = 1.0,
27 streamer = streamer
28 )