diff --git a/services/hwfit/profiles.py b/services/hwfit/profiles.py index 337af7648..5c885e38b 100644 --- a/services/hwfit/profiles.py +++ b/services/hwfit/profiles.py @@ -103,6 +103,9 @@ def compute_serve_profiles(system, model, serve_weights_gb=None, serve_quant=Non in the actual serving knobs (n_cpu_moe, KV-cache type, context). serve_quant is the file's quant label (e.g. "Q4_K_M") just for display. """ + if not isinstance(system, dict) or not isinstance(model, dict): + return [] + vram = float(system.get("gpu_vram_gb") or 0) if vram <= 0: return [] diff --git a/tests/test_serve_profiles.py b/tests/test_serve_profiles.py index e612a7a83..cc7e3788e 100644 --- a/tests/test_serve_profiles.py +++ b/tests/test_serve_profiles.py @@ -28,6 +28,12 @@ def _sys(vram, family="rdna"): return {"backend": "rocm", "gpu_vram_gb": vram, "gpu_family": family} +def test_compute_serve_profiles_ignores_invalid_inputs(): + assert compute_serve_profiles(None, _DENSE_8B) == [] + assert compute_serve_profiles(_sys(8), None) == [] + assert compute_serve_profiles(["bad"], _DENSE_8B) == [] + + def test_big_moe_on_small_card_offloads_not_fails(): """A 35B MoE can't hold its weights on 16 GB, so the Quality profile must offload experts to CPU (n_cpu_moe > 0) rather than be dropped."""