xai-org/x-algorithm · error · ValueError

batch missing

Error message

batch missing {ACTION_MULTIHOT_COLUMN}

What it means

fold_action_delays_into_multihot() folds per-action delay columns into the existing ACTION_MULTIHOT_COLUMN of the batch. If action delay columns are present but the multi-hot column is missing from the batch schema, there is nothing to fold into, so it raises ValueError naming the missing column.

Solutions

  1. Ensure the source batch files contain the multi-hot column (regenerate or use newer data).
  2. Remove the projection/filter that drops the multi-hot column before folding.
  3. Disable action-delay folding (include_action_delay_columns=False) if multi-hot is not needed.

Example fix

// before
batch = fold_action_delays_into_multihot(batch_wo_multihot, window_ms)  # ValueError

// after
batch = fold_action_delays_into_multihot(batch_with_multihot, window_ms)
Defensive patterns

Strategy: validation

Validate before calling

has_multihot = ACTION_MULTIHOT_COLUMN in batch.schema.names
has_action_cols = any(n.startswith(ACTION_DELAY_PREFIX) for n in batch.schema.names)
assert not (has_action_cols and not has_multihot), 'cannot fold without multi-hot'

Type guard

def can_fold(batch) -> bool:
    names = batch.schema.names
    return (ACTION_MULTIHOT_COLUMN in names
            and any(n.startswith('action_delay_') for n in names))

Try / catch

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

Prevention

When it happens

Trigger: Producer path with include_action_delay_columns=True on a batch schema that predates the multi-hot feature; a batch where the multi-hot column was renamed or dropped upstream; delay columns attached but multi-hot column filtered out by a column projection.

Common situations: Training on older datasets lacking the multi-hot column; column pruning config that excludes ACTION_MULTIHOT_COLUMN.

Related errors


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

Appendix: source

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

def attach_delays(batch: pa.RecordBatch, delays: dict[str, np.ndarray]) -> pa.RecordBatch:
    for name, mat in delays.items():
        if mat.shape[0] != batch.num_rows:
            raise ValueError(f"{name}: delay rows {mat.shape[0]} != batch rows {batch.num_rows}")
        arr = pa.FixedSizeListArray.from_arrays(
            pa.array(mat.reshape(-1), type=pa.int64()), mat.shape[1]
        )
        batch = batch.append_column(name, arr)
    return batch


def fold_action_delays_into_multihot(batch: pa.RecordBatch, window_ms: int) -> pa.RecordBatch:
    action_cols = [n for n in batch.schema.names if n.startswith(ACTION_DELAY_PREFIX)]
    if not action_cols:
        return batch
    col_idx = batch.schema.get_field_index(ACTION_MULTIHOT_COLUMN)
    if col_idx < 0:
        raise ValueError(f"batch missing {ACTION_MULTIHOT_COLUMN}")
    mh = batch.column(col_idx)
    seq_len = mh.type.list_size
    vocab = mh.type.value_type.list_size
    bits = (
        mh.flatten()
        .flatten()
        .to_numpy(zero_copy_only=False)
        .astype(np.bool_)
        .reshape(batch.num_rows, seq_len, vocab)
        .copy()
    )
    mask_name = next(
        (n for n in ("newEventMask", "newEventMaskSeq") if n in batch.schema.names), None
    )
    if mask_name is None:
        raise ValueError("batch missing newEventMask; conversion-label folding is candidate-only")
    mask_col = batch.column(mask_name)
    is_candidate = (

View on GitHub (pinned to 24c60942c5)