feat: Update CoreML device support and server controls

- Replace 'mps' with 'coreml' as the identifier for Apple CoreML Execution Provider across the codebase.
- Remove Apple chip generation checks and ensure CoreML is available on all macOS arm64 devices.
- Adjust ONNX Runtime session creation to use default CoreML configurations without forcing 'MLProgram'.
- Implement support for MoGe-2 to utilize CoreML with static input shape requirements.
- Enhance server panel to display restart and stop controls consistently across running states, including 'BUSY'.
- Update UI tests to verify new behavior for server controls and cached model display.
- Bump blendjob dependency version to 0.1.16 in packaging tests and configurations.
This commit is contained in:
2026-09-02 10:50:02 +08:00
parent 7f6e47432e
commit 5a011b3b57
24 changed files with 619 additions and 117 deletions

View File

@@ -10,6 +10,9 @@ from .onnx_runtime import select_providers as select_providers
ONNX_FILENAME = "model.onnx"
MIN_TOKENS = 1200
MAX_TOKENS = 3600
COREML_PROVIDER_OPTIONS = {
"RequireStaticInputShapes": "1",
}
def is_onnx_model(model_directory):
@@ -18,7 +21,11 @@ def is_onnx_model(model_directory):
def create_session(model_directory, requested_device="auto"):
path = Path(model_directory) / ONNX_FILENAME
return create_runtime_session(path, requested_device)
return create_runtime_session(
path,
requested_device,
coreml_options=COREML_PROVIDER_OPTIONS,
)
def normalized_view_plane_uv(width, height, dtype):

View File

@@ -1,12 +1,5 @@
"""Shared ONNX Runtime session helpers."""
COREML_PROVIDER_OPTIONS = {
"ModelFormat": "MLProgram",
"MLComputeUnits": "ALL",
"RequireStaticInputShapes": "0",
"EnableOnSubgraphs": "0",
}
CUDA_PROVIDER_OPTIONS = {
"arena_extend_strategy": "kSameAsRequested",
}
@@ -17,14 +10,20 @@ def select_providers(requested, available):
providers_for_device = {
"cuda": ("CUDAExecutionProvider", "DmlExecutionProvider"),
"directml": ("DmlExecutionProvider",),
"mps": ("CoreMLExecutionProvider",),
"coreml": ("CoreMLExecutionProvider",),
"cpu": ("CPUExecutionProvider",),
}
if requested != "auto":
candidates = providers_for_device[requested]
for provider in candidates:
if provider in available:
return [provider]
providers = [provider]
if (
provider == "CoreMLExecutionProvider"
and "CPUExecutionProvider" in available
):
providers.append("CPUExecutionProvider")
return providers
if "CPUExecutionProvider" in available:
return ["CPUExecutionProvider"]
raise RuntimeError(
@@ -44,7 +43,12 @@ def select_providers(requested, available):
return providers
def create_session(path, requested_device="auto"):
def create_session(
path,
requested_device="auto",
*,
coreml_options=None,
):
import onnxruntime
providers = select_providers(
@@ -55,8 +59,8 @@ def create_session(path, requested_device="auto"):
for provider in providers:
if provider == "CUDAExecutionProvider":
provider = (provider, dict(CUDA_PROVIDER_OPTIONS))
elif provider == "CoreMLExecutionProvider":
provider = (provider, dict(COREML_PROVIDER_OPTIONS))
elif provider == "CoreMLExecutionProvider" and coreml_options:
provider = (provider, dict(coreml_options))
configured_providers.append(provider)
return onnxruntime.InferenceSession(
str(path),