vllm: [Bug]: BitsandBytes quantization is not working as expected
Your current environment
$ python collect_env.py
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.5
Libc version: glibc-2.35
Python version: 3.11.9 (main, Apr 19 2024, 16:48:06) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-105-generic-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: Tesla T4
Nvidia driver version: 550.54.15
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.7
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: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 72
On-line CPU(s) list: 0-71
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz
CPU family: 6
Model: 85
Thread(s) per core: 2
Core(s) per socket: 18
Socket(s): 2
Stepping: 4
BogoMIPS: 6000.00
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 smx 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 intel_ppin 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 pku ospke md_clear flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 1.1 MiB (36 instances)
L1i cache: 1.1 MiB (36 instances)
L2 cache: 36 MiB (36 instances)
L3 cache: 49.5 MiB (2 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70
NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71
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
Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] torch==2.3.0
[pip3] transformers==4.41.2
[pip3] triton==2.3.0
[conda] numpy 1.26.4 pypi_0 pypi
[conda] nvidia-nccl-cu12 2.20.5 pypi_0 pypi
[conda] torch 2.3.0 pypi_0 pypi
[conda] transformers 4.41.2 pypi_0 pypi
[conda] triton 2.3.0 pypi_0 pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.5.0.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X 1,3,5,7,9,11 1 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
With the latest bitsandbytes quantization feature, the official Llama3-8B-Instruct produces garbage.
Start the server:
$ python -m vllm.entrypoints.openai.api_server --dtype half --served-model-name llama3-8b --model /models/Meta-Llama-3-8B-Instruct --load-format bitsandbytes --quantization bitsandbytes
INFO 06-15 14:33:24 api_server.py:177] vLLM API server version 0.5.0.post1
INFO 06-15 14:33:24 api_server.py:178] args: Namespace(host=None, port=8000, uvicorn_log_level='info', allow_credentials=False, allowed_origins=['*'], allowed_methods=['*'], allowed_headers=['*'], api_key=None, lora_modules=None, chat_template=None, response_role='assistant',
ssl_keyfile=None, ssl_certfile=None, ssl_ca_certs=None, ssl_cert_reqs=0, root_path=None, middleware=[], model='/models/Meta-Llama-3-8B-Instruct', tokenizer=None, skip_tokenizer_init=False, revision=None, code_revision=None, tokenizer_revision=None, tokenizer_mode='auto', trust
_remote_code=False, download_dir=None, load_format='bitsandbytes', dtype='half', kv_cache_dtype='auto', quantization_param_path=None, max_model_len=None, guided_decoding_backend='outlines', distributed_executor_backend=None, worker_use_ray=False, pipeline_parallel_size=1, tens
or_parallel_size=1, max_parallel_loading_workers=None, ray_workers_use_nsight=False, block_size=16, enable_prefix_caching=False, disable_sliding_window=False, use_v2_block_manager=False, num_lookahead_slots=0, seed=0, swap_space=4, gpu_memory_utilization=0.9, num_gpu_blocks_ov
erride=None, max_num_batched_tokens=None, max_num_seqs=256, max_logprobs=20, disable_log_stats=False, quantization='bitsandbytes', rope_scaling=None, rope_theta=None, enforce_eager=False, max_context_len_to_capture=None, max_seq_len_to_capture=8192, disable_custom_all_reduce=F
alse, tokenizer_pool_size=0, tokenizer_pool_type='ray', tokenizer_pool_extra_config=None, enable_lora=False, max_loras=1, max_lora_rank=16, lora_extra_vocab_size=256, lora_dtype='auto', long_lora_scaling_factors=None, max_cpu_loras=None, fully_sharded_loras=False, device='auto
', image_input_type=None, image_token_id=None, image_input_shape=None, image_feature_size=None, image_processor=None, image_processor_revision=None, disable_image_processor=False, scheduler_delay_factor=0.0, enable_chunked_prefill=False, speculative_model=None, num_speculative
_tokens=None, speculative_max_model_len=None, speculative_disable_by_batch_size=None, ngram_prompt_lookup_max=None, ngram_prompt_lookup_min=None, model_loader_extra_config=None, preemption_mode=None, served_model_name=['llama3-8b'], qlora_adapter_name_or_path=None, engine_use_
ray=False, disable_log_requests=False, max_log_len=None)
WARNING 06-15 14:33:24 config.py:1222] Casting torch.bfloat16 to torch.float16.
WARNING 06-15 14:33:24 config.py:217] bitsandbytes quantization is not fully optimized yet. The speed can be slower than non-quantized models.
INFO 06-15 14:33:24 llm_engine.py:161] Initializing an LLM engine (v0.5.0.post1) with config: model='/models/Meta-Llama-3-8B-Instruct', speculative_config=None, tokenizer='/models/Meta-Llama-3-8B-Instruct', skip_tokenizer_init=False, tokenizer_mode=auto, revision=None, rope_sc
aling=None, rope_theta=None, tokenizer_revision=None, trust_remote_code=False, dtype=torch.float16, max_seq_len=8192, download_dir=None, load_format=LoadFormat.BITSANDBYTES, tensor_parallel_size=1, disable_custom_all_reduce=False, quantization=bitsandbytes, enforce_eager=False
, kv_cache_dtype=auto, quantization_param_path=None, device_config=cuda, decoding_config=DecodingConfig(guided_decoding_backend='outlines'), seed=0, served_model_name=llama3-8b)
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
INFO 06-15 14:33:25 selector.py:131] Cannot use FlashAttention-2 backend for Volta and Turing GPUs.
INFO 06-15 14:33:25 selector.py:51] Using XFormers backend.
INFO 06-15 14:33:26 selector.py:131] Cannot use FlashAttention-2 backend for Volta and Turing GPUs.
INFO 06-15 14:33:26 selector.py:51] Using XFormers backend.
INFO 06-15 14:33:26 loader.py:744] Loading weights with BitsAndBytes quantization. May take a while ...
INFO 06-15 14:33:32 model_runner.py:160] Loading model weights took 5.3128 GB
INFO 06-15 14:34:17 gpu_executor.py:83] # GPU blocks: 2595, # CPU blocks: 2048
INFO 06-15 14:34:19 model_runner.py:889] Capturing the model for CUDA graphs. This may lead to unexpected consequences if the model is not static. To run the model in eager mode, set 'enforce_eager=True' or use '--enforce-eager' in the CLI.
INFO 06-15 14:34:19 model_runner.py:893] CUDA graphs can take additional 1~3 GiB memory per GPU. If you are running out of memory, consider decreasing `gpu_memory_utilization` or enforcing eager mode. You can also reduce the `max_num_seqs` as needed to decrease memory usage.
INFO 06-15 14:35:47 model_runner.py:965] Graph capturing finished in 88 secs.
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
INFO 06-15 14:35:48 serving_chat.py:92] Using default chat template:
INFO 06-15 14:35:48 serving_chat.py:92] {% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>
INFO 06-15 14:35:48 serving_chat.py:92]
INFO 06-15 14:35:48 serving_chat.py:92] '+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|>
INFO 06-15 14:35:48 serving_chat.py:92]
INFO 06-15 14:35:48 serving_chat.py:92] ' }}{% endif %}
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
WARNING 06-15 14:35:48 serving_embedding.py:141] embedding_mode is False. Embedding API will not work.
INFO: Started server process [2622103]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
Test the service:
$ curl localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "llama3-8b", "messages": [{"role": "user", "content": "Hi!"}], "max_tokens": 128}'
{"id":"cmpl-5a7d1b331b8345f88433fbaf0da9c7e2","object":"chat.completion","created":1718460912,"model":"llama3-8b","choices":[{"index":0,"message":{"role":"assistant","content":" the!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!","tool_calls":[]},"logprobs":null,"finish_reason":"length","stop_reason":null}],"usage":{"prompt_tokens":12,"total_tokens":140,"completion_tokens":128}}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 32 (19 by maintainers)
You are right, only Llama is supported by now. More models to come.
Thanks for reporting this issue @QwertyJack!
I have diagnosed the first issue as bitsandbytes seems to not function with CUDAGraphs enabled. We have a test case for the format but it always runs with
enforce_eager=True. If I replace it withenforce_eager=False, then the test fails. @chenqianfzh can you look into this test (cc @Yard1)?The second issue is that this isnât sufficient to produce good results. I still see gibberish in the output of Llama 3 8B with
enforce_eagerset. I donât know enough about the quality of bnb nf4 quantization to compare at this point, but this implementation doesnât seem usable at this point. @chenqianfzh could you add your thoughts on this?Example with
--enforce-eagerserver:Client:
https://github.com/bitsandbytes-foundation/bitsandbytes/issues/1308 this issue got fixed , this will enable not to enforce eager mode ? @chenqianfzh @kylesayrs
@QwertyJack
@thesues and I had an offline discussion offline earlier today. We will work together on bitsandbytes in vllm together.
The following is the list of items that we are working and will work on:
Root cause unknown yet. I just send out a PR of workaround, https://github.com/vllm-project/vllm/pull/6846, to enforce eager mode with bnb temporarily. Hope it can cause less confusion while we are still working on the bug.
support load_in_8bit: work under the way
support fp4
support more models
support Bnb with TP: there is an initial PR out which only support NF4. But it needs more revision after the above items are done.
bitsandbytes perf improvement: due to bitsandbytes bug ( https://github.com/TimDettmers/bitsandbytes/issues/1235)), extra tensor copy is needed in computation. Need to update vllm code after the bug is fixed.
Please let us know if you see any problems with this plan. Thanks.
@QwertyJack @mgoin
The issue of bnb with Llama3 is root-caused, which is a bug in processing GQA. I found the PR from @thesues https://github.com/vllm-project/vllm/pull/5753 fixed this issue.
Especially, the following change in loader.py does the job:
Yet, PR 5753 does more that fixing that bug. It is also about loading pre-quant bnb mode. Could you take a look and upstream it if it looks right to you?
Thanks.