xai-org/x-algorithm · error · ValueError
Unsupported emb_table dtype: {embeddings.dtype}
Error message
Unsupported emb_table dtype: {embeddings.dtype} What it means
_maybe_init_rows lazily fills uninitialized embedding rows by generating random float32 values and bit-casting them into the table's storage dtype: uint16 stores the high 16 bits (bfloat16-style truncation via values.view(np.uint32) >> 16) and uint32 stores the full bits. Any other dtype has no defined bit-cast path, so it raises rather than writing garbage. Reached from lookup_h2d_embeddings.
Source
Thrown at phoenix/xrex/inference/h2d.py:412
)
if embeddings.ndim != 2:
raise ValueError(f"Expected 2D emb_table, got shape={embeddings.shape}")
row_size = embeddings.shape[1]
scale = 1.0 / math.sqrt(row_size)
unique_rows = np.unique(row_indexes)
for row in unique_rows:
idx = int(row)
first = int(embeddings[idx, 0])
if first != 0:
continue
rng = np.random.default_rng(idx)
values = rng.uniform(-scale, scale, size=row_size).astype(np.float32)
if embeddings.dtype == np.uint16:
embeddings[idx] = (values.view(np.uint32) >> 16).astype(np.uint16)
elif embeddings.dtype == np.uint32:
embeddings[idx] = values.view(np.uint32)
else:
raise ValueError(f"Unsupported emb_table dtype: {embeddings.dtype}")
View on GitHub (pinned to 24c60942c5)
Solutions
- Re-create the table with the dtype from create_h2d_state ('bfloat16'->np.uint16, 'float32'->np.uint32)
- Convert an existing table: table.astype(np.uint32) for float32 values or proper bfloat16 bit conversion for uint16
- If a new storage dtype is genuinely needed, add an explicit branch in _maybe_init_rows with a correct bit-cast
Example fix
# before table = np.zeros((vocab, dim), dtype=np.float32) rows = lookup_h2d_embeddings(idx, table, ...) # lazy init -> error # after table = np.zeros((vocab, dim), dtype=np.uint32) rows = lookup_h2d_embeddings(idx, table, ...)
Defensive patterns
Strategy: validation
Validate before calling
import numpy as np
assert table.dtype in (np.uint16, np.uint32), f"bad table dtype {table.dtype}" Type guard
def is_supported_table_dtype(a: np.ndarray) -> bool:
return a.dtype in (np.dtype(np.uint16), np.dtype(np.uint32)) Prevention
- Only pass tables produced by create_h2d_state or converted with the documented bit-cast
- Unit-test dtype round-trips when adding new embedding precisions
When it happens
Trigger: Calling lookup_h2d_embeddings with an emb_table whose dtype is float32, float16, int32, or anything other than np.uint16/np.uint32 while some row indexes are uninitialized. Note a table created via create_h2d_state will always be uint16/uint32, so this only happens with externally supplied tables.
Common situations: Passing a native float32 numpy table built for debugging instead of the uint view; reusing a dtype from a different pipeline; a checkpoint conversion step that emits float32 arrays directly.
Related errors
- Expected 2D emb_table, got shape={embeddings.shape}
- rows must contain only 1-dim uint8 numpy arrays
- type checking expression %s failed: invalid argument type: e
- {key}: got {arr.shape}/{arr.dtype}, manifest says {meta['sha
- Only bfloat16 is supported for keys.
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/04953e1b4350b614.
Report an issue: GitHub.