当前环境
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.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-107-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: NVIDIA H100 80GB HBM3
GPU 1: NVIDIA H100 80GB HBM3
GPU 2: NVIDIA H100 80GB HBM3
GPU 3: NVIDIA H100 80GB HBM3
GPU 4: NVIDIA H100 80GB HBM3
GPU 5: NVIDIA H100 80GB HBM3
GPU 6: NVIDIA H100 80GB HBM3
GPU 7: NVIDIA H100 80GB HBM3
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: 46 bits physical, 57 bits virtual
Byte Order: Little Endian
CPU(s): 224
On-line CPU(s) list: 0-111
Off-line CPU(s) list: 112-223
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Platinum 8480+
CPU family: 6
Model: 143
Thread(s) per core: 1
Core(s) per socket: 56
Socket(s): 2
Stepping: 8
Frequency boost: enabled
CPU max MHz: 2001.0000
CPU min MHz: 0.0000
BogoMIPS: 4000.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 tsc_known_freq 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 cat_l2 cdp_l3 invpcid_single intel_ppin cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 5.3 MiB (112 instances)
L1i cache: 3.5 MiB (112 instances)
L2 cache: 224 MiB (112 instances)
L3 cache: 210 MiB (2 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0-55
NUMA node1 CPU(s): 56-111
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: 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; Enhanced IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Versions of relevant libraries:
[pip3] mypy==1.9.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] sentence-transformers==3.0.1
[pip3] torch==2.3.0
[pip3] torchvision==0.18.1
[pip3] transformers==4.41.2
[pip3] triton==2.3.0
[conda] Could not collect
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 GPU1 GPU2 GPU3 GPU4 GPU5 GPU6 GPU7 NIC0 NIC1 NIC2 NIC3 NIC4 NIC5 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X NV18 NV18 NV18 NV18 NV18 NV18 NV18 PIX NODE NODE NODE SYS SYS 0-55 0 N/A
GPU1 NV18 X NV18 NV18 NV18 NV18 NV18 NV18 NODE NODE NODE NODE SYS SYS 0-55 0 N/A
GPU2 NV18 NV18 X NV18 NV18 NV18 NV18 NV18 NODE PIX NODE NODE SYS SYS 0-55 0 N/A
GPU3 NV18 NV18 NV18 X NV18 NV18 NV18 NV18 NODE NODE NODE NODE SYS SYS 0-55 0 N/A
GPU4 NV18 NV18 NV18 NV18 X NV18 NV18 NV18 SYS SYS SYS SYS PIX NODE 56-111 1 N/A
GPU5 NV18 NV18 NV18 NV18 NV18 X NV18 NV18 SYS SYS SYS SYS NODE NODE 56-111 1 N/A
GPU6 NV18 NV18 NV18 NV18 NV18 NV18 X NV18 SYS SYS SYS SYS NODE PIX 56-111 1 N/A
GPU7 NV18 NV18 NV18 NV18 NV18 NV18 NV18 X SYS SYS SYS SYS NODE NODE 56-111 1 N/A
NIC0 PIX NODE NODE NODE SYS SYS SYS SYS X NODE NODE NODE SYS SYS
NIC1 NODE NODE PIX NODE SYS SYS SYS SYS NODE X NODE NODE SYS SYS
NIC2 NODE NODE NODE NODE SYS SYS SYS SYS NODE NODE X PIX SYS SYS
NIC3 NODE NODE NODE NODE SYS SYS SYS SYS NODE NODE PIX X SYS SYS
NIC4 SYS SYS SYS SYS PIX NODE NODE NODE SYS SYS SYS SYS X NODE
NIC5 SYS SYS SYS SYS NODE NODE PIX NODE SYS SYS SYS SYS NODE X
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
NIC Legend:
NIC0: mlx5_0
NIC1: mlx5_1
NIC2: mlx5_2
NIC3: mlx5_3
NIC4: mlx5_4
NIC5: mlx5_5
🐛 描述错误
加载一个具有巨大上下文长度(100k+)的模型,在为KV缓存分配空间时会导致内存不足错误。虽然从技术上讲,模型确实不适合,但这样的模型仍然应该从较小的上下文大小开始。
一个容易复现的例子是 gradientai/Llama-3-8B-Instruct-Gradient-1048k
,它有8B,上下文长度为1M。它将无法在任何单个GPU上启动:
python -m vllm.entrypoints.openai.api_server --model gradientai/Llama-3-8B-Instruct-Gradient-1048k
结果如下:
INFO 06-26 07:48:15 model_runner.py:160] Loading model weights took 15.2075 GB
[rank0]: Traceback (most recent call last):
[rank0]: File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
[rank0]: return _run_code(code, main_globals, None,
[rank0]: File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
[rank0]: exec(code, run_globals)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/entrypoints/openai/api_server.py", line 196, in <module>
[rank0]: engine = AsyncLLMEngine.from_engine_args(
[rank0]: File "/home/adam/work/vllm-parasail/vllm/engine/async_llm_engine.py", line 415, in from_engine_args
[rank0]: engine = cls(
[rank0]: File "/home/adam/work/vllm-parasail/vllm/engine/async_llm_engine.py", line 355, in __init__
[rank0]: self.engine = self._init_engine(*args, **kwargs)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/engine/async_llm_engine.py", line 490, in _init_engine
[rank0]: return engine_class(*args, **kwargs)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/engine/llm_engine.py", line 243, in __init__
[rank0]: self._initialize_kv_caches()
[rank0]: File "/home/adam/work/vllm-parasail/vllm/engine/llm_engine.py", line 326, in _initialize_kv_caches
[rank0]: self.model_executor.determine_num_available_blocks())
[rank0]: File "/home/adam/work/vllm-parasail/vllm/executor/gpu_executor.py", line 75, in determine_num_available_blocks
[rank0]: return self.driver_worker.determine_num_available_blocks()
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
[rank0]: return func(*args, **kwargs)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/worker/worker.py", line 163, in determine_num_available_blocks
[rank0]: self.model_runner.profile_run()
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
[rank0]: return func(*args, **kwargs)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/worker/model_runner.py", line 844, in profile_run
[rank0]: self.execute_model(seqs, kv_caches)
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
[rank0]: return func(*args, **kwargs)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/worker/model_runner.py", line 749, in execute_model
[rank0]: hidden_states = model_executable(
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
[rank0]: return self._call_impl(*args, **kwargs)
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
[rank0]: return forward_call(*args, **kwargs)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/model_executor/models/llama.py", line 371, in forward
[rank0]: hidden_states = self.model(input_ids, positions, kv_caches,
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
[rank0]: return self._call_impl(*args, **kwargs)
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
[rank0]: return forward_call(*args, **kwargs)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/model_executor/models/llama.py", line 288, in forward
[rank0]: hidden_states, residual = layer(
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
[rank0]: return self._call_impl(*args, **kwargs)
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
[rank0]: return forward_call(*args, **kwargs)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/model_executor/models/llama.py", line 237, in forward
[rank0]: hidden_states = self.mlp(hidden_states)
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
[rank0]: return self._call_impl(*args, **kwargs)
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
[rank0]: return forward_call(*args, **kwargs)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/model_executor/models/llama.py", line 79, in forward
[rank0]: gate_up, _ = self.gate_up_proj(x)
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
[rank0]: return self._call_impl(*args, **kwargs)
[rank0]: File "/home/adam/venvs/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
[rank0]: return forward_call(*args, **kwargs)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/model_executor/layers/linear.py", line 298, in forward
[rank0]: output_parallel = self.quant_method.apply(self, input_, bias)
[rank0]: File "/home/adam/work/vllm-parasail/vllm/model_executor/layers/linear.py", line 111, in apply
[rank0]: return F.linear(x, weight, bias)
[rank0]: torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 56.00 GiB. GPU
3条答案
按热度按时间erhoui1w1#
这个错误出现在用于确定内存使用情况的
profile_run
中。如果我修补代码以忽略此错误,并在下面的几行修补模型长度以使raise_if_cache_size_invalid
满意,模型将开始运行。当然,它不会达到完整的 1M 上下文,但它可以在具有 80GB GPU 的 200k 上工作。随着流行的模型将它们的上下文长度扩展到超过 8k,这对小型 GPU 的用户来说将更加紧迫。
如果还没有计划支持大型上下文模型,我很乐意提交我的猴子补丁。
nc1teljy2#
你可以手动设置
--max-model-len
来减少上下文长度。不确定是否应该根据可用内存自动限制上下文长度,@simon-mo有什么想法吗?rdrgkggo3#
你可以手动设置
--max-model-len
以减少上下文长度。不确定是否应该根据可用内存自动限制上下文长度,@simon-mo 有什么想法吗?同意,纯粹的自动设置可能会给人们留下错误的印象,即使他们的硬件不允许,他们也可以使用模型的完整上下文。一个替代方案是
--max-model-len max
,无论什么情况都会启动模型并在日志中报告实际的最大上下文大小。目前,某人必须启动 vllm,查看崩溃,从日志中解析出最大上下文大小,并使用
--max-model-len
设置它。但这只有在profile_run()
不会出现异常的情况下才可能发生(在 OP 中提到的异常),在这种情况下,用户必须猜测最大模型长度(实际最大值的日志消息稍后打印,并取决于profile_run()
成功)。