{"record":{"id":"9fd4a1da2ce70e3a","repo":"jax-ml/jax","slug":"name1-and-name2-in-op-name-op-must-be-disjoi","errorCode":null,"errorMessage":"{name1} and {name2} in {op_name} op must be disjoint; got: {dims1} and {dims2}.","messagePattern":"(.+?) and (.+?) in (.+?) op must be disjoint; got: (.+?) and (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/lax/slicing.py","lineNumber":1808,"sourceCode":"def _sorted_dims_in_range(dims, rank, op_name, name):\n  if len(dims) == 0:\n    return\n  invalid_dim = None\n  if dims[0] < 0:\n    invalid_dim = dims[0]\n  elif dims[-1] >= rank:\n    invalid_dim = dims[-1]\n  if invalid_dim:\n    raise TypeError(f\"Invalid {name} set in {op_name} op; valid range is \"\n                    f\"[0, {rank}); got: {invalid_dim}.\")\n\ndef _no_duplicate_dims(dims, op_name, name):\n  if len(set(dims)) != len(dims):\n    raise TypeError(f\"{name} in {op_name} op must not repeat; got: {dims}.\")\n\ndef _disjoint_dims(dims1, dims2, op_name, name1, name2):\n  if not set(dims1).isdisjoint(set(dims2)):\n    raise TypeError(f\"{name1} and {name2} in {op_name} op must be disjoint; \"\n                    f\"got: {dims1} and {dims2}.\")\n\ndef _gather_shape_rule(operand, indices, *, dimension_numbers,\n                       slice_sizes, unique_indices, indices_are_sorted,\n                       mode, fill_value):\n  \"\"\"Validates the well-formedness of the arguments to Gather.\n\n  The code implements the checks based on the detailed operation semantics of\n  XLA's `Gather <https://www.openxla.org/xla/operation_semantics#gather>`_\n  operator and following the outline of the implementation of\n  ShapeInference::InferGatherShape in TensorFlow.\n  \"\"\"\n\n  offset_dims = dimension_numbers.offset_dims\n  collapsed_slice_dims = dimension_numbers.collapsed_slice_dims\n  operand_batching_dims = dimension_numbers.operand_batching_dims\n  start_indices_batching_dims = dimension_numbers.start_indices_batching_dims\n  start_index_map = dimension_numbers.start_index_map","sourceCodeStart":1790,"sourceCodeEnd":1826,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/lax/slicing.py#L1790-L1826","documentation":"Validator used by gather/scatter shape rules that requires two dimension lists to be pairwise disjoint, e.g. collapsed_slice_dims and offset_dims in gather, or update_window_dims and inserted_window_dims in scatter. Sharing any axis between the two lists raises this TypeError showing both lists, because an axis cannot play two roles in the dimension mapping.","triggerScenarios":"Building lax.GatherDimensionNumbers with an axis present in both collapsed_slice_dims and offset_dims; or lax.ScatterDimensionNumbers where an axis appears in both update_window_dims and inserted_window_dims; then calling lax.gather / lax.scatter.","commonSituations":"Hand-writing dimension numbers to mimic an embedding lookup and double-assigning the axis that holds the index; configs copied between gather and scatter with different disjointness rules; computing one list as 'all dims' and the other non-empty.","solutions":["Partition the rank: every axis 0..rank-1 goes into exactly one of the two lists (e.g. offset_dims + collapsed_slice_dims should cover the slice dims without overlap).","Remove the shared axis from one list, usually from offset_dims / update_window_dims.","Validate with set(list1).isdisjoint(list2) before calling, or switch to jnp.take / .at[] helpers."],"exampleFix":"# before\ndnums = lax.GatherDimensionNumbers(\n    offset_dims=(0,), collapsed_slice_dims=(0, 1), start_index_map=(0,))\nout = lax.gather(x, idx, dnums, slice_sizes=(1,))  # axis 0 in both -> TypeError\n\n# after\ndnums = lax.GatherDimensionNumbers(\n    offset_dims=(0,), collapsed_slice_dims=(1,), start_index_map=(0,))\nout = lax.gather(x, idx, dnums, slice_sizes=(1, 1))","handlingStrategy":"validation","validationCode":"assert set(collapsed_slice_dims).isdisjoint(offset_dims), \\\n    f\"overlapping dims: {collapsed_slice_dims} vs {offset_dims}\"\ndnums = lax.GatherDimensionNumbers(offset_dims, collapsed_slice_dims, start_index_map)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the two lists as a partition of the axes; assign each axis exactly one role.","Assert set(list_a).isdisjoint(set(list_b)) in tests for every dnums/sdnums you define.","Document which axes belong to which list next to each config."],"tags":["jax","lax","gather","scatter","dimension-numbers"],"backgroundTag":"overlapping-dimension-sets","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}