1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""Backend selection utilities for foldit-runner plugins.
This module provides utilities for selecting the appropriate compute backend
(MLX for Apple Silicon, PyTorch for other platforms).
Usage:
from backend_utils import get_backend
backend = get_backend() # Returns "mlx" on macOS, "torch" otherwise
"""
"""Get the appropriate backend for the current platform.
Returns "mlx" on macOS (Apple Silicon optimized), "torch" on other platforms.
Returns:
str: Backend identifier ("mlx" or "torch")
Example:
backend = get_backend()
model = ModelWrapper(backend=backend)
"""
return
"""Check if MLX backend is available.
Returns:
bool: True if running on macOS (where MLX is available)
"""
return ==
"""Check if PyTorch CUDA is available.
Returns:
bool: True if CUDA-capable GPU is available
"""
return
return False
"""Log information about the selected backend.
Args:
logger: Logger instance to use for output
backend: Backend identifier ("mlx" or "torch")
device: Optional device info to log for torch backend
"""