-
Notifications
You must be signed in to change notification settings - Fork 2k
[Bug] HuggingFace and SGLang inference don't match #2671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@pratcooper Hi, we just updated the codes for Lora. The misalignment bug should be fixed. Would you please test it? |
BTW I'll release a new version soon |
Also, the lora paths of adaptors should be passed in when launching server (engine). So the line of launching engine in script should be modified to self._model = sgl.Engine(model_path=self.base_model_path, lora_paths=[adaptor_path]) to make it work. |
@Fridge003 Thanks ! I will try to test it this week. Can you please provide me version number for this fix ? |
sglang 0.4.2.post4, sgl-kernel 0.0.3.post3, flashinfer 0.2.0.post2 |
Hi @pratcooper Is this issue fixed? |
@Fridge003 Have been a little occupied lately. Will try to get back as soon as possible. Sorry for delay. |
This issue has been automatically closed due to inactivity. Please feel free to reopen it if needed. |
Uh oh!
There was an error while loading. Please reload this page.
Checklist
Describe the bug
The accuracy of the model is degraded due to inconsistent outputs from SGLang. While HF and vLLM produce consistent results such as "A" or "B," SGLang occasionally outputs responses like "I can't process that request." or "A." / "B." This inconsistency impacts overall accuracy.
Reproduction
What command or script did you run?
A script for generating outputs using a LLaMA 3.1 8B Istruct model with LoRA.
Which model are you using?
LLaMA 3.1 with LoRA applied.
Steps to reproduce:
Hugging Face Code Snippet :
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = LlamaForCausalLM.from_pretrained(
model_name,
load_in_8bit=False,
torch_dtype=torch.float16,
device_map='auto',
)
adaptor_path = './model_spec/checkpoints/checkpoint-200-vllm'
model = PeftModel.from_pretrained(
model,
adaptor_path,
torch_dtype=torch.float16,
)
model.config.pad_token_id = tokenizer.pad_token_id = 0
model.config.bos_token_id = 1
model.config.eos_token_id = 2
model.generation_config.pad_token_id = tokenizer.pad_token_id
model.eval()
def evaluate(
instruction,
input=None,
temperature=0,
top_p=1,
top_k=-1,
num_beams=4,
max_new_tokens=128,
stream_output=False,
**kwargs,
):
prompt = f"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n{instruction}<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n{input}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
SGLang Code Snippet :
import sglang as sgl
from sglang import *
import logging
import json
import torch
from typing import Union, List
from vllm import LLM, SamplingParams
from vllm.inputs import TokensPrompt
from vllm.lora.request import LoRARequest
from collections import defaultdict
from utils.usecase_prompts import UseCasePrompter
from utils.lora_adapters import UseCaseLoraAdapters
from utils.prompter import Prompter
logging.basicConfig(format='%(asctime)s %(message)s')
logger = logging.getLogger()
logger.setLevel(logging.INFO)
class SimpleSGLangLlama2:
def init(self, base_model_path, number_of_gpu=1, gpu_memory_utilization=0.4):
self.base_model_path = base_model_path
self._model = sgl.Engine(model_path=self.base_model_path)
if name == "main":
model_path = "./models/meta-llama/Meta-Llama-3.1-8B-Instruct"
llm = SimpleSGLangLlama2(model_path)
Environment
Run the class in notebooks environment.
SGLang 0.4.0 (with flashinfer 0.1.6+cu121torch2.4)
The text was updated successfully, but these errors were encountered: