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]: OpenAI LogProbs format for Chat-Completion is incorrect #5008

Closed
br3no opened this issue May 23, 2024 · 5 comments · Fixed by #5029
Closed

[Bug]: OpenAI LogProbs format for Chat-Completion is incorrect #5008

br3no opened this issue May 23, 2024 · 5 comments · Fixed by #5029
Labels
bug Something isn't working

Comments

@br3no
Copy link
Contributor

br3no commented May 23, 2024

Your current environment

Collecting environment information...
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: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.29.2
Libc version: glibc-2.31

Python version: 3.8.18 (default, Oct  2 2023, 15:02:11)  [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-101-generic-x86_64-with-glibc2.2.5
Is CUDA available: True
CUDA runtime version: 12.4.131
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: 545.23.08
cuDNN version: Probably one of the following:
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn.so.8.9.5
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.9.5
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.9.5
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.9.5
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.9.5
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.9.5
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.9.5
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
Byte Order:                         Little Endian
Address sizes:                      46 bits physical, 48 bits virtual
CPU(s):                             32
On-line CPU(s) list:                0-31
Thread(s) per core:                 2
Core(s) per socket:                 16
Socket(s):                          1
NUMA node(s):                       1
Vendor ID:                          GenuineIntel
CPU family:                         6
Model:                              85
Model name:                         Intel(R) Core(TM) i9-7960X CPU @ 2.80GHz
Stepping:                           4
CPU MHz:                            1204.917
CPU max MHz:                        4400,0000
CPU min MHz:                        1200,0000
BogoMIPS:                           5599.85
Virtualization:                     VT-x
L1d cache:                          512 KiB
L1i cache:                          512 KiB
L2 cache:                           16 MiB
L3 cache:                           22 MiB
NUMA node0 CPU(s):                  0-31
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        KVM: Mitigation: VMX disabled
Vulnerability L1tf:                 Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:                  Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:             Mitigation; PTI
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             Mitigation; IBRS
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; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Mitigation; Clear CPU buffers; SMT vulnerable
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 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 cdp_l3 invpcid_single pti ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req md_clear flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] mypy==1.9.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.24.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] torch==2.3.0
[pip3] triton==2.3.0
[pip3] vllm-nccl-cu12==2.18.1.0.2.0
[conda] Could not collectROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.4.2
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    GPU1    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      SYS     0-31    0               N/A
GPU1    SYS      X      0-31    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

🐛 Describe the bug

The output format of the logprobs in the chat OpenAI server has been mostly copied from the legacy completion server, according to the description in #2918.

Unfortunately, the format of this part of the answer is not the same in the official OpenAI API.

While the completion logprobs look like this:
grafik
(cf. https://platform.openai.com/docs/api-reference/completions/object)

The chat completion logprobs look like this:
grafik
(cf. https://platform.openai.com/docs/api-reference/chat/object)

OpenAI clients will have problems parsing the answer correctly.

@br3no
Copy link
Contributor Author

br3no commented May 24, 2024

@DarkLight1337 you were quicker by one hour, but you still have failing tests, so I win 😜

@DarkLight1337
Copy link
Member

It's not a competition xD We can combine our solutions in your PR if need be.

@br3no
Copy link
Contributor Author

br3no commented May 24, 2024

I know! I was being (not so) funny.

@DarkLight1337
Copy link
Member

DarkLight1337 commented May 24, 2024

I have updated my PR with more test cases. From my understanding, the behaviour of disabling logprobs and specifying zero top logprobs should be distinct. In particular:

  • Disabling logprobs should return no logprobs at all:
    • Completions API: Input logprobs=None should result in output top_logprobs==None
    • Chat Completions API: Input logprobs=False should result in output len(top_logprobs)==0
  • Specifying zero top logprobs should return the logprob for the output token only for Completions API (if it exists):
    • Completions API: Input logprobs=0 should result in output len(top_logprobs)<=1
    • Chat Completions API: Input logprobs=True,top_logprobs=0 should result in output len(top_logprobs)<=k len(top_logprobs)==0
  • Specifying k top logprobs should return the top k items, plus the logprob for the output token only for Completions API (if it exists):
    • Completions API: Input logprobs=k should result in output len(top_logprobs)<=k+1
    • Chat Completions API: Input logprobs=True,top_logprobs=k should result in output len(top_logprobs)<=k+1 len(top_logprobs)==k

Edit: Thanks @br3no for the correction!

@DarkLight1337
Copy link
Member

My PR #5026 now passes all tests as well.

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.

2 participants