vllm-project / vllm

A high-throughput and memory-efficient inference and serving engine for LLMs
https://docs.vllm.ai
Apache License 2.0
30.1k stars 4.55k forks source link

[Bug]: Concurrent requests are non-deterministic #4091

Open beam-me-up-scotchy opened 7 months ago

beam-me-up-scotchy commented 7 months ago

Your current environment

NB: This output is for our endpoint machine running vLLM

PyTorch version: 2.1.2+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.29.2
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-100-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA H100 80GB HBM3
GPU 1: NVIDIA H100 80GB HBM3
GPU 2: NVIDIA H100 80GB HBM3
GPU 3: NVIDIA H100 80GB HBM3

Nvidia driver version: 550.54.14
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:                      46 bits physical, 57 bits virtual
Byte Order:                         Little Endian
CPU(s):                             128
On-line CPU(s) list:                0-127
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Gold 6448Y
CPU family:                         6
Model:                              143
Thread(s) per core:                 2
Core(s) per socket:                 32
Socket(s):                          2
Stepping:                           8
BogoMIPS:                           4200.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 tsc_known_freq 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 cat_l2 cdp_l3 invpcid_single cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi 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 avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          3 MiB (64 instances)
L1i cache:                          2 MiB (64 instances)
L2 cache:                           128 MiB (64 instances)
L3 cache:                           120 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126
NUMA node1 CPU(s):                  1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,127
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] torch==2.1.2
[pip3] triton==2.1.0
[conda] Could not collectROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.4.0.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    GPU1    GPU2    GPU3    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X  NV6 NV6 NV6 0,2,4,6,8,10    0       N/A
GPU1    NV6  X  NV6 NV6 0,2,4,6,8,10    0       N/A
GPU2    NV6 NV6  X  NV6 1,3,5,7,9,11    1       N/A
GPU3    NV6 NV6 NV6  X  1,3,5,7,9,11    1       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

๐Ÿ› Describe the bug

When querying vLLM as a server, running syncronous requests one-at-a-time results in deterministic output. However, when running concurrent request, outputs become non-deterministic.

This seems to be the same issues mentioned here: #1182

How can we ensure deterministic outputs when running concurrent requests?

Please see synchronous and asynchronous scripts running a dummy translate task below to replicate (remember to replace IP address with address of endpoint machine):

starting server on endpoint machine python -m vllm.entrypoints.openai.api_server --model /data/huggingface/Mistral-7B-Instruct-v0.2 --tensor-parallel-size=4 --disable-log-stats --disable-log-requests

test_chat_completion.py

import requests

# Read the prompt from a file
with open("public_test_prompt.txt", "r") as file:
    prompt = file.read()

# Messages payload for the request
messages = [
    {
        "role": "user",
        "content": prompt,
    },
]

# Accumulate results to compare
output = []

# Send synchronous requests
for i in range(1, 50):
    response = requests.post(
        "http://[IP address redacted]:8000/v1/chat/completions",
        headers={"Authorization": "Bearer sk-sdf"},
        json={
            "model": "/data/huggingface/Mistral-7B-Instruct-v0.2",
            "messages": messages,
            "max_tokens": 8000,
            "temperature": 0,
        },
        timeout=100000,  # Adjust the timeout value as needed (in seconds)
    )

    data = response.json()
    result = data["choices"][0]["message"]["content"]
    output.append(result)

# Check if all outputs are the same
print(f"Is every output the same? {all(o == output[0] for o in output)}")

Output: "Is every output the same? True"

test_async_public.py

import asyncio
import aiohttp

async def translate_async(session, semaphore, messages):
    async with semaphore:
        async with session.post(
            url="http://[IP address redacted]:8000/v1/chat/completions",
            headers={"Authorization": "Bearer sk-sdf"},
            json={
                "model": "/data/huggingface/Mistral-7B-Instruct-v0.2",
                "messages": messages,
                "temperature": 0,
            },
            timeout=100
        ) as response:
            data = await response.json()
            return data["choices"][0]["message"]["content"]

async def translate():
    # Read the prompt from a file
    with open("public_test_prompt.txt", "r") as file:
        prompt = file.read()

    # Messages payload for the request
    messages = [
        {
            "role": "user",
            "content": prompt,
        },
    ]

    # Semaphore to limit concurrency
    semaphore = asyncio.Semaphore(45)
    tasks = []

    async with aiohttp.ClientSession() as session:
        for _ in range(50):  # Create tasks for concurrent requests
            task = asyncio.create_task(translate_async(session, semaphore, messages))
            tasks.append(task)

        # Wait for all tasks to complete
        results = await asyncio.gather(*tasks)
        return results

async def main():
    output = await translate()
    print(output)
    print(f"Is every output the same? {all(o == output[0] for o in output)}")

asyncio.run(main())

Output: "Is every output the same? False"

public_test_prompt.txt

You are a world class translator of the Korean Language.
You will be provided with text to translate from Korean to English.
Precision and accuracy are fundamentally important.
Please try to keep the same formatting as the text you receive.
Here is your text to translate: 
๋‚ด๊ฐ€ ๋งž์•˜์–ด ๋…ผํ˜„๋™์˜ยน ๋น„๊ฐ€ ์ƒˆ๋˜ ์ž‘์—…์‹ค์—์„œ
๊นก์†Œ์ฃผ๋ฅผยฒ ๊นŒ๋ฉฐ ์‹ ์„ธํƒ€๋ น์ด๋‚˜ ํ•˜๋ฉฐ
๋‹ค์งํ–ˆ๋˜ ๊ทธ ๋ง ์„ฑ๊ณตํ•˜๋ฉด ๋‹ค๋“ค ๋’ค์กŒ์–ดยณ
๋ฐฉํƒ„์˜ ์„ฑ๊ณต ์ด์œ ? ๋‚˜๋„ ๋ชฐ๋ผ ๊ทธ๋”ด ๊ฒŒ ์–ด๋”จ์–ด
์šฐ๋ฆฌ๋“ค์ด ๋ชจ๋‘ ์ƒˆ๋น ์ง€๊ฒŒโด ๋‹ฌ๋ฆฐ ๊ฑฐ์ง€
๋ญ๋ผ ํ•˜๋“  ๋‹ฌ๋ฆฐ ๊ฑฐ์ง€
๋‹ต์€ ์—ฌ๊ธฐ ์žˆ์–ด ํ•˜ํ•˜ํ•˜
github-actions[bot] commented 2 weeks ago

This issue has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this issue should remain open. Thank you!