{"record":{"id":"ae461716acc79593","repo":"xai-org/x-algorithm","slug":"mask-name-seq-len-is-candidate-shape-1-mu","errorCode":null,"errorMessage":"{mask_name}: seq len {is_candidate.shape[1]} != multi-hot {seq_len}","messagePattern":"(.+?): seq len (.+?) != multi-hot (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/data/conversion_labels.py","lineNumber":116,"sourceCode":"        .to_numpy(zero_copy_only=False)\n        .astype(np.bool_)\n        .reshape(batch.num_rows, seq_len, vocab)\n        .copy()\n    )\n    mask_name = next(\n        (n for n in (\"newEventMask\", \"newEventMaskSeq\") if n in batch.schema.names), None\n    )\n    if mask_name is None:\n        raise ValueError(\"batch missing newEventMask; conversion-label folding is candidate-only\")\n    mask_col = batch.column(mask_name)\n    is_candidate = (\n        mask_col.flatten()\n        .to_numpy(zero_copy_only=False)\n        .astype(np.bool_)\n        .reshape(batch.num_rows, mask_col.type.list_size)\n    )\n    if is_candidate.shape[1] != seq_len:\n        raise ValueError(f\"{mask_name}: seq len {is_candidate.shape[1]} != multi-hot {seq_len}\")\n    for name in action_cols:\n        idx = action_index_of(name)\n        if idx >= vocab:\n            raise ValueError(f\"{name}: bit {idx} outside vocab {vocab}\")\n        delays_col = batch.column(name)\n        delays = (\n            delays_col.flatten()\n            .to_numpy(zero_copy_only=False)\n            .astype(np.int64)\n            .reshape(batch.num_rows, delays_col.type.list_size)\n        )\n        if delays.shape[1] != seq_len:\n            raise ValueError(f\"{name}: seq len {delays.shape[1]} != multi-hot {seq_len}\")\n        bits[:, :, idx] = np.where(\n            is_candidate, delays_to_labels(delays, window_ms), bits[:, :, idx]\n        )\n    inner = pa.FixedSizeListArray.from_arrays(pa.array(bits.reshape(-1)), vocab)\n    outer = pa.FixedSizeListArray.from_arrays(inner, seq_len)","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/data/conversion_labels.py#L98-L134","documentation":"The candidate mask's per-row sequence length must equal the sequence length of the multi-hot column (list_size). If the reshaped mask has a different second dimension, the element-wise np.where fold would broadcast incorrectly, so ValueError is raised naming the mask column and both lengths.","triggerScenarios":"Batch where newEventMask has seq len 32 but the multi-hot list_size is 64; schema evolution changing sequence length for one column but not the other; mixing columns from different feature versions into one batch.","commonSituations":"Mid-migration datasets where sequence length changed; concatenating batches with inconsistent FixedSizeList widths.","solutions":["Regenerate the dataset so mask and multi-hot share the same sequence length.","Rebuild the batch with consistent FixedSizeList types before folding.","Skip folding for batches whose schema lengths disagree."],"exampleFix":"// before: mask seq 32, multihot seq 64\nbatch = fold_action_delays_into_multihot(batch, w)  # ValueError\n\n// after: regenerate data with seq_len consistent (e.g. both 64)\nbatch = fold_action_delays_into_multihot(batch_fixed, w)","handlingStrategy":"validation","validationCode":"seq = batch.column(batch.schema.get_field_index(ACTION_MULTIHOT_COLUMN)).type.list_size\nmask = next(n for n in ('newEventMask','newEventMaskSeq') if n in batch.schema.names)\nassert batch.column(mask).type.list_size == seq","typeGuard":"def seq_lens_consistent(batch) -> bool:\n    lens = {batch.schema.field(n).type.list_size for n in batch.schema.names\n            if pa.types.is_fixed_size_list(batch.schema.field(n).type)}\n    return len(lens) <= 1","tryCatchPattern":"try:\n    batch = fold_action_delays_into_multihot(batch, w)\nexcept ValueError as e:\n    raise RuntimeError(f'bad batch schema: {e}') from e","preventionTips":["Pin sequence length in pipeline config and validate every FixedSizeList width on write.","Reject mixed-schema batches at concatenation time."],"tags":["shape-mismatch","sequence-length","conversion-labels"],"backgroundTag":"data-shape-mismatch","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}