xai-org/x-algorithm · error · ValueError
valid_block_upper and valid_block_lower must both be provide
Error message
valid_block_upper and valid_block_lower must both be provided or both be None
What it means
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.
Source
Thrown at phoenix/xrex/cutedsl/ranker_fa4/block_sparsity.py:479
metadata_block_shape = expected_count_shape
valid_block_upper = _check_and_expand_metadata_tensor(
"valid_block_upper",
tensors.valid_block_upper,
metadata_block_shape,
context,
hint,
mask_cnt.device,
)
valid_block_lower = _check_and_expand_metadata_tensor(
"valid_block_lower",
tensors.valid_block_lower,
metadata_block_shape,
context,
hint,
mask_cnt.device,
)
if (valid_block_upper is None) != (valid_block_lower is None):
raise ValueError(
"valid_block_upper and valid_block_lower must both be provided or both be None"
)
spt = tensors.spt
if spt is not None and not isinstance(spt, bool):
raise ValueError("spt must be a bool when provided")
if spt is not None and dq_write_order is None:
raise ValueError("spt requires dq_write_order to be provided")
return BlockSparseTensorsTorch(
mask_block_cnt=mask_cnt,
mask_block_idx=mask_idx,
full_block_cnt=full_cnt,
full_block_idx=full_idx,
cu_total_m_blocks=tensors.cu_total_m_blocks,
cu_block_idx_offsets=tensors.cu_block_idx_offsets,
block_size=tensors.block_size,
dq_write_order=dq_write_order,
dq_write_order_full=dq_write_order_full,View on GitHub (pinned to 24c60942c5)
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
Example fix
# before tensors = BlockSparseTensorsTorch(..., valid_block_upper=ub, valid_block_lower=None) # after tensors = BlockSparseTensorsTorch(..., valid_block_upper=ub, valid_block_lower=lb) # or omit both
Defensive patterns
Strategy: validation
Validate before calling
assert (tensors.valid_block_upper is None) == (tensors.valid_block_lower is None)
Type guard
def valid_bounds_paired(t) -> bool:
return (t.valid_block_upper is None) == (t.valid_block_lower is None) Prevention
- Read paired keys from config with .get() and default both to None together
When it happens
Trigger: Constructing BlockSparseTensorsTorch with valid_block_upper set but valid_block_lower=None (or vice versa), typically when conditionally filling one field in builder code.
Common situations: 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.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- {name}_block_cnt and {name}_block_idx must be on the same de
- {name} must have dtype torch.int32
- mask_block_cnt and mask_block_idx must be provided for block
- type checking expression %s failed: invalid argument type: %
- Non-optional parameter %s must be declared before optional p
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/b78d17b6e4737143.
Report an issue: GitHub.