PygmalionAI / aphrodite-engine

PygmalionAI's large-scale inference engine
https://pygmalion.chat
GNU Affero General Public License v3.0
772 stars 87 forks source link

[Bug]: bnb quant load error #513

Open theobjectivedad opened 2 weeks ago

theobjectivedad commented 2 weeks ago

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 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-6.5.0-35-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 RTX A6000
GPU 1: NVIDIA RTX A6000
GPU 2: NVIDIA RTX A6000
GPU 3: NVIDIA RTX A6000

Nvidia driver version: 535.171.04
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):                             64
On-line CPU(s) list:                0-63
Vendor ID:                          AuthenticAMD
Model name:                         AMD Ryzen Threadripper PRO 5975WX 32-Cores
CPU family:                         25
Model:                              8
Thread(s) per core:                 2
Core(s) per socket:                 32
Socket(s):                          1
Stepping:                           2
Frequency boost:                    enabled
CPU max MHz:                        7006.6401
CPU min MHz:                        1800.0000
BogoMIPS:                           7186.60
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 brs 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:                          1 MiB (32 instances)
L1i cache:                          1 MiB (32 instances)
L2 cache:                           16 MiB (32 instances)
L3 cache:                           128 MiB (4 instances)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-63
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: Vulnerable: Safe RET, no microcode
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; 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

Additionally:

transformers==4.40.0 bitsandbytes==0.43.1

🐛 Describe the bug

When loading CommandR+ (bnb/4bit) with the following command:

docker run -it -d --name=eleanor-aphrodite-main --restart=unless-stopped --shm-size=15g --ulimit memlock=-1 --ipc=host --entrypoint=python3 --gpus="device=0,1,2,3" --publish=7800:8000 --volume=/mnt/archive/models:/models:ro --health-cmd=timeout 5 bash -c 'cat < /dev/null > /dev/tcp/localhost/8000' --health-start-period=240s --health-interval=15s --health-timeout=8s --health-retries=3 --env=RAY_DEDUP_LOGS=1 --env=APHRODITE_ENGINE_ITERATION_TIMEOUT_S=120 quay.io/theobjectivedad/aphrodite:latest -m aphrodite.endpoints.openai.api_server --model /models/c4ai-command-r-plus-4bit --served-model-name c4ai-command-r-plus-4bit --quantization bnb --context-shift --tensor-parallel-size 4 --gpu-memory-utilization 0.90 --kv-cache-dtype auto --load-format safetensors --tokenizer-mode auto --dtype auto --response-role gpt --port 8000 --host 0.0.0.0

I get this error:

INFO: Tailing logs for eleanor-aphrodite-main. Press CTRL+C to stop.
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/app/aphrodite-engine/aphrodite/endpoints/openai/api_server.py", line 562, in <module>
    run_server(args)
  File "/app/aphrodite-engine/aphrodite/endpoints/openai/api_server.py", line 519, in run_server
    engine = AsyncAphrodite.from_engine_args(engine_args)
  File "/app/aphrodite-engine/aphrodite/engine/async_aphrodite.py", line 340, in from_engine_args
    engine_config = engine_args.create_engine_config()
  File "/app/aphrodite-engine/aphrodite/engine/args_tools.py", line 539, in create_engine_config
    model_config = ModelConfig(
  File "/app/aphrodite-engine/aphrodite/common/config.py", line 145, in __init__
    self._verify_quantization()
  File "/app/aphrodite-engine/aphrodite/common/config.py", line 215, in _verify_quantization
    raise ValueError(
ValueError: Quantization method specified in the model config (bitsandbytes) does not match the quantization method specified in the `quantization` argument (bnb).

The image was build from main on 6/11/2024.

As indicated in the error message, omitting --quantization bnb doesn't seem to have any effect, I the error is from reading the model's config.json file:

...
  "quantization_config": {
    "_load_in_4bit": true,
    "_load_in_8bit": false,
    "bnb_4bit_compute_dtype": "bfloat16",
    "bnb_4bit_quant_storage": "uint8",
    "bnb_4bit_quant_type": "fp4",
    "bnb_4bit_use_double_quant": true,
    "llm_int8_enable_fp32_cpu_offload": false,
    "llm_int8_has_fp16_weight": false,
    "llm_int8_skip_modules": null,
    "llm_int8_threshold": 6.0,
    "load_in_4bit": true,
    "load_in_8bit": false,
    "quant_method": "bitsandbytes"
  },
...

Some notes I took looking into this a little deeper...

Lastly, I'm hesitant to fly solo and just submit a PR on this one since the current bnb quant config is pretty tightly integrated into aphrodite/quantization/bitsandbytes.py, not sure on the best way to proceed.

AlpinDale commented 2 weeks ago

The quant name in aphrodite is unfortunately a bit misleading - I intend to fix this with the next release. The load_in_4bit quant isn't actually bitsandbytes, it's SmoothQuant+. We don't allow loading bnb weights directly yet. This will also be addressed with the next release.

Note that SQ+ is faster and offers better quality than bnb 4bit. bnb reduces throughput compared to fp16, while sq+ increases it by close to 3x.

theobjectivedad commented 2 weeks ago

Got it, ty for looking at this and helping me understand. Do you want me to close this issue?

AlpinDale commented 2 weeks ago

Might be a good idea to keep it open in case someone else has the same issue. I'll close it myself once we have real bitsandbytes support.