{"record":{"id":"fa5c0e061a7f2d96","repo":"jax-ml/jax","slug":"conv-general-dilated-batch-group-count-must-be-a-p","errorCode":null,"errorMessage":"conv_general_dilated batch_group_count must be a positive integer, got {}.","messagePattern":"conv_general_dilated batch_group_count must be a positive integer, got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/lax/convolution.py","lineNumber":425,"sourceCode":"    msg = (\"conv_general_dilated feature_group_count must divide lhs feature \"\n           \"dimension size, but {} does not divide {}.\")\n    raise ValueError(msg.format(feature_group_count, lhs_feature_count))\n  if not core.definitely_equal(quot, rhs.shape[dimension_numbers.rhs_spec[1]]):\n    msg = (\"conv_general_dilated lhs feature dimension size divided by \"\n           \"feature_group_count must equal the rhs input feature dimension \"\n           \"size, but {} // {} != {}.\")\n    raise ValueError(msg.format(lhs_feature_count, feature_group_count,\n                                rhs.shape[dimension_numbers.rhs_spec[1]]))\n  if rhs.shape[dimension_numbers.rhs_spec[0]] % feature_group_count:\n    msg = (\"conv_general_dilated rhs output feature dimension size must be a \"\n           \"multiple of feature_group_count, but {} is not a multiple of {}.\")\n    raise ValueError(msg.format(rhs.shape[dimension_numbers.rhs_spec[0]],\n                                feature_group_count))\n\n  if not batch_group_count > 0:\n    msg = (\"conv_general_dilated batch_group_count \"\n           \"must be a positive integer, got {}.\")\n    raise ValueError(msg.format(batch_group_count))\n  lhs_batch_count = lhs.shape[dimension_numbers.lhs_spec[0]]\n  if batch_group_count > 1 and lhs_batch_count % batch_group_count != 0:\n    msg = (\"conv_general_dilated batch_group_count must divide lhs batch \"\n           \"dimension size, but {} does not divide {}.\")\n    raise ValueError(msg.format(batch_group_count, lhs_batch_count))\n\n  if rhs.shape[dimension_numbers.rhs_spec[0]] % batch_group_count:\n    msg = (\"conv_general_dilated rhs output feature dimension size must be a \"\n           \"multiple of batch_group_count, but {} is not a multiple of {}.\")\n    raise ValueError(msg.format(rhs.shape[dimension_numbers.rhs_spec[0]],\n                                batch_group_count))\n\n  if batch_group_count > 1 and feature_group_count > 1:\n    msg = (\"At most one of batch_group_count and feature_group_count may be > \"\n           \"1, got batch_group_count={} and feature_group_count={}\")\n    raise ValueError(msg.format(batch_group_count, feature_group_count))\n\n  if len(_conv_sdims(dimension_numbers.rhs_spec)) != len(window_strides):","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/lax/convolution.py#L407-L443","documentation":"batch_group_count in conv_general_dilated (used for vmap'd batched convs) must be a positive integer; the shape rule checks `batch_group_count > 0` and raises ValueError otherwise, mirroring the feature_group_count check.","triggerScenarios":"Calling lax.conv_general_dilated(..., batch_group_count=0) or with a negative value; typically the parameter is managed by jax.vmap's batch rules rather than set manually.","commonSituations":"Manually constructing batched convolutions instead of letting vmap handle batching; passing an uninitialized/default-zero groups variable into batch_group_count.","solutions":["Set batch_group_count to a positive int (usually 1)","Prefer jax.vmap over conv for batching convs instead of manually setting batch_group_count","Audit any computed group parameters with max(1, n)"],"exampleFix":"// before\nlax.conv_general_dilated(x, k, (1,1), 'SAME', batch_group_count=bgc)  # bgc == 0\n// after\nlax.conv_general_dilated(x, k, (1,1), 'SAME', batch_group_count=max(1, bgc))","handlingStrategy":"validation","validationCode":"assert batch_group_count > 0, batch_group_count","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Let jax.vmap manage batching instead of setting batch_group_count manually","Sanitize computed group params with max(1, n)"],"tags":["jax","lax","convolution","batch-group-count"],"backgroundTag":"invalid-parameter-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}