[Hardware][Apple] Native support for macOS Apple Silicon (#11696)

Signed-off-by: Wallas Santos <wallashss@ibm.com>
Co-authored-by: Michael Goin <michael@neuralmagic.com>
This commit is contained in:
Wallas Henrique
2025-01-08 16:35:49 +08:00
committed by GitHub
co-authored by Michael Goin
parent a1b2b8606e
commit cfd3219f58
11 changed files with 210 additions and 30 deletions
+12
View File
@@ -4,6 +4,7 @@ import enum
import hashlib
import json
import os
import sys
import warnings
from contextlib import contextmanager
from dataclasses import dataclass, field, replace
@@ -2259,6 +2260,17 @@ def _get_and_verify_dtype(
"supported for POWERPC.")
torch_dtype = torch.bfloat16
# TODO: change this condition to check if the platform support bf16
# instead of checking the OS. For instance M2 shall supports bf16
# already. But we need to modify `cpu_extension.cmake` to activate
# the feature in the build.
if (current_platform.is_cpu() and sys.platform.startswith("darwin")
and current_platform.get_cpu_architecture()
== CpuArchEnum.ARM and config_dtype == torch.bfloat16):
logger.info("For macOS with Apple Silicon, currently bfloat16 "
"is not supported. Setting dtype to float16.")
torch_dtype = torch.float16
if current_platform.is_hpu() and config_dtype == torch.float16:
logger.info(
"For HPU, we cast models to bfloat16 instead of"
+3
View File
@@ -7,6 +7,7 @@ import os
import re
import signal
import socket
import sys
import tempfile
import uuid
from argparse import Namespace
@@ -805,6 +806,8 @@ async def run_server(args, **uvicorn_kwargs) -> None:
ssl_certfile=args.ssl_certfile,
ssl_ca_certs=args.ssl_ca_certs,
ssl_cert_reqs=args.ssl_cert_reqs,
# Workaround to work on macOS
fd=sock.fileno() if sys.platform.startswith("darwin") else None,
**uvicorn_kwargs,
)
+7
View File
@@ -524,6 +524,13 @@ def get_open_port() -> int:
def find_process_using_port(port: int) -> Optional[psutil.Process]:
# TODO: We can not check for running processes with network
# port on macOS. Therefore, we can not have a full graceful shutdown
# of vLLM. For now, let's not look for processes in this case.
# Ref: https://www.florianreinhard.de/accessdenied-in-psutil/
if sys.platform.startswith("darwin"):
return None
for conn in psutil.net_connections():
if conn.laddr.port == port:
try: