PygmalionAI / aphrodite-engine

Large-scale LLM inference engine
https://aphrodite.pygmalion.chat
GNU Affero General Public License v3.0
1.09k stars 120 forks source link

[Bug]: (exl2) First request with guided_json/guided_regex param creates crash loop for 10 minutes #521

Closed khalo-sa closed 2 months ago

khalo-sa commented 4 months ago

Your current environment

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 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.3
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-112-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.1.105
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA L40
Nvidia driver version: 555.42.02
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):                             256
On-line CPU(s) list:                0-255
Vendor ID:                          AuthenticAMD
Model name:                         AMD EPYC 7763 64-Core Processor
CPU family:                         25
Model:                              1
Thread(s) per core:                 2
Core(s) per socket:                 64
Socket(s):                          2
Stepping:                           1
Frequency boost:                    enabled
CPU max MHz:                        3529.0520
CPU min MHz:                        1500.0000
BogoMIPS:                           4900.46
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 pcid 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 invpcid_single 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 amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm
Virtualization:                     AMD-V
L1d cache:                          4 MiB (128 instances)
L1i cache:                          4 MiB (128 instances)
L2 cache:                           64 MiB (128 instances)
L3 cache:                           512 MiB (16 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-63,128-191
NUMA node1 CPU(s):                  64-127,192-255
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: Mitigation; safe RET
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==1.26.4
[pip3] torch==2.3.0
[pip3] triton==2.3.0
[conda] Could not collect ROCM Version: Could not collect
Aphrodite Version: 0.5.3
Aphrodite Build Flags:
CUDA Archs: 6.1 7.0 7.5 8.0 8.6 8.9 9.0+PTX; ROCm: Disabled

🐛 Describe the bug

Hey guys, I'm running aphrodite in Docker with the following compose file:

  mistral7bv3:
    image: alpindale/aphrodite-engine
    restart: always
    runtime: nvidia
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              capabilities: [ gpu ]
              device_ids: [ '3' ]
    environment:
      MODEL_NAME: "/models/exl2/bartowski_Mistral-7B-Instruct-v0.3-exl2_6_5"
      CMD_ADDITIONAL_ARGUMENTS: "--chat-template /models/templates/mistral-chat.jinja"
      CONTEXT_LENGTH: "8192"
      GPU_MEMORY_UTILIZATION: "0.2"
      NUM_GPUS: 1
      HF_HOME: "/hf_cache"
      APHRODITE_LOG_LEVEL: "DEBUG"
    ports:
      - "8202:7860"
    user: root
    volumes:
      - /data/.cache/huggingface:/hf_cache
      - /data/models:/models
    ipc: host

Once the server has started, I can start sending normal generation requests without issues. However, as soon as I send the first request with guided_json or guided_regex param, the request never terminates, and I'm getting crazy logs that are so long that I attached them as a file here: aphrodite-startup-bug.txt

As you can see in the logs, after about 10 minutes the crash logs disappear and I can start sending the same type of request (with guided_json/guided_regex) again without the error. However, I think I have experienced the same error spontaneosly again later on. As I'm dependent on structured generation in my projects, I currently cannot rely on Aphrodite which is a real bummer.

While in the error state, the server is stuck with CPU Utilization at 100%, GPU Utilization at 0%, and doesn't accept new generation requests of any kind.

I'm getting the same behavior with three exl2 models that I tried (llama3-70b, mistral7b-v3, qwen2-7b), therefore, I am assuming this is related to exl2. Though, have a feeling that I had a similar behavior with gguf in the past, which probably made me switch to exl2, but I would have to check that again to say for certain.

sgsdxzy commented 4 months ago

might be some problems with outlines printing debug info, can you try lmfe instead? pass "guided_decoding_backend": ""lm-format-enforcer" in your request. outlines needs to compile the regex, and the process is very slow, lmfe doesn't. On the other hand, once compiled, outlines is faster than lmfe. So outlines is only suitable for the case where the same regex is applied to all subsequent requests.

khalo-sa commented 2 months ago

Hey @sgsdxzy , you were right. Only if APHRODITE_LOG_LEVEL is set to DEBUG am I getting the mentioned excessive logs from Outlines. But I wonder whether the sheer amount of logs makes the server crash/hang or if another side effect is responsible for it? Either way, not setting APHRODITE_LOG_LEVEL solved it for me.