Skip to content
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

[Bug]: Concurrent requests messing up GREEDY responses #5607

Closed
prashantgupta24 opened this issue Jun 17, 2024 · 6 comments · Fixed by #5639
Closed

[Bug]: Concurrent requests messing up GREEDY responses #5607

prashantgupta24 opened this issue Jun 17, 2024 · 6 comments · Fixed by #5639
Labels
bug Something isn't working

Comments

@prashantgupta24
Copy link
Contributor

prashantgupta24 commented Jun 17, 2024

Your current environment

The output of `python collect_env.py`

Collecting environment information...
/opt/vllm/lib64/python3.11/site-packages/transformers/utils/hub.py:124: FutureWarning: Using `TRANSFORMERS_CACHE` is deprecated and will be removed in v5 of Transformers. Use `HF_HOME` instead.
  warnings.warn(
PyTorch version: 2.3.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Red Hat Enterprise Linux 9.4 (Plow) (x86_64)
GCC version: (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3)
Clang version: Could not collect
CMake version: version 3.29.5
Libc version: glibc-2.34

Python version: 3.11.7 (main, Jan 22 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (64-bit runtime)
Python platform: Linux-4.18.0-372.46.1.el8_6.x86_64-x86_64-with-glibc2.34
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA A100-SXM4-80GB
Nvidia driver version: 535.104.12
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):                          80
On-line CPU(s) list:             0-79
Vendor ID:                       GenuineIntel
Model name:                      Intel Xeon Processor (Icelake)
CPU family:                      6
Model:                           134
Thread(s) per core:              2
Core(s) per socket:              20
Socket(s):                       2
Stepping:                        0
BogoMIPS:                        5600.04
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves wbnoinvd arat avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq la57 rdpid fsrm md_clear arch_capabilities
Virtualization:                  VT-x
Hypervisor vendor:               KVM
Virtualization type:             full
L1d cache:                       2.5 MiB (80 instances)
L1i cache:                       2.5 MiB (80 instances)
L2 cache:                        160 MiB (40 instances)
L3 cache:                        32 MiB (2 instances)
NUMA node(s):                    2
NUMA node0 CPU(s):               0-39
NUMA node1 CPU(s):               40-79
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Retbleed:          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 IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] torch==2.3.0
[pip3] transformers==4.41.2
[pip3] triton==2.3.0
[pip3] vllm-nccl-cu12==2.18.1.0.4.0
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.4.3
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0	NIC0	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	PIX	0-39	0		N/A
NIC0	PIX	 X

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

NIC Legend:

  NIC0: mlx5_0

🐛 Describe the bug

Issue

While sending concurrent requests, greedy responses become inconsistent and become affected due to the other concurrent sampling request.

In the example below, if only the greedy request is sent, the output is 100% Once upon a time, there was an old man.
But, as soon as another concurrent sampling request is sent along with the greedy request, the greedy response sometimes changes to Once upon a time, there was a young woman -> which should not be the case.

(Note: not consistent behavior, but happens like 2/5 times)

Server

python -m vllm.entrypoints.api_server --model LLaMa/models/hf/13B-F

Sample client

import json
import concurrent.futures
import requests
import traceback

def post_http_request(api_url: str, pload) -> requests.Response:
    headers = {"User-Agent": "Test Client"}
    pload = pload
    response = requests.post(api_url, headers=headers, json=pload, stream=True)
    data = json.loads(response.content)
    output = data["text"]
    print(output)


if __name__ == "__main__":

    prompt = "Once upon a time,"
    api_url = f"http://localhost:8000/generate"

    sampling_params = []
    sampling_params.append(
        {
            "prompt": prompt,
            "temperature": 0.0,
            "max_tokens": 5,
            "repetition_penalty": 2,
        }
    )
    sampling_params.append(
        {
            "prompt": prompt,
            "seed": 99,
            "max_tokens": 4,
            "top_k": 1,
        }
    )
    sampling_params = sampling_params * 10

    with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
        futures = []
        for param in sampling_params:
            futures.append(
                executor.submit(post_http_request, api_url=api_url, pload=param)
            )

        # Waiting for all futures to complete
        for future in concurrent.futures.as_completed(futures):
            try:
                future.result()
            except Exception as exc:
                # printing stack trace
                traceback.print_exc()
                print(f"exception: {exc}")

Output

❯ python3 sample_client.py
['Once upon a time, there was a young']
['Once upon a time, there was a young']
['Once upon a time, there was a young']
['Once upon a time, there was a young']
['Once upon a time, there was a young']
['Once upon a time, there was a young']
['Once upon a time, there was a young']
['Once upon a time, there was a young']
['Once upon a time, there was a young']
['Once upon a time, there was a young']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was a young woman']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was a young woman']
@prashantgupta24 prashantgupta24 added the bug Something isn't working label Jun 17, 2024
@simon-mo
Copy link
Collaborator

This might be a dup and being investigated here: #5404

@tdoublep
Copy link
Member

This seems to be related to the fact that some requests have repetition_penalty set and others do not. There is some inconsistent behaviour in this function that means some tensor sizes depends on the order in which the requests get batched together.

See #5639

@tdoublep
Copy link
Member

Also worth mentioning that I see the same behaviour if I remove the top_k from your repro script, e.g.:

sampling_params = []
sampling_params.append(
    {
        "prompt": prompt,
        "temperature": 0.0,
        "max_tokens": 5,
        "repetition_penalty": 2,
    }
)
sampling_params.append(
    {
        "prompt": prompt,
        "seed": 99,
        "max_tokens": 4,
    }
)
sampling_params = sampling_params * 10

sometimes produces:

['Once upon a time, there were two best']
['Once upon a time, there were two best']
['Once upon a time, there were two best']
['Once upon a time, there were two best']
['Once upon a time, there were two best']
['Once upon a time, there were two best']
['Once upon a time, there were two best']
['Once upon a time, there were two best']
['Once upon a time, there were two best']
['Once upon a time, there were two best']
['Once upon a time, there was a young woman']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']
['Once upon a time, there was an old man']

However, if I have both requests be greedy then the issue goes away. I think that is because the offending code only gets excecuted if seq_group.do_sample=True and at least one request has a repetition penalty.

@njhill
Copy link
Member

njhill commented Jun 18, 2024

Thanks @prashantgupta24 @tdoublep for finding and investigating this!

@hulongan
Copy link

What is the final conclusion of this question?

@prashantgupta24
Copy link
Contributor Author

@hulongan this was fixed by #5639

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants