{"record":{"id":"ae4b9b2a00c97354","repo":"jax-ml/jax","slug":"the-manually-assigned-collective-id-in-kernel","errorCode":null,"errorMessage":"The manually assigned {collective_id=} in {kernel_name=} conflicts with an existing auto-assigned collective id. Auto-assignment uses a base collective id of {_AUTO_COLLECTIVE_BASE_ID}. Please use values away from this offset.","messagePattern":"The manually assigned (.+?) in (.+?) conflicts with an existing auto-assigned collective id\\. Auto-assignment uses a base collective id of (.+?)\\. Please use values away from this offset\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/tpu_custom_call.py","lineNumber":775,"sourceCode":"              _AUTO_COLLECTIVE_BASE_ID + auto_num + len(existing_ids) + 1)\n          new_id = next(id for id in proposed_ids if id not in existing_ids)\n          ctx.module_context.pallas_collective_id_mapping.auto[key] = new_id\n          ctx.module_context.pallas_collective_id_mapping.all_ids.add(new_id)\n          collective_id = new_id\n          if (len(ctx.module_context.pallas_collective_id_mapping.auto)\n              > _AUTO_COLLECTIVE_ID_LIMIT):\n            logging.warning(\n                \"The number of auto-assigned collective ids for pallas kernels\"\n                \" is very large, consider manually annotating the kernels with\"\n                \" collective ids:\"\n                f\" {ctx.module_context.pallas_collective_id_mapping}\"\n            )\n      else:  # Manually assigned collective ID.\n        # We need to check for a conflict between the manual collective id\n        # and the auto-assigned collective ids so far.\n        if (collective_id\n            in ctx.module_context.pallas_collective_id_mapping.auto.values()):\n          raise ValueError(\n              f\"The manually assigned {collective_id=} in {kernel_name=}\"\n              \" conflicts with an existing auto-assigned collective id.\"\n              \" Auto-assignment uses a base collective id of\"\n              f\" {_AUTO_COLLECTIVE_BASE_ID}. Please use values away from this\"\n              \" offset.\"\n          )\n        ctx.module_context.pallas_collective_id_mapping.manual[key] = (\n            collective_id\n        )\n        ctx.module_context.pallas_collective_id_mapping.all_ids.add(\n            collective_id\n        )\n\n    if collective_id is None:\n      raise ValueError(\n          \"collective_id has to be specified when using a custom barrier \"\n          \"(cannot auto-allocate without lowering context)\"\n      )","sourceCodeStart":757,"sourceCodeEnd":793,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/tpu_custom_call.py#L757-L793","documentation":"A user-specified collective_id collides with an id the compiler auto-assigned (auto ids start at _AUTO_COLLECTIVE_BASE_ID) for barriers in the same module.","triggerScenarios":"Passing a manual collective_id to a Pallas kernel that falls in the auto-assigned range while other collectives were auto-allocated in the same lowering.","commonSituations":"Choosing small collective_id values that overlap the auto base offset when multiple kernels use custom barriers.","solutions":["Pick a collective_id far from _AUTO_COLLECTIVE_BASE_ID (e.g. a large number like 10000+)","Avoid specifying collective_id and let the compiler auto-assign"],"exampleFix":"// before\nkernel(..., compiler_params=dict(collective_id=50))\n// after\nkernel(..., compiler_params=dict(collective_id=100000))","handlingStrategy":"validation","validationCode":"from jax._src.tpu_custom_call import _AUTO_COLLECTIVE_BASE_ID as BASE\nassert collective_id is None or collective_id >= BASE + 10000","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use high, well-separated collective ids for manual barriers","Prefer auto-assignment when possible"],"tags":["tpu","pallas","collective-id","barrier","conflict"],"backgroundTag":"id-collision","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}