sgl-project/sglang · error · ValueError

Unknown interaction strategy: {strategy}

Error message

Unknown interaction strategy: {strategy}

What it means

MovaDualTower.get_interaction_layers maps a strategy string (e.g. 'custom', 'full') to the set of layer indices where the audio and vision towers interact. Any strategy string outside the supported set hits the final else and raises.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/bridges/mova_dual_tower.py:173

            num_interact = min(10, self.min_layers // 3)
            interact_layers = list(range(0, num_interact))
        elif strategy == "distributed":
            step = 3
            interact_layers = list(range(0, self.min_layers, step))
        elif strategy == "progressive":
            shallow = list(range(0, min(8, self.min_layers)))
            if self.min_layers > 8:
                deep = list(range(8, self.min_layers, 3))
                interact_layers = shallow + deep
            else:
                interact_layers = shallow
        elif strategy == "custom":
            interact_layers = [0, 2, 4, 6, 8, 12, 16, 20]
            interact_layers = [i for i in interact_layers if i < self.min_layers]
        elif strategy == "full":
            interact_layers = list(range(0, self.min_layers))
        else:
            raise ValueError(f"Unknown interaction strategy: {strategy}")

        mapping = {
            "v2a": [(i, i) for i in interact_layers],
            "a2v": [(i, i) for i in interact_layers],
        }
        return mapping

    def should_interact(
        self, layer_idx: int, direction: str, interaction_mapping: Dict
    ) -> bool:
        """Determines if the specified layer needs to interact."""
        if direction not in interaction_mapping:
            return False
        return any(src == layer_idx for src, _ in interaction_mapping[direction])


class ConditionalCrossAttention(nn.Module):
    """

View on GitHub (pinned to 0132848349)

Solutions

  1. Check the if/elif chain in get_interaction_layers for the accepted strategy values and use one of them (e.g. 'custom' or 'full')
  2. Fix typos / casing in the config value feeding the strategy argument
  3. If you need a new strategy, extend the chain in the source and map it to an explicit layer list
  4. Add config validation (Literal/Enum) at the config-parsing layer so invalid values fail with a clearer message

Example fix

# before
tower = MovaDualTower(..., interaction_strategy="adaptive")
# after
from typing import Literal
strategy: Literal["custom", "full"] = "custom"
tower = MovaDualTower(..., interaction_strategy=strategy)
Defensive patterns

Strategy: validation

Validate before calling

assert strategy in ("custom", "full"), f"unsupported interaction strategy: {strategy}"

Type guard

from typing import Literal
InteractionStrategy = Literal["custom", "full"]
def is_valid_strategy(s: str) -> bool:
    return s in ("custom", "full")

Try / catch

try:
    tower = MovaDualTower(...)
except ValueError as e:
    if "Unknown interaction strategy" in str(e):
        raise ValueError("check config 'interaction_strategy'; supported: custom, full") from e
    raise

Prevention

When it happens

Trigger: Calling `get_interaction_layers(strategy=...)` (invoked from __init__) with a misspelled or unsupported value such as 'adaptive', 'cross', 'Custom', or an empty string.

Common situations: Copy-pasting a config key from another dual-tower implementation; typos or case mismatch in a YAML/JSON config; adding a new strategy constant that was never wired into this if/elif chain.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/582f21542de2b704. Report an issue: GitHub.