exo-explore/exo · error · ValueError

Expected NHD (3D), got shape={tuple(t.shape)}

Error message

Expected NHD (3D), got shape={tuple(t.shape)}

What it means

Error "Expected NHD (3D), got shape={tuple(t.shape)}" thrown in exo-explore/exo.

Source

Thrown at src/exo/worker/engines/mlx/disaggregated/adapter.py:89

            arr = np.frombuffer(data, dtype=np.uint16).reshape(shape).copy()
            return mx.array(arr).view(mx.bfloat16)
        case "float16":
            arr = np.frombuffer(data, dtype=np.float16).reshape(shape).copy()
            return mx.array(arr)
        case "float32":
            arr = np.frombuffer(data, dtype=np.float32).reshape(shape).copy()
            return mx.array(arr)


def bhsd_to_nhd(t: mx.array) -> mx.array:
    if t.ndim != 4 or int(t.shape[0]) != 1:
        raise ValueError(f"Expected BHSD with B=1, got shape={tuple(t.shape)}")
    return mx.transpose(t[0], (1, 0, 2))


def nhd_to_bhsd(t: mx.array) -> mx.array:
    if t.ndim != 3:
        raise ValueError(f"Expected NHD (3D), got shape={tuple(t.shape)}")
    return mx.expand_dims(mx.transpose(t, (1, 0, 2)), 0)


def send_mlx_kv_cache(
    stream: BinaryIO,
    caches: KVCacheType,
    *,
    dtype: DType,
    start_pos: int = 0,
    max_tokens: int | None = None,
) -> int:
    tokens_sent = 0
    for layer_idx, c in enumerate(caches):
        match c:
            case QuantizedKVCache() | CacheList() | DeepseekV4Cache():
                raise NotImplementedError
            case KVCache() | RotatingKVCache():
                keys = c.keys

View on GitHub (pinned to 21a54c5ea0)

When it happens

Trigger: Thrown at src/exo/worker/engines/mlx/disaggregated/adapter.py:89 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of exo-explore/exo@21a54c5ea0 (2026-08-26). Data as JSON: /api/errors/45cc95c03be962f1. Report an issue: GitHub.