Implement 4-bit quant for train script and inference

This commit is contained in:
2025-04-23 16:43:55 +00:00
parent 2c4b254bb0
commit e2e346d134
3 changed files with 65 additions and 36 deletions

View File

@@ -6,8 +6,6 @@ from threading import Thread
from transformers import AutoTokenizer, TextIteratorStreamer, pipeline
from typing import Callable, Iterator, Optional
from xml_schema_validator import XmlLogitsProcessor
import os
import torch
from . import LlmEngine
from .. import util
@@ -38,10 +36,7 @@ class QwQLlmEngine(LlmEngine):
# Load model
self._model, _returned_tokenizer = FastLanguageModel.from_pretrained(
model_path,
load_in_4bit = True, # False for LoRA 16bit
fast_inference = True, # Enable vLLM fast inference
gpu_memory_utilization = 0.8, # Reduce if out of memory
tokenizer = self._tokenizer,
gpu_memory_utilization = 0.5, # Reduce if out of memory
)
# enable unsloth optimizations