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]: Guided Decoding Broken in Streaming mode #10376

Open
1 task done
JC1DA opened this issue Nov 15, 2024 · 0 comments
Open
1 task done

[Bug]: Guided Decoding Broken in Streaming mode #10376

JC1DA opened this issue Nov 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@JC1DA
Copy link

JC1DA commented Nov 15, 2024

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.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.30.0
Libc version: glibc-2.35

Python version: 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.8.0-1017-azure-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 A100 80GB PCIe
GPU 1: NVIDIA A100 80GB PCIe

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:                        48 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               48
On-line CPU(s) list:                  0-47
Vendor ID:                            AuthenticAMD
Model name:                           AMD EPYC 7V13 64-Core Processor
CPU family:                           25
Model:                                1
Thread(s) per core:                   1
Core(s) per socket:                   48
Socket(s):                            1
Stepping:                             1
BogoMIPS:                             4890.87
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl tsc_reliable nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext perfctr_core vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves user_shstk clzero xsaveerptr rdpru arat umip vaes vpclmulqdq rdpid fsrm
Hypervisor vendor:                    Microsoft
Virtualization type:                  full
L1d cache:                            1.5 MiB (48 instances)
L1i cache:                            1.5 MiB (48 instances)
L2 cache:                             24 MiB (48 instances)
L3 cache:                             192 MiB (6 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-23
NUMA node1 CPU(s):                    24-47
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 Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Vulnerable: Safe RET, no microcode
Vulnerability Spec store bypass:      Vulnerable
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Retpolines; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] nvidia-cublas-cu12==12.4.5.8
[pip3] nvidia-cuda-cupti-cu12==12.4.127
[pip3] nvidia-cuda-nvrtc-cu12==12.4.127
[pip3] nvidia-cuda-runtime-cu12==12.4.127
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.2.1.3
[pip3] nvidia-curand-cu12==10.3.5.147
[pip3] nvidia-cusolver-cu12==11.6.1.9
[pip3] nvidia-cusparse-cu12==12.3.1.170
[pip3] nvidia-ml-py==12.560.30
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.4.127
[pip3] nvidia-nvtx-cu12==12.4.127
[pip3] pyzmq==26.2.0
[pip3] sentence-transformers==3.2.1
[pip3] torch==2.5.1
[pip3] torchaudio==2.5.1+cu121
[pip3] torchvision==0.20.1
[pip3] transformers==4.45.2
[pip3] transformers-stream-generator==0.0.5
[pip3] triton==3.1.0
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] nvidia-cublas-cu12        12.4.5.8                 pypi_0    pypi
[conda] nvidia-cuda-cupti-cu12    12.4.127                 pypi_0    pypi
[conda] nvidia-cuda-nvrtc-cu12    12.4.127                 pypi_0    pypi
[conda] nvidia-cuda-runtime-cu12  12.4.127                 pypi_0    pypi
[conda] nvidia-cudnn-cu12         9.1.0.70                 pypi_0    pypi
[conda] nvidia-cufft-cu12         11.2.1.3                 pypi_0    pypi
[conda] nvidia-curand-cu12        10.3.5.147               pypi_0    pypi
[conda] nvidia-cusolver-cu12      11.6.1.9                 pypi_0    pypi
[conda] nvidia-cusparse-cu12      12.3.1.170               pypi_0    pypi
[conda] nvidia-ml-py              12.560.30                pypi_0    pypi
[conda] nvidia-nccl-cu12          2.21.5                   pypi_0    pypi
[conda] nvidia-nvjitlink-cu12     12.4.127                 pypi_0    pypi
[conda] nvidia-nvtx-cu12          12.4.127                 pypi_0    pypi
[conda] pyzmq                     26.2.0                   pypi_0    pypi
[conda] sentence-transformers     3.2.1                    pypi_0    pypi
[conda] torch                     2.5.1                    pypi_0    pypi
[conda] torchaudio                2.5.1+cu121              pypi_0    pypi
[conda] torchvision               0.20.1                   pypi_0    pypi
[conda] transformers              4.45.2                   pypi_0    pypi
[conda] transformers-stream-generator 0.0.5                    pypi_0    pypi
[conda] triton                    3.1.0                    pypi_0    pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.1.dev3367+g3b980c2 (git sha: 3b980c2
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0	GPU1	NIC0	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	NV12	NODE	0-23	0		N/A
GPU1	NV12	 X 	SYS	24-47	1		N/A
NIC0	NODE	SYS	 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

Model Input Dumps

No response

🐛 Describe the bug

Guided decoding broken in streaming mode after this commit 04cef2c
Previous commits are working fine. Non-streaming mode works fine as well.

Dataset to test: https://raw.githubusercontent.com/JC1DA/SharedData/refs/heads/main/gsm8k_luca_input_prompts/dataset.json

Test script:

import json
from openai import OpenAI
from concurrent.futures import ThreadPoolExecutor
from tqdm import tqdm

json_schema = """
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "thoughts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "description": "Description of the step in the thought process"
          },
          "calculation": {
            "type": "string",
            "description": "Calculation performed in this step"
          },
          "result": {
            "type": "integer",
            "description": "Result of the calculation"
          }
        },
        "required": ["action", "calculation", "result"],
        "additionalProperties": false
      }
    },
    "answer": {
      "type": "integer",
      "description": "Final answer calculated from the thoughts"
    }
  },
  "required": ["thoughts", "answer"],
  "additionalProperties": false
}
""".strip()

model = "Qwen/Qwen2.5-7B-Instruct-GPTQ-Int4"

client = OpenAI(
    base_url="http://localhost:5006/v1",
    api_key="NOKEY",
)

data = json.load(open("dataset.json", "r", encoding="utf-8"))

def get_output(prompt):
    stream = client.chat.completions.create(
        model=model,
        messages=[
            {
                "role": "system",
                "content": f"""
You are a helpful assistant that can answer questions from the user and provide useful information.
Generate your answer based on the JSON schema below.
{json_schema}
""".strip(),
            },
            {
                "role": "user",
                "content": prompt,
            },
        ],
        max_tokens=1024,
        temperature=0.0,
        top_p=1.0,
        stream=True,
        extra_body={"guided_json": json.loads(json_schema), "guided_decoding_backend": "outlines"},
    )

    _data = ""
    for chunk in stream:
        if chunk.choices[0].delta.content is not None:
            _data += chunk.choices[0].delta.content

    return _data

futures = []
failed = 0
with ThreadPoolExecutor(max_workers=8) as executor:
    futures = [executor.submit(get_output, prompt) for prompt in data]

    for f in tqdm(futures):
        res = f.result()
        try:
          res = json.loads(res)
          # print(res)
        except:
            failed += 1

print(failed, "/", len(futures))

Result:
Commit 6e056bc: failed 1 / 1318
Commit 04cef2c: failed 263 / 1318

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.
@JC1DA JC1DA added the bug Something isn't working label Nov 15, 2024
joennlae added a commit to 44ai-labs/vllm that referenced this issue Dec 1, 2024
During the startup of the api server the setup function is called
multiple times (every 5s). So the longer the longer the startup time
(generally for larger models) the more consumers are contending for the
output. This can then lead to race condition where the order of the
answer token is wrong.

Introduce here: vllm-project#9973

References:
vllm-project#10376
vllm-project#10589
vllm-project#10782

Signed-off-by: Jannis Schönleber <[email protected]>
joennlae added a commit to 44ai-labs/vllm that referenced this issue Dec 1, 2024
During the startup of the api server the setup function is called
multiple times (every 5s). So the longer the longer the startup time
(generally for larger models) the more consumers are contending for the
output. This can then lead to race condition where the order of the
answer token is wrong.

Introduce here: vllm-project#9973

References:
vllm-project#10376
vllm-project#10589
vllm-project#10782

Signed-off-by: Jannis Schönleber <[email protected]>
joennlae added a commit to 44ai-labs/vllm that referenced this issue Dec 1, 2024
During the startup of the api server the setup function is called
multiple times (every 5s). So the longer the longer the startup time
(generally for larger models) the more consumers are contending for the
output. This can then lead to race condition where the order of the
answer token is wrong.

Introduce here: vllm-project#9973

References:
vllm-project#10376
vllm-project#10589
vllm-project#10782

Signed-off-by: Jannis Schönleber <[email protected]>
joennlae added a commit to 44ai-labs/vllm that referenced this issue Dec 1, 2024
During the startup of the api server the setup function is called
multiple times (every 5s). So the longer the longer the startup time
(generally for larger models) the more consumers are contending for the
output. This can then lead to race condition where the order of the
answer token is wrong.

Introduce here: vllm-project#9973

References:
vllm-project#10376
vllm-project#10589
vllm-project#10782

Signed-off-by: Jannis Schönleber <[email protected]>
joennlae added a commit to 44ai-labs/vllm that referenced this issue Dec 15, 2024
During the startup of the api server the setup function is called
multiple times (every 5s). So the longer the longer the startup time
(generally for larger models) the more consumers are contending for the
output. This can then lead to race condition where the order of the
answer token is wrong.

Introduce here: vllm-project#9973

References:
vllm-project#10376
vllm-project#10589
vllm-project#10782

Signed-off-by: Jannis Schönleber <[email protected]>
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

No branches or pull requests

1 participant