Snider Virgil commited on
Commit
b5a2983
·
1 Parent(s): ec7f6ce

fix: capability probe promotes both backends independently

Browse files

detect_default_types() previously fell back to {mlx} when mlx_lm
wasn't importable, which would cause charon (Linux, no mlx) to try
mlx targets and fail. Now each backend is probed independently:

mlx = mlx_lm importable + Darwin
gguf = openai importable

Studio (mac) sees {mlx, gguf} since openai is always in the PEP 723
closure. Charon (Linux) sees {gguf} since mlx_lm import raises. Empty
detection triggers an explicit error in main() asking the caller to
set LEM_TYPES, instead of silently routing to an empty target list.

Co-Authored-By: Virgil <virgil@lethean.io>

Files changed (1) hide show
  1. eval.py +25 -7
eval.py CHANGED
@@ -748,22 +748,34 @@ SUPPORTED_TYPES = {"mlx", "gguf"}
748
  def detect_default_types():
749
  """Figure out which target types this machine can run by capability probe.
750
 
751
- Apple Silicon + mlx_lm installed mlx. Anything else (or explicit opt-in)
752
- → gguf via an OpenAI-compatible endpoint (Ollama / llama.cpp server).
753
- Returns a set. Workers override with --type or the LEM_TYPES env var.
 
 
 
 
 
 
 
754
  """
755
  import platform
756
  types = set()
 
757
  try:
758
  import mlx_lm # noqa: F401
759
  if platform.system() == "Darwin":
760
  types.add("mlx")
761
  except ImportError:
762
  pass
763
- # gguf path will be available once gguf_wrapper lands — for now it's
764
- # opt-in via explicit --type gguf so workers don't silently skip
765
- # mlx-only targets when the wrapper is absent.
766
- return types or {"mlx"}
 
 
 
 
767
 
768
 
769
  def _print_target_table(targets, highlight_types=None):
@@ -819,6 +831,12 @@ def main():
819
  allowed_types = set(os.environ["LEM_TYPES"].split(","))
820
  else:
821
  allowed_types = detect_default_types()
 
 
 
 
 
 
822
 
823
  if args.list_targets:
824
  _print_target_table(all_targets, highlight_types=allowed_types)
 
748
  def detect_default_types():
749
  """Figure out which target types this machine can run by capability probe.
750
 
751
+ Each type is probed independently and added if the dependency is present:
752
+
753
+ mlx : Apple Silicon (Darwin) with mlx_lm importable
754
+ gguf : any machine with the `openai` client importable (Ollama's
755
+ endpoint availability is checked at wrapper __init__ time
756
+ via a lightweight probe request)
757
+
758
+ Workers override with --type <name> or the LEM_TYPES env var. If the
759
+ probe finds zero types, the caller gets an explicit error from main()
760
+ asking them to set LEM_TYPES.
761
  """
762
  import platform
763
  types = set()
764
+
765
  try:
766
  import mlx_lm # noqa: F401
767
  if platform.system() == "Darwin":
768
  types.add("mlx")
769
  except ImportError:
770
  pass
771
+
772
+ try:
773
+ import openai # noqa: F401
774
+ types.add("gguf")
775
+ except ImportError:
776
+ pass
777
+
778
+ return types
779
 
780
 
781
  def _print_target_table(targets, highlight_types=None):
 
831
  allowed_types = set(os.environ["LEM_TYPES"].split(","))
832
  else:
833
  allowed_types = detect_default_types()
834
+ if not allowed_types:
835
+ parser.error(
836
+ "no target types detected on this machine (tried mlx, gguf). "
837
+ "Install mlx_lm (Apple Silicon) or openai (any), or set LEM_TYPES "
838
+ "explicitly in the environment."
839
+ )
840
 
841
  if args.list_targets:
842
  _print_target_table(all_targets, highlight_types=allowed_types)