Comfy-Org/ComfyUI · error · ValueError
Unknown reference view selection strategy: {strategy!r}. Mus
Error message
Unknown reference view selection strategy: {strategy!r}. Must be one of: 'first', 'middle', 'saddle_balanced', 'saddle_sim_range' What it means
The DA3 reference-view selector picks a reference frame by strategy name: 'first', 'middle', 'saddle_balanced', or 'saddle_sim_range'. Any other string falls through to a ValueError listing the valid options. The strategy is a parameter of the selection routine, usually hardcoded or exposed by a node.
Source
Thrown at comfy/ldm/depth_anything_3/reference_view_selector.py:54
feat_var = img_class_feat.var(dim=-1) # (B,S)
def _normalize(metric):
mn = metric.min(dim=1, keepdim=True).values
mx = metric.max(dim=1, keepdim=True).values
return (metric - mn) / (mx - mn + 1e-8)
sim_n, norm_n, var_n = _normalize(sim_score), _normalize(feat_norm), _normalize(feat_var)
balance = (sim_n - 0.5).abs() + (norm_n - 0.5).abs() + (var_n - 0.5).abs()
return balance.argmin(dim=1)
if strategy == "saddle_sim_range":
sim = torch.matmul(img_class_feat, img_class_feat.transpose(1, 2))
sim_no_diag = sim - torch.eye(S, device=sim.device).unsqueeze(0)
sim_max = sim_no_diag.max(dim=-1).values
sim_min = sim_no_diag.min(dim=-1).values
return (sim_max - sim_min).argmax(dim=1)
raise ValueError(
f"Unknown reference view selection strategy: {strategy!r}. "
f"Must be one of: 'first', 'middle', 'saddle_balanced', 'saddle_sim_range'"
)
def reorder_by_reference(x: torch.Tensor, b_idx: torch.Tensor) -> torch.Tensor:
"""Reorder x so the reference view is at position 0 in axis S."""
B, S = x.shape[0], x.shape[1]
if S <= 1:
return x
positions = torch.arange(S, device=x.device).unsqueeze(0).expand(B, -1)
b_idx_exp = b_idx.unsqueeze(1)
reorder = torch.where(
(positions > 0) & (positions <= b_idx_exp),
positions - 1,
positions,
)
reorder[:, 0] = b_idxView on GitHub (pinned to 1c6d8d45b3)
Solutions
- Use one of the four exact strings: 'first', 'middle', 'saddle_balanced', 'saddle_sim_range'.
- If exposing in a node, use a fixed combo input constrained to the four values.
- Add the missing strategy branch yourself if you truly need new behavior, before the final raise.
Example fix
# before idx = select_reference_view(feat, strategy="saddle_balance") # after idx = select_reference_view(feat, strategy="saddle_balanced")
Defensive patterns
Strategy: type-guard
Validate before calling
STRATEGIES = {"first", "middle", "saddle_balanced", "saddle_sim_range"}
assert strategy in STRATEGIES, f"strategy must be one of {sorted(STRATEGIES)}" Type guard
def is_valid_reference_strategy(strategy: str) -> bool:
return strategy in {"first", "middle", "saddle_balanced", "saddle_sim_range"} Prevention
- Use a fixed allowlist for strategy strings at the node/UI boundary.
- Copy strategy names from the raise message itself (it is the authoritative allowlist).
When it happens
Trigger: Calling select_reference_view (or its caller) with a strategy string that misses the allowlist — typo such as 'saddle_balance', or a new strategy name from a different repo revision.
Common situations: Custom nodes exposing the strategy as a text input; syncing code between upstream DA3 forks where strategy names diverged.
Related errors
- Unsupported process_res_method: {method}
- At least 4 points are required to compute a homography.
- Unknown DINOv2 backbone variant: {backbone_name!r}
- Invalid affine shape: {ext.shape}
- Invalid rotation matrix shape {matrix.shape}.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/b8753d44a5de421c.
Report an issue: GitHub.