{"record":{"id":"27fae6a5d7acb2e5","repo":"jax-ml/jax","slug":"bkv-compute-should-not-be-greater-than-bkv","errorCode":null,"errorMessage":"{bkv_compute=} should not be greater than {bkv=}","messagePattern":"(.+?) should not be greater than (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py","lineNumber":1908,"sourceCode":"    v_layout: QKVLayout,\n    mask_function: MaskFunctionType | None,\n    interpret: bool,\n):\n  num_q_heads, q_seq_len, head_dim_qk = q.shape\n  head_dim_v = v.shape[-1]\n  if is_mqa:\n    num_kv_heads, kv_seq_len = 1, k.shape[0]\n  else:\n    num_kv_heads, kv_seq_len, _ = k.shape\n\n  if bq > q_seq_len:\n    raise ValueError(\n        f\"{bq=} should not be greater than {q_seq_len=}\")\n  if bkv > kv_seq_len:\n    raise ValueError(\n        f\"{bkv=} should not be greater than {kv_seq_len=}\")\n  if bkv_compute > bkv:\n    raise ValueError(\n        f\"{bkv_compute=} should not be greater than {bkv=}\")\n  if bkv % bkv_compute:\n    raise ValueError(\n        f\"{bkv=} should be a multiple of {bkv_compute=}\")\n\n  if not is_mqa and num_q_heads % num_kv_heads != 0:\n    raise ValueError(\n        f\"In MHA, expected number of 'key' heads ({num_kv_heads}) to be a\"\n        f\" multiple of the number of 'query' heads ({num_q_heads})\"\n    )\n\n  if k.shape[:-1] != v.shape[:-1]:\n    raise ValueError(\n        f\"Expected 'key' {k.shape} and 'value' {v.shape} to have the same \"\n        \"leading dimensions.\"\n    )\n\n  q_heads_per_kv_head = num_q_heads // num_kv_heads","sourceCodeStart":1890,"sourceCodeEnd":1926,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py#L1890-L1926","documentation":"Splash Attention backward validates that the compute tile for KV (bkv_compute) does not exceed the memory tile bkv. The kernel splits the KV block into compute sub-blocks, so the sub-block must fit inside the block.","triggerScenarios":"Setting BlockSizes.block_kv_dkv_compute > BlockSizes.block_kv_dkv when configuring backward blocks for splash attention on TPU.","commonSituations":"Hand-tuning block sizes for TPU memory; copying block-size configs from a different kernel version where defaults differ; partial overrides that leave an inconsistent combination.","solutions":["Set block_kv_dkv_compute <= block_kv_dkv","Prefer leaving bkv_compute at its default (often None) so it is derived automatically","Validate the full BlockSizes tuple together rather than overriding single fields"],"exampleFix":"// before\nBlockSizes(block_kv_dkv=128, block_kv_dkv_compute=256)\n// after\nBlockSizes(block_kv_dkv=256, block_kv_dkv_compute=128)","handlingStrategy":"validation","validationCode":"assert bs.block_kv_dkv_compute is None or bs.block_kv_dkv_compute <= bs.block_kv_dkv","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Leave compute blocks as None to use derived defaults","Centralize BlockSizes construction in one helper that enforces invariants"],"tags":["jax","tpu","pallas","splash-attention","block-sizes","validation"],"backgroundTag":"block-size-exceeds-dimension","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}