sgl-project/sglang · error · ValueError
spt requires dq_write_order to be provided
Error message
spt requires dq_write_order to be provided
What it means
Dependency check for the `spt` code path: enabling spt additionally requires dq_write_order to be provided, because the kernel must know the dq write ordering to apply the spt transformation correctly.
Solutions
- Provide dq_write_order as an int32 CUDA tensor with shape equal to mask_block_idx's shape
- Or unset spt (leave None/False) if the spt mode is not intended
Example fix
// before tensors = BlockSparseTensorsTorch(cnt, idx, spt=True) // after order = make_dq_write_order(idx.shape) # int32, cuda tensors = BlockSparseTensorsTorch(cnt, idx, spt=True, dq_write_order=order)
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' Prevention
- When enabling spt, prepare dq_write_order (int32, CUDA, idx-shaped) at the same time
- Write a single prep_spt() helper that sets both fields together
When it happens
Trigger: Setting BlockSparseTensorsTorch(spt=True) without dq_write_order, then calling normalize_block_sparse_tensors (e.g. via normalize_block_sparse_config_bwd).
Common situations: Enabling spt for the backward pass but only preparing the forward's mask/full tensors.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- mask_block_cnt and mask_block_idx must be provided for…
- spt must be a bool when provided
- All block sparse tensors must be on the same device
- audio_num_frames must be provided for RoPE coordinate…
- Backward pass is not implemented yet and we do not have…
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/08a24692d19d4e8b.
Report an issue: GitHub.
Appendix: source
Thrown at python/sglang/kernels/ops/attention/flash_attn/cute/block_sparsity.py:494
tensors.dq_write_order,
tuple(mask_idx.shape),
context,
hint,
mask_cnt.device,
)
dq_write_order_full = _check_and_expand_metadata_tensor(
"dq_write_order_full",
tensors.dq_write_order_full,
tuple(full_idx.shape) if full_idx is not None else expected_index_shape,
context,
hint,
mask_cnt.device,
)
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,
)
def is_block_sparsity_enabled(tensors: BlockSparseTensorsTorch) -> bool:
return any(t is not None for t in (tensors.full_block_cnt, tensors.mask_block_cnt))
View on GitHub (pinned to 0132848349)