Closed
Description
Your current environment
The output of `python collect_env.py`
PyTorch version: 2.5.1+cu124
Is debug build: False
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A
OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.35
Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-6.8.0-48-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.1.105
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA A40
Nvidia driver version: 550.127.05
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 52 bits physical, 57 bits virtual
Byte Order: Little Endian
CPU(s): 96
On-line CPU(s) list: 0-95
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Gold 6342 CPU @ 2.80GHz
CPU family: 6
Model: 106
Thread(s) per core: 2
Core(s) per socket: 24
Socket(s): 2
Stepping: 6
CPU max MHz: 3500.0000
CPU min MHz: 800.0000
BogoMIPS: 5600.00
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect wbnoinvd dtherm ida arat pln pts vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 2.3 MiB (48 instances)
L1i cache: 1.5 MiB (48 instances)
L2 cache: 60 MiB (48 instances)
L3 cache: 72 MiB (2 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0-23,48-71
NUMA node1 CPU(s): 24-47,72-95
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Versions of relevant libraries:
[uv] numpy==1.26.2
[uv] nvidia-cublas-cu12==12.1.3.1
[uv] nvidia-cuda-cupti-cu12==12.1.105
[uv] nvidia-cuda-nvrtc-cu12==12.1.105
[uv] nvidia-cuda-runtime-cu12==12.1.105
[uv] nvidia-cudnn-cu12==8.9.2.26
[uv] nvidia-cufft-cu12==11.0.2.54
[uv] nvidia-curand-cu12==10.3.2.106
[uv] nvidia-cusolver-cu12==11.4.5.107
[uv] nvidia-cusparse-cu12==12.1.0.106
[uv] nvidia-nccl-cu12==2.18.1
[uv] nvidia-nvjitlink-cu12==12.3.101
[uv] nvidia-nvtx-cu12==12.1.105
[uv] pyzmq==24.0.1
[uv] torch==2.1.1
[uv] torchaudio==2.1.1
[uv] torchvision==0.16.1
[uv] transformers==4.46.3
[uv] triton==2.1.0
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.6.4.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X 0-23,48-71 0 N/A
Legend:
X = Self
SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
PIX = Connection traversing at most a single PCIe bridge
NV# = Connection traversing a bonded set of # NVLinks
LD_LIBRARY_PATH=/workspace/ADVANCED-inference/lora-server/.venv/lib/python3.10/site-packages/cv2/../../lib64:
CUDA_MODULE_LOADING=LAZY
Model Input Dumps
No response
🐛 Describe the bug
Issue: LoRa adapter responses with vLLM do not match peft/transformer responses.
The reproduction involves running inference using a) vllm, compared to b) running inference with transformers and peft. I have run both on A40 machines on runpod.
vLLM approach
vLLM server startup with statically loaded LoRa
ADAPTER_REPO="Trelis/Qwen2.5-7B-Instruct-touch-rugby-1"
ADAPTER_PATH=$(python3 -c "from huggingface_hub import snapshot_download; print(snapshot_download('${ADAPTER_REPO}', ignore_patterns=['model-*', 'pytorch_model*', 'tf_model*', 'flax_model*']))")
# Start server with LoRA pre-loaded
vllm serve Qwen/Qwen2.5-7B-Instruct \
--max-model-len 8192 \
--enable-lora \
--max-lora-rank 8 \
--port 8000 \
--lora-modules "{\"name\": \"touch-rugby-1\", \"path\": \"${ADAPTER_PATH}\", \"base_model_name\": \"Qwen/Qwen2.5-7B-Instruct\"}"
vLLM Script to call the server endpoint, aka vllm_replication.py
import requests
import json
from typing import List, Dict, Any
def send_chat_completion(
messages: List[Dict[str, str]],
model: str,
base_url: str = "http://localhost:8000"
) -> Dict[str, Any]:
"""Send a chat completion request to the vLLM server."""
try:
response = requests.post(
f"{base_url}/v1/chat/completions",
headers={"Content-Type": "application/json"},
json={
"model": model,
"messages": messages,
"max_tokens": 100,
"temperature": 0.01,
}
)
response.raise_for_status() # Raise an error for bad status codes
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error making request: {e}")
print(f"Response content: {response.text if 'response' in locals() else 'No response'}")
return None
def main():
# Configuration
base_model = "Qwen/Qwen2.5-7B-Instruct"
adapter_name = "touch-rugby-1" # This matches the name in your vLLM server command
# Test prompt (same as in your transformers example)
messages = [{
"role": "user",
"content": "How many players are on the field on each team at the start of a drop-off?"
}]
# Generate with base model
print("\nBase Model Response:")
base_response = send_chat_completion(messages, base_model)
if base_response and 'choices' in base_response:
print(f"Base Model Output: {base_response['choices'][0]['message']['content']}")
else:
print("Failed to get base model response")
# Generate with adapter
print("\nAdapter Model Response:")
adapter_response = send_chat_completion(messages, adapter_name)
if adapter_response and 'choices' in adapter_response:
print(f"Adapter Output: {adapter_response['choices'][0]['message']['content']}")
else:
print("Failed to get adapter response")
if __name__ == "__main__":
main()
Transformers / PEFT script
# Install required packages if needed
!pip install transformers peft accelerate -qU
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load the base model and tokenizer
base_model_id = "Qwen/Qwen2.5-7B-Instruct"
adapter_id = "Trelis/Qwen2.5-7B-Instruct-touch-rugby-1"
tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
# Test prompt
prompt = "How many players are on the field on each team at the start of a drop-off?"
# Function to generate response
def generate_response(model, prompt):
messages = [
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=100,
temperature=0.01,
do_sample=True,
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response
# Generate with base model
print("Base Model Response:")
base_response = generate_response(base_model, prompt)
print(base_response)
# Load adapter and generate
print("\nLoading adapter...")
adapter_model = PeftModel.from_pretrained(base_model, adapter_id)
print("\nAdapter Model Response:")
adapter_response = generate_response(adapter_model, prompt)
print(adapter_response)
# Free up memory
del base_model
del adapter_model
torch.cuda.empty_cache()
Results / Output
vLLM
The adapter response does not take on the adapter/fine-tune attributes). It does not know what sport the question is about or what a drop-off is.
uv run vllm-replication.py
Base Model Response:
Base Model Output: It seems there might be a bit of confusion in your question. The term "drop-off" is not commonly used in sports, especially not in team sports like football, basketball, or soccer. Could you please clarify which sport you are referring to?
For example:
- In soccer (football), there are 11 players on the field for each team at the start of a match.
- In American football, there are 11 players on the field for each team at the start of
Adapter Model Response:
Adapter Output: In the context of Australian rules football, which is the sport referred to as "drop-off," each team starts with 18 players on the field at the beginning of the game. This number of players is standard for a match and includes both forwards, midfielders, and defenders.
Transformers / peft Response
The model knows what a "drop-off" is and that this question is about touch rugby.
Base Model Response:
system
You are Qwen, created by Alibaba Cloud. You are a helpful assistant.
user
How many players are on the field on each team at the start of a drop-off?
assistant
It seems there might be some confusion in your question. The term "drop-off" is not commonly used in sports to describe the number of players on a field or court. Could you please clarify which sport you are referring to?
For example:
- In soccer (football), there are 11 players on the field for each team.
- In American football, there are typically 11 players on the field for each team at the start of a play.
- In basketball, there are
Loading adapter...
Adapter Model Response:
system
You are Qwen, created by Alibaba Cloud. You are a helpful assistant.
user
How many players are on the field on each team at the start of a drop-off?
assistant
To determine how many players are on the field at the start of a drop-off, we can follow these steps:
1. **Understand the Composition of a Team**: Each team consists of 14 players, including the Interchange.
2. **Interchange Rules**: The Interchange is allowed to enter and leave the field during normal play without a Change of Possession (COP).
3. **Drop-Off Procedure**: A Drop-Off occurs when one team has fewer than six (
Additional Notes
- Base models are loaded in bfloat16 in both cases
- The very same adapters and base models are used from Huggingface
- The adapter is public and you can check it here
- I also have tried with the same fine-tuning approach on Llama 3.1 8B (with ranks of 8 and also 32).
- I intentionally used a low rank of 8 here in case somehow that gave issues.
Questions
- Are there any known issues with loading safetensors? I don't see anything in the issues?
- Are there limits on what modules can be trained? I only trained linear layers, which should be fine:
"target_modules": [
| "gate_proj",
| "k_proj",
| "v_proj",
| "down_proj",
| "q_proj",
| "o_proj",
| "up_proj"
| ],
Before submitting a new issue...
- Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.