xai-org/x-algorithm · error · ValueError
Backward block sizes (block_q_dq, block_kv_dq, block_q_dkv,
Error message
Backward block sizes (block_q_dq, block_kv_dq, block_q_dkv, block_kv_dkv) must either all be specified or all be None.
What it means
TuningConfig for varlen ranker attention validates that the four backward block sizes (block_q_dq, block_kv_dq, block_q_dkv, block_kv_dkv) are all-or-nothing. Partially specifying them is ambiguous (autotuning would mix tuned and unset sizes), so __post_init__ rejects it immediately at config construction.
Source
Thrown at phoenix/xrex/pallas/ranker_attention_varlen.py:35
class TuningConfig:
block_q: int
block_kv: int
num_warps: int
num_stages: int
block_q_dq: int | None = None
block_kv_dq: int | None = None
block_q_dkv: int | None = None
block_kv_dkv: int | None = None
bwd_num_warps: int | None = None
bwd_num_stages: int | None = None
def __post_init__(self):
backward_blocks = [self.block_q_dq, self.block_kv_dq, self.block_q_dkv, self.block_kv_dkv]
block_is_set = [blk is not None for blk in backward_blocks]
if any(block_is_set) and not all(block_is_set):
raise ValueError(
"Backward block sizes (block_q_dq, block_kv_dq, block_q_dkv, "
"block_kv_dkv) must either all be specified or all be None."
)
HOPPER_CONFIG = TuningConfig(
block_q=128,
block_kv=128,
num_warps=8,
num_stages=2,
block_q_dq=128,
block_kv_dq=16,
block_q_dkv=16,
block_kv_dkv=128,
bwd_num_warps=8,
bwd_num_stages=4,
)
View on GitHub (pinned to 24c60942c5)
Solutions
- Provide all four backward block sizes explicitly, or remove all of them so autotuning/defaults apply.
- Check dataclass field defaults vs your overrides; a field left as None while siblings are ints triggers this.
- Build the config programmatically so all four sizes are set together.
Example fix
# before cfg = TuningConfig(block_q_dq=128) # after cfg = TuningConfig(block_q_dq=128, block_kv_dq=128, block_q_dkv=64, block_kv_dkv=128) # or simply cfg = TuningConfig()
Defensive patterns
Strategy: validation
Validate before calling
bwd = [cfg.block_q_dq, cfg.block_kv_dq, cfg.block_q_dkv, cfg.block_kv_dkv] assert all(b is not None for b in bwd) or all(b is None for b in bwd)
Type guard
def backward_blocks_consistent(cfg) -> bool:
blocks = [cfg.block_q_dq, cfg.block_kv_dq, cfg.block_q_dkv, cfg.block_kv_dkv]
return all(b is None for b in blocks) or all(b is not None for b in blocks) Prevention
- Build TuningConfig presets programmatically so all four backward sizes are set together.
- Never partially override a copied preset; override all-or-none of the backward block fields.
When it happens
Trigger: Constructing TuningConfig (e.g. HOPPER_CONFIG-style presets or a custom config) where some but not all of block_q_dq, block_kv_dq, block_q_dkv, block_kv_dkv are provided.
Common situations: Copying a preset config and overriding only one block size; merging configs where overrides drop some fields; partial migration to a new config schema.
Related errors
- cap_method must be in [tanh, soft_sign], got {cap_method}
- Invalid backward pass implementation: {backward_pass_impl}
- cap_method must be in [tanh, soft_sign, none], got {cap_meth
- {self.block_q=} must be a multiple of 64
- {self.block_kv=} must be a multiple of 64
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/dd1e882acf828711.
Report an issue: GitHub.