Fix VLM metric structured output#594
Fix VLM metric structured output#594davidberenstein1957 merged 1 commit intofeat/metrics-vlm-supportfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Registry crashes when metric_device is None
- I added a guard in MetricRegistry so device normalization/fallback only runs when a stateful metric device is provided, allowing None to pass through to StatefulMetric initialization as before.
Or push these changes by commenting:
@cursor push b308d27d2e
Preview (b308d27d2e)
diff --git a/src/pruna/evaluation/metrics/registry.py b/src/pruna/evaluation/metrics/registry.py
--- a/src/pruna/evaluation/metrics/registry.py
+++ b/src/pruna/evaluation/metrics/registry.py
@@ -137,9 +137,10 @@
elif isclass(metric_cls):
if issubclass(metric_cls, StatefulMetric):
metric_device = stateful_metric_device if stateful_metric_device else device
- requested_device, _ = split_device(device_to_string(metric_device), strict=False)
- if requested_device not in metric_cls.runs_on and "cpu" in metric_cls.runs_on:
- metric_device = "cpu"
+ if metric_device is not None:
+ requested_device, _ = split_device(device_to_string(metric_device), strict=False)
+ if requested_device not in metric_cls.runs_on and "cpu" in metric_cls.runs_on:
+ metric_device = "cpu"
kwargs["device"] = metric_device
elif issubclass(metric_cls, BaseMetric):
kwargs["device"] = inference_device if inference_device else deviceThis Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
| if issubclass(metric_cls, StatefulMetric): | ||
| kwargs["device"] = stateful_metric_device if stateful_metric_device else device | ||
| metric_device = stateful_metric_device if stateful_metric_device else device | ||
| requested_device, _ = split_device(device_to_string(metric_device), strict=False) |
There was a problem hiding this comment.
Registry crashes when metric_device is None
High Severity
device_to_string(metric_device) raises ValueError when metric_device is None. This happens when MetricRegistry.get_metric is called for a StatefulMetric subclass without providing device, stateful_metric_device, or inference_device kwargs. The previous code simply passed None through to the metric constructor, which handled it gracefully via set_to_best_available_device(None). At least one existing caller (base_tester.py) invokes get_metric(metric) with no device args for arbitrary metrics.



Summary
Verification