Skip to content

Commit c0bb1b5

Browse files
committed
Fix macOS MPS compatibility in test server startup
Add PYTORCH_ENABLE_MPS_FALLBACK=1 environment variable when starting test servers to allow PyTorch operations to fall back to CPU when MPS (Metal Performance Shaders) doesn't support them. This fixes test failures on macOS with Apple Silicon where operations like aten::linalg_cholesky_ex.L are not implemented for MPS device.
1 parent 8b2e035 commit c0bb1b5

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

tests/test_conversation_logging_server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ def _start_server_with_logging(cls):
9494
env["OPTILLM_API_KEY"] = "optillm"
9595
env["OPTILLM_LOG_CONVERSATIONS"] = "true"
9696
env["OPTILLM_CONVERSATION_LOG_DIR"] = str(cls.temp_log_dir)
97+
# Enable MPS fallback to CPU for unsupported operations (fixes macOS compatibility)
98+
env["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
9799

98100
# Get the project root directory (parent of tests directory)
99101
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

tests/test_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def start_test_server(model: str = TEST_MODEL, port: int = 8000) -> subprocess.P
4242
# Set environment for local inference
4343
env = os.environ.copy()
4444
env["OPTILLM_API_KEY"] = "optillm"
45+
# Enable MPS fallback to CPU for unsupported operations (fixes macOS compatibility)
46+
env["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
4547

4648
# Get the project root directory (parent of tests directory)
4749
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

0 commit comments

Comments
 (0)