Skip to content

[Bug]: Corrupted output when using JSON structured response (v0.9.1) #19493

Closed
@ankandrew

Description

@ankandrew

Your current environment

The output of python collect_env.py
==============================
        System Info
==============================
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.22.1
Libc version                 : glibc-2.35

==============================
       PyTorch Info
==============================
PyTorch version              : 2.7.0+cu126
Is debug build               : False
CUDA used to build PyTorch   : 12.6
ROCM used to build PyTorch   : N/A

==============================
      Python Environment
==============================
Python version               : 3.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0] (64-bit runtime)
Python platform              : Linux-5.15.0-141-generic-x86_64-with-glibc2.35

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : Could not collect
CUDA_MODULE_LOADING set to   : LAZY
GPU models and configuration : 
GPU 0: NVIDIA GeForce RTX 3090
GPU 1: NVIDIA GeForce RTX 3090

Nvidia driver version        : 575.57.08
cuDNN version                : Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.2.1
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
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):                               24
On-line CPU(s) list:                  0-23
Vendor ID:                            AuthenticAMD
Model name:                           AMD Ryzen 9 5900X 12-Core Processor
CPU family:                           25
Model:                                33
Thread(s) per core:                   2
Core(s) per socket:                   12
Socket(s):                            1
Stepping:                             0
Frequency boost:                      enabled
CPU max MHz:                          3700.0000
CPU min MHz:                          2200.0000
BogoMIPS:                             7386.03
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 nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm
Virtualization:                       AMD-V
L1d cache:                            384 KiB (12 instances)
L1i cache:                            384 KiB (12 instances)
L2 cache:                             6 MiB (12 instances)
L3 cache:                             64 MiB (2 instances)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-23
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:   Mitigation; safe RET, no microcode
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; Retpolines; IBPB conditional; IBRS_FW; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

==============================
Versions of relevant libraries
==============================
[pip3] numpy==2.2.6
[pip3] nvidia-cublas-cu12==12.6.4.1
[pip3] nvidia-cuda-cupti-cu12==12.6.80
[pip3] nvidia-cuda-nvrtc-cu12==12.6.77
[pip3] nvidia-cuda-runtime-cu12==12.6.77
[pip3] nvidia-cudnn-cu12==9.5.1.17
[pip3] nvidia-cufft-cu12==11.3.0.4
[pip3] nvidia-cufile-cu12==1.11.1.6
[pip3] nvidia-curand-cu12==10.3.7.77
[pip3] nvidia-cusolver-cu12==11.7.1.2
[pip3] nvidia-cusparse-cu12==12.5.4.2
[pip3] nvidia-cusparselt-cu12==0.6.3
[pip3] nvidia-nccl-cu12==2.26.2
[pip3] nvidia-nvjitlink-cu12==12.6.85
[pip3] nvidia-nvtx-cu12==12.6.77
[pip3] pyzmq==26.4.0
[pip3] torch==2.7.0
[pip3] torchaudio==2.7.0
[pip3] torchvision==0.22.0
[pip3] transformers==4.52.4
[pip3] triton==3.3.0
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
Neuron SDK Version           : N/A
vLLM Version                 : 0.9.1
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
  	GPU0	GPU1	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	PHB	0-23	0		N/A
GPU1	PHB	 X 	0-23	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

==============================
     Environment Variables
==============================
NCCL_CUMEM_ENABLE=0
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
CUDA_MODULE_LOADING=LAZY

🐛 Describe the bug

I'm seeing a lot of the following errors:

[backend_xgrammar.py:160] Failed to advance FSM for request chatcmpl-XXX for tokens 500. Please file an issue.

This happens when specifying the response_format to be of {'type': 'json_object'}, but only when multiple requests are received. See bellow to reproduce.

Reproduce

pip install vllm==0.9.1

vllm serve mediainbox/cogito-14b-gptq-q4 \
  --port=8098 \
  --host=0.0.0.0 \
  --max-model-len 4K \
  --disable-fastapi-docs

Now run the following script:

import concurrent.futures

import requests

OPTIONS = {"temperature": 0.0, "max_tokens": 256, "response_format": {"type": "json_object"}}
PROMPT = [
    {"role": "system", "content": "You are a Named Entity Recognition system. Output should be JSON in a single line."},
    {"role": "user", "content": "Extract entities from this sentence: 'Hi Robert did you go to TacoBox?'"},
]


def call_vllm():
    resp = requests.post(
        "http://localhost:8098/v1/chat/completions",
        json={
            "model": "mediainbox/cogito-14b-gptq-q4",
            "messages": PROMPT,
            **OPTIONS,
        },
        timeout=10,
    )
    return resp.json()["choices"][0]["message"]["content"]


if __name__ == "__main__":
    for concurrency in [1, 2]:
        print(f"\nConcurrency level: {concurrency}")
        with concurrent.futures.ThreadPoolExecutor(max_workers=concurrency) as executor:
            futures = [executor.submit(call_vllm) for _ in range(10)]
            for f in concurrent.futures.as_completed(futures):
                print(f.result())

returns the following:

Concurrency level: 1
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}

Concurrency level: 2
{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
lplplplplplplplplplplplplplplplplplpl{"entities": [{"text": "Robert", "type": "PERSON"}]}
lplplpl{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
lplplplplpl{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
lplplplplpl{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
lplplpl{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
lplplplplpl{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
lplplplplpl{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}
lplplplplplpl{"entities": {"PER": ["Robert"], "ORG": ["TacoBox"]}}
lplplpl{"entities": {"Robert": "PERSON", "TacoBox": "ORGANIZATION"}}

Which totally corrupts the output.

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions