BerriAI/litellm · error · ValueError
Shape must be of length 2.
Error message
Shape must be of length 2.
What it means
Triton embedding splitter guard: split_embedding_by_dims received an embedding shape whose length is not 2 (expected [batch, dim]), so the response tensor cannot be split per dimension batch as the codepath assumes.
Source
Thrown at litellm/llms/triton/embedding/transformation.py:139
continue
try:
prompt_tokens += token_counter(model=model, text=text)
except Exception:
prompt_tokens += len(text.split())
return Usage(
prompt_tokens=prompt_tokens,
completion_tokens=0,
total_tokens=prompt_tokens,
)
def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:
return TritonError(message=error_message, status_code=status_code, headers=headers)
@staticmethod
def split_embedding_by_shape(data: list[float], shape: list[int]) -> list[list[float]]:
if len(shape) != 2:
raise ValueError("Shape must be of length 2.")
embedding_size: Final = shape[1]
return [data[i * embedding_size : (i + 1) * embedding_size] for i in range(shape[0])]
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Pass a shape list/tuple of exactly length 2 for the embedding request.
Example fix
shape=[batch_size, seq_len]
Defensive patterns
Strategy: validation
When it happens
Trigger: Triggered when the Triton embedding request shape does not have exactly length 2.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/b070804f3766a335.
Report an issue: GitHub.