{"record":{"id":"b99fb79b1e9bd033","repo":"jax-ml/jax","slug":"num-arrivals-must-be-at-least-1-but-got-n","errorCode":null,"errorMessage":"Num arrivals must be at least 1, but got {n}","messagePattern":"Num arrivals must be at least 1, but got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic_gpu/core.py","lineNumber":1503,"sourceCode":"class Barrier:\n  \"\"\"Describes a barrier reference.\n\n  Attributes:\n    num_arrivals: The number of arrivals that will be recorded by this barrier.\n    num_barriers: The number of barriers that will be created. Individual\n      barriers can be accessed by indexing into the barrier Ref.\n    orders_tensor_core: If False, a successful wait from one thread does not\n      guarantee that the TensorCore-related operations in other threads have\n      completed. Similarly, when False any TensorCore operation in the waiting\n      thread is allowed to begin before the wait succeeds.\n  \"\"\"\n  num_arrivals: int = 1\n  num_barriers: int | Sequence[int] = 1\n  orders_tensor_core: bool = False\n\n  def __post_init__(self):\n    if (n := self.num_arrivals) < 1:\n      raise ValueError(f\"Num arrivals must be at least 1, but got {n}\")\n\n    if isinstance(self.num_barriers, int):\n      object.__setattr__(self, \"num_barriers\", (self.num_barriers,))\n    else:\n      object.__setattr__(self, \"num_barriers\", tuple(self.num_barriers))\n\n  def get_array_aval(self) -> jax_core.ShapedArray:\n    raise ValueError(\"Barriers are not arrays\")\n\n  def get_ref_aval(self) -> state.AbstractRef:\n    ty = BarrierType(self.num_arrivals, self.orders_tensor_core)\n    return state.AbstractRef(jax_core.ShapedArray(self.num_barriers, ty), SMEM)\n\n\n@dataclasses.dataclass(frozen=True, kw_only=True)\nclass ClusterBarrier:\n  collective_axes: tuple[str | tuple[str, ...], ...]\n  num_barriers: int | Sequence[int] = 1","sourceCodeStart":1485,"sourceCodeEnd":1521,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic_gpu/core.py#L1485-L1521","documentation":"BarrierSpec.__post_init__ validates that num_arrivals >= 1. Arrivals count the threads/blocks that must arrive at an asynchronous barrier before it releases; zero or negative arrivals is nonsensical and rejected immediately at construction.","triggerScenarios":"Constructing a BarrierSpec with num_arrivals=0 or negative — often from a computed arrival count (e.g. num_threads // divisor) that evaluates to 0.","commonSituations":"Deriving num_arrivals from a layout parameter that can be 0 (empty warp config), arithmetic errors in warp-specialized pipeline setup, or defaults silently overwritten.","solutions":["Check the formula producing num_arrivals and clamp/validate it to >= 1","Pass num_arrivals explicitly as the number of arriving warps/blocks","Add an assert num_arrivals >= 1 near the configuration code"],"exampleFix":"// before\nspec = plgpu.BarrierSpec(num_arrivals=num_warps // 4)  # 0 if num_warps < 4\n// after\nassert num_warps >= 4\nspec = plgpu.BarrierSpec(num_arrivals=num_warps // 4)","handlingStrategy":"validation","validationCode":"assert num_arrivals >= 1, f'num_arrivals must be >= 1, got {num_arrivals}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate arrival-count formulas at config time","Never let derived arrival counts reach 0"],"tags":["jax","pallas","barrier","validation","config"],"backgroundTag":"invalid-barrier-configuration","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}