feat: enhance GPU support detection and user feedback in the engine interface
This commit is contained in:
@@ -24,6 +24,8 @@ from .core_bridge import (
|
||||
ProviderError,
|
||||
build_provider,
|
||||
detect_architecture,
|
||||
engine_warning,
|
||||
gpu_offload_supported,
|
||||
list_provider_names,
|
||||
load_engine_class,
|
||||
load_settings,
|
||||
@@ -87,10 +89,16 @@ async def get_system() -> SystemInfo:
|
||||
except EngineLoadError as exc:
|
||||
runtime_name = f"unavailable ({exc})"
|
||||
|
||||
# Computed after load_engine_class above, which already imports llama_cpp,
|
||||
# so the probe costs nothing extra here.
|
||||
offload = gpu_offload_supported()
|
||||
|
||||
return SystemInfo(
|
||||
version=__version__,
|
||||
engine_architecture=descriptor.architecture,
|
||||
engine_runtime=runtime_name,
|
||||
engine_gpu_offload=offload,
|
||||
engine_warning=engine_warning(descriptor, offload=offload),
|
||||
template_ok=TEMPLATE_PATH.exists(),
|
||||
python_version=platform.python_version(),
|
||||
metrics={
|
||||
|
||||
@@ -30,6 +30,8 @@ from config import ( # type: ignore[import-not-found]
|
||||
from engine_loader import ( # type: ignore[import-not-found]
|
||||
EngineLoadError,
|
||||
detect_architecture,
|
||||
engine_warning,
|
||||
gpu_offload_supported,
|
||||
load_engine_class,
|
||||
)
|
||||
from prompts import load_test_prompts # type: ignore[import-not-found]
|
||||
@@ -77,6 +79,8 @@ __all__ = [
|
||||
"DEFAULT_PROVIDER_NAME",
|
||||
"EngineLoadError",
|
||||
"detect_architecture",
|
||||
"engine_warning",
|
||||
"gpu_offload_supported",
|
||||
"load_engine_class",
|
||||
"DEFAULT_TEMPERATURE",
|
||||
"MODELS_DIR",
|
||||
|
||||
@@ -204,6 +204,13 @@ class SystemInfo(BaseModel):
|
||||
version: str
|
||||
engine_architecture: str
|
||||
engine_runtime: str
|
||||
# None when llama-cpp-python is absent or too old to report it, which is a
|
||||
# different thing from a confirmed False.
|
||||
engine_gpu_offload: Optional[bool] = None
|
||||
# Set when the detected hardware and the installed build disagree — the
|
||||
# case where the interface would otherwise claim "cuda" while every token
|
||||
# is generated on the CPU.
|
||||
engine_warning: Optional[str] = None
|
||||
template_ok: bool
|
||||
python_version: str
|
||||
metrics: Dict[str, str] = {}
|
||||
|
||||
Reference in New Issue
Block a user