Skip to content

Commit 84c28d5

Browse files
author
reidliu41
committed
[Misc][MacOS] fix bfloat16 error
Signed-off-by: reidliu41 <reid201711@gmail.com>
1 parent 3d2779c commit 84c28d5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

vllm/config.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import inspect
88
import json
99
import re
10+
import sys
1011
import textwrap
1112
import uuid
1213
import warnings
@@ -3064,7 +3065,7 @@ def _get_and_verify_dtype(
30643065
torch_dtype = torch.bfloat16
30653066

30663067
# Deal with torch dtype fallback for device compatibility.
3067-
from vllm.platforms import current_platform
3068+
from vllm.platforms import CpuArchEnum, current_platform
30683069
if torch_dtype not in current_platform.supported_dtypes:
30693070
device_name = current_platform.get_device_name()
30703071

@@ -3088,6 +3089,15 @@ def _get_and_verify_dtype(
30883089
"using float16 by default. Please specify `dtype` if you "
30893090
"want to use float16.")
30903091
torch_dtype = torch.bfloat16
3092+
3093+
if (current_platform.is_cpu() and sys.platform.startswith("darwin")
3094+
and current_platform.get_cpu_architecture()
3095+
== CpuArchEnum.ARM and config_dtype == torch.bfloat16):
3096+
logger.info(
3097+
"For macOS with Apple Silicon, currently using float16 "
3098+
"by default. Please specify `dtype` if you "
3099+
"want to use bfloat16.")
3100+
torch_dtype = torch.float16
30913101
elif dtype == "float16" and config.model_type == "plamo2":
30923102
logger.warning(
30933103
"For PLaMo2, using float16 is unstable and might cause "

0 commit comments

Comments
 (0)