xai-org/x-algorithm · error · ValueError

spt requires dq_write_order to be provided

Error message

spt requires dq_write_order to be provided

What it means

Enabling spt (the special-path flag) additionally requires dq_write_order metadata, because that path uses the write-order tensor to sequence dQ accumulation. spt set without dq_write_order is rejected.

Source

Thrown at phoenix/xrex/cutedsl/ranker_fa4/block_sparsity.py:486

        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,
        spt=spt,
        diag_block_cnt=diag_cnt,
        diag_block_idx=diag_idx,
        dq_write_order_diag=dq_write_order_diag,
        valid_block_upper=valid_block_upper,
        valid_block_lower=valid_block_lower,
    )

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Provide tensors.dq_write_order (built by the mask-generation utilities for the SPT path)
  2. Or disable spt (set to None/False) if you don't need that path
  3. Regenerate your block-sparse artifacts with the current tooling so all SPT metadata is present

Example fix

# before
tensors.spt = True                      # no dq_write_order

# after
tensors = BlockSparseTensorsTorch(..., spt=True, dq_write_order=dqwo)
# or: tensors.spt = None
Defensive patterns

Strategy: validation

Validate before calling

if tensors.spt is not None:
    assert tensors.dq_write_order is not None, 'spt requires dq_write_order'

Type guard

def spt_ready(t) -> bool:
    return t.spt is None or t.dq_write_order is not None

Prevention

When it happens

Trigger: Setting tensors.spt = True while leaving tensors.dq_write_order as None, typically when enabling the SPT optimization without shipping its metadata.

Common situations: Toggling an experimental spt flag in config without regenerating the mask bundle that includes dq_write_order; partial upgrade to a newer mask format that added dq_write_order.

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


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