sgl-project/sglang · error · ValueError

audio_projection_mode = {audio_projection_mode} not implemen

Error message

audio_projection_mode = {audio_projection_mode} not implemented

What it means

get_audio_features dispatches on audio_projection_mode and only supports 'speech' (self.audio_projection) and 'vision' (self.audio_projection_for_vision). Any other mode string raises ValueError at runtime during forward of the audio tower.

Source

Thrown at python/sglang/srt/models/phi4mm_audio.py:1236

                    audio_features,
                    (0, 0, 0, self.linear_downsample_rate - padding),
                    "constant",
                    0,
                )

            seq_len = audio_features.size(1)
            audio_features = audio_features.view(
                bs,
                seq_len // self.linear_downsample_rate,
                feat_dim * self.linear_downsample_rate,
            )

        if audio_projection_mode == "speech":
            audio_set_tensor = self.audio_projection(audio_features)
        elif audio_projection_mode == "vision":
            audio_set_tensor = self.audio_projection_for_vision(audio_features)
        else:
            raise ValueError(
                f"audio_projection_mode = {audio_projection_mode} not " "implemented"
            )

        return audio_set_tensor

    def forward(
        self,
        audio_features: torch.FloatTensor,
        audio_attention_mask: torch.Tensor = None,
        audio_projection_mode: str = "speech",
    ) -> torch.FloatTensor:
        """
        arguments:
            audio_features: audio features (num_audio_tokens, T, D)

        returns:
            audio_embeds: audio embeddings (num_audio_tokens, hidden_dim)
        """

View on GitHub (pinned to 0132848349)

Solutions

  1. Ensure the caller passes audio_projection_mode of exactly 'speech' or 'vision'
  2. Check where get_audio_features is invoked (forward) and fix the mode propagation from config
  3. Normalize/lowercase the mode string before dispatch if case drift is possible

Example fix

# before
audio_set_tensor = model.get_audio_features(audio_features, mode="text")
# after
audio_set_tensor = model.get_audio_features(audio_features, mode="speech")
Defensive patterns

Strategy: type-guard

Validate before calling

assert audio_projection_mode in ("speech", "vision"), f"bad mode: {audio_projection_mode}"

Type guard

def is_valid_audio_projection_mode(mode: str) -> bool:
    return mode in ("speech", "vision")

Try / catch

try:
    feats = model.get_audio_features(audio_features, mode)
except ValueError as e:
    if "audio_projection_mode" in str(e):
        raise ValueError("mode must be 'speech' or 'vision'") from e
    raise

Prevention

When it happens

Trigger: Calling forward on the Phi-4-MM audio model when the audio tower was configured with an audio_projection_mode other than 'speech' or 'vision'; the mode typically comes from the multimodal projector config or is hardcoded at call sites.

Common situations: A vision-language call path routed into the audio tower with the wrong mode string; fine-tuned models introducing a new projection mode; typos like 'Speech' or 'vision ' in configs.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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