Views
No views yet
pip install hqq gemlite; #to use the gemlite backend1import torch
2device = 'cuda:0'
3backend = 'torchao_int4' #'torchao_int4' or 'gemlite'
4compute_dtype = torch.bfloat16 if backend=="torchao_int4" else torch.float16
5model_id = 'mobiuslabsgmbh/Qwen2.5-VL-7B-Instruct_4bitgs64_hqq_hf'
6
7#Load model
8from transformers import AutoModelForCausalLM, AutoProcessor
9
10model = AutoModelForCausalLM.from_pretrained(
11 model_id,
12 torch_dtype=compute_dtype,
13 device_map=device,
14)
15
16processor = AutoProcessor.from_pretrained(model_id)
17
18#Patching
19from hqq.utils.patching import prepare_for_inference
20prepare_for_inference(model, backend=backend, verbose=True) pip install git+https://github.com/mobiusml/hqq/;
pip install git+https://github.com/mobiusml/gemlite/;1from vllm import LLM
2from vllm.sampling_params import SamplingParams
3
4from hqq.utils.vllm import set_vllm_hqq_backend, VLLM_HQQ_BACKEND
5set_vllm_hqq_backend(backend=VLLM_HQQ_BACKEND.GEMLITE)
6
7model_id = "mobiuslabsgmbh/Qwen2.5-VL-7B-Instruct_4bitgs64_hqq_hf"
8
9llm = LLM(model=model_id, max_model_len=4096, max_num_seqs=2, limit_mm_per_prompt={"image": 1}, dtype=torch.float16)