xai-org/x-algorithm · error · ValueError

{name}: seq len {delays.shape[1]} != multi-hot {seq_len}

Error message

{name}: seq len {delays.shape[1]} != multi-hot {seq_len}

What it means

Each action-delay column is a FixedSizeListArray whose list_size (per-row delay vector length) must equal the multi-hot sequence length. If reshaping yields a different second dimension, the fold would misalign positions, so ValueError names the column and both lengths.

Source

Thrown at phoenix/xrex/data/conversion_labels.py:129

        .to_numpy(zero_copy_only=False)
        .astype(np.bool_)
        .reshape(batch.num_rows, mask_col.type.list_size)
    )
    if is_candidate.shape[1] != seq_len:
        raise ValueError(f"{mask_name}: seq len {is_candidate.shape[1]} != multi-hot {seq_len}")
    for name in action_cols:
        idx = action_index_of(name)
        if idx >= vocab:
            raise ValueError(f"{name}: bit {idx} outside vocab {vocab}")
        delays_col = batch.column(name)
        delays = (
            delays_col.flatten()
            .to_numpy(zero_copy_only=False)
            .astype(np.int64)
            .reshape(batch.num_rows, delays_col.type.list_size)
        )
        if delays.shape[1] != seq_len:
            raise ValueError(f"{name}: seq len {delays.shape[1]} != multi-hot {seq_len}")
        bits[:, :, idx] = np.where(
            is_candidate, delays_to_labels(delays, window_ms), bits[:, :, idx]
        )
    inner = pa.FixedSizeListArray.from_arrays(pa.array(bits.reshape(-1)), vocab)
    outer = pa.FixedSizeListArray.from_arrays(inner, seq_len)
    return batch.set_column(col_idx, batch.schema.field(col_idx), outer)


def delays_to_labels(delays: np.ndarray, window_ms: int) -> np.ndarray:
    if window_ms < 0:
        raise ValueError(f"window_ms must be >= 0, got {window_ms}")
    return (delays >= 0) & (delays <= window_ms)

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Regenerate sidecar delay columns with vectors matching the current sequence length.
  2. Re-attach delay columns using the correct FixedSizeList width.
  3. Skip the offending column until sidecars are rebuilt.

Example fix

// before: delays width 16, multihot seq 64
fold_action_delays_into_multihot(batch, w)  # ValueError

// after: regenerate sidecar with width == seq len (64)
fold_action_delays_into_multihot(batch_fixed, w)
Defensive patterns

Strategy: validation

Validate before calling

for n in action_cols:
    if batch.column(n).type.list_size != seq_len:
        raise SystemExit(f'{n} delay width mismatch; regenerate sidecar')

Try / catch

try:
    batch = fold_action_delays_into_multihot(batch, w)
except ValueError as e:
    logger.error('delay width mismatch: %s', e); raise

Prevention

When it happens

Trigger: Delay sidecar written with per-row vectors of length 16 while the multi-hot seq len is 64; delay columns attached with a stale FixedSizeList width after seq length changed.

Common situations: Sequence-length migration between pipeline versions; sidecars built from a dataset with different windowing.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/8143feb8ee3a00f2. Report an issue: GitHub.