{"record":{"id":"8cd8c96a6827aadd","repo":"exo-explore/exo","slug":"expected-bhsd-with-b-1-got-shape-tuple-t-shape","errorCode":null,"errorMessage":"Expected BHSD with B=1, got shape={tuple(t.shape)}","messagePattern":"Expected BHSD with B=1, got shape=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/exo/worker/engines/mlx/disaggregated/adapter.py","lineNumber":83,"sourceCode":"    raise ValueError(f\"Unsupported mlx dtype for wire: {t.dtype}\")\n\n\ndef bytes_to_array(data: bytes, shape: tuple[int, ...], dtype: DType) -> mx.array:\n    match dtype:\n        case \"bfloat16\":\n            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","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/exo-explore/exo/blob/21a54c5ea0230a3bec1e1a786d200126c7e34ec6/src/exo/worker/engines/mlx/disaggregated/adapter.py#L65-L101","documentation":"Error \"Expected BHSD with B=1, got shape={tuple(t.shape)}\" thrown in exo-explore/exo.","triggerScenarios":"Thrown at src/exo/worker/engines/mlx/disaggregated/adapter.py:83 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"}