{"record":{"id":"b78d17b6e4737143","repo":"xai-org/x-algorithm","slug":"valid-block-upper-and-valid-block-lower-must-both","errorCode":null,"errorMessage":"valid_block_upper and valid_block_lower must both be provided or both be None","messagePattern":"valid_block_upper and valid_block_lower must both be provided or both be None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/cutedsl/ranker_fa4/block_sparsity.py","lineNumber":479,"sourceCode":"    metadata_block_shape = expected_count_shape\n    valid_block_upper = _check_and_expand_metadata_tensor(\n        \"valid_block_upper\",\n        tensors.valid_block_upper,\n        metadata_block_shape,\n        context,\n        hint,\n        mask_cnt.device,\n    )\n    valid_block_lower = _check_and_expand_metadata_tensor(\n        \"valid_block_lower\",\n        tensors.valid_block_lower,\n        metadata_block_shape,\n        context,\n        hint,\n        mask_cnt.device,\n    )\n    if (valid_block_upper is None) != (valid_block_lower is None):\n        raise ValueError(\n            \"valid_block_upper and valid_block_lower must both be provided or both be None\"\n        )\n    spt = tensors.spt\n    if spt is not None and not isinstance(spt, bool):\n        raise ValueError(\"spt must be a bool when provided\")\n    if spt is not None and dq_write_order is None:\n        raise ValueError(\"spt requires dq_write_order to be provided\")\n\n    return BlockSparseTensorsTorch(\n        mask_block_cnt=mask_cnt,\n        mask_block_idx=mask_idx,\n        full_block_cnt=full_cnt,\n        full_block_idx=full_idx,\n        cu_total_m_blocks=tensors.cu_total_m_blocks,\n        cu_block_idx_offsets=tensors.cu_block_idx_offsets,\n        block_size=tensors.block_size,\n        dq_write_order=dq_write_order,\n        dq_write_order_full=dq_write_order_full,","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/cutedsl/ranker_fa4/block_sparsity.py#L461-L497","documentation":"valid_block_upper and valid_block_lower are a paired option: they must be supplied together or both omitted. Supplying only one is ambiguous because the kernel uses them as a symmetric bound pair for partial-block validity.","triggerScenarios":"Constructing BlockSparseTensorsTorch with valid_block_upper set but valid_block_lower=None (or vice versa), typically when conditionally filling one field in builder code.","commonSituations":"Copy-paste from an example that set both, with one line later removed; defaults from a dataclass where one field was overridden; partial deserialization from a checkpoint/config dict missing one key.","solutions":["Set both fields or neither","If your config dict may lack one key, default both to None together: cfg.get('valid_block_upper') and cfg.get('valid_block_lower')","Add a paired-presence check in your config loader"],"exampleFix":"# before\ntensors = BlockSparseTensorsTorch(..., valid_block_upper=ub, valid_block_lower=None)\n\n# after\ntensors = BlockSparseTensorsTorch(..., valid_block_upper=ub, valid_block_lower=lb)\n# or omit both","handlingStrategy":"validation","validationCode":"assert (tensors.valid_block_upper is None) == (tensors.valid_block_lower is None)","typeGuard":"def valid_bounds_paired(t) -> bool:\n    return (t.valid_block_upper is None) == (t.valid_block_lower is None)","tryCatchPattern":null,"preventionTips":["Read paired keys from config with .get() and default both to None together"],"tags":["block-sparsity","paired-arguments","validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}