{"record":{"id":"45cc95c03be962f1","repo":"exo-explore/exo","slug":"expected-nhd-3d-got-shape-tuple-t-shape","errorCode":null,"errorMessage":"Expected NHD (3D), got shape={tuple(t.shape)}","messagePattern":"Expected NHD \\(3D\\), got shape=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/exo/worker/engines/mlx/disaggregated/adapter.py","lineNumber":89,"sourceCode":"            arr = np.frombuffer(data, dtype=np.uint16).reshape(shape).copy()\n            return mx.array(arr).view(mx.bfloat16)\n        case \"float16\":\n            arr = np.frombuffer(data, dtype=np.float16).reshape(shape).copy()\n            return mx.array(arr)\n        case \"float32\":\n            arr = np.frombuffer(data, dtype=np.float32).reshape(shape).copy()\n            return mx.array(arr)\n\n\ndef bhsd_to_nhd(t: mx.array) -> mx.array:\n    if t.ndim != 4 or int(t.shape[0]) != 1:\n        raise ValueError(f\"Expected BHSD with B=1, got shape={tuple(t.shape)}\")\n    return mx.transpose(t[0], (1, 0, 2))\n\n\ndef nhd_to_bhsd(t: mx.array) -> mx.array:\n    if t.ndim != 3:\n        raise ValueError(f\"Expected NHD (3D), got shape={tuple(t.shape)}\")\n    return mx.expand_dims(mx.transpose(t, (1, 0, 2)), 0)\n\n\ndef send_mlx_kv_cache(\n    stream: BinaryIO,\n    caches: KVCacheType,\n    *,\n    dtype: DType,\n    start_pos: int = 0,\n    max_tokens: int | None = None,\n) -> int:\n    tokens_sent = 0\n    for layer_idx, c in enumerate(caches):\n        match c:\n            case QuantizedKVCache() | CacheList() | DeepseekV4Cache():\n                raise NotImplementedError\n            case KVCache() | RotatingKVCache():\n                keys = c.keys","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/exo-explore/exo/blob/21a54c5ea0230a3bec1e1a786d200126c7e34ec6/src/exo/worker/engines/mlx/disaggregated/adapter.py#L71-L107","documentation":"Error \"Expected NHD (3D), got shape={tuple(t.shape)}\" thrown in exo-explore/exo.","triggerScenarios":"Thrown at src/exo/worker/engines/mlx/disaggregated/adapter.py:89 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"21a54c5ea0230a3bec1e1a786d200126c7e34ec6","analyzedAt":"2026-08-26T00:02:16.033Z","schemaVersion":2},"datasetVersion":"2026-08-26T04:18:47.238Z"}