{"record":{"id":"3d7381a51910a6e1","repo":"jax-ml/jax","slug":"conv-general-dilated-feature-group-count-must-be-a","errorCode":null,"errorMessage":"conv_general_dilated feature_group_count must be a positive integer, got {}.","messagePattern":"conv_general_dilated feature_group_count must be a positive integer, got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/lax/convolution.py","lineNumber":403,"sourceCode":"    rhs = rhs.swapaxes(dn.rhs_spec[0], dn.rhs_spec[1])\n  return conv_general_dilated(lhs, rhs, one, pads, strides, rhs_dilation, dn,\n                              precision=precision,\n                              preferred_element_type=preferred_element_type)\n\n\ndef _conv_general_dilated_shape_rule(\n    lhs: core.ShapedArray, rhs: core.ShapedArray, *, window_strides, padding,\n    lhs_dilation, rhs_dilation, dimension_numbers, feature_group_count,\n    batch_group_count, **unused_kwargs) -> tuple[int, ...]:\n  assert type(dimension_numbers) is ConvDimensionNumbers\n  if len(lhs.shape) != len(rhs.shape):\n    msg = (\"conv_general_dilated lhs and rhs must have the same number of \"\n           \"dimensions, but got {} and {}.\")\n    raise ValueError(msg.format(lhs.shape, rhs.shape))\n  if not feature_group_count > 0:\n    msg = (\"conv_general_dilated feature_group_count \"\n           \"must be a positive integer, got {}.\")\n    raise ValueError(msg.format(feature_group_count))\n  lhs_feature_count = lhs.shape[dimension_numbers.lhs_spec[1]]\n  quot, rem = divmod(lhs_feature_count, feature_group_count)\n  if rem:\n    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","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/lax/convolution.py#L385-L421","documentation":"feature_group_count in conv_general_dilated controls grouped convolutions (like PyTorch's groups) and must be a positive integer. The shape rule checks `feature_group_count > 0` and raises ValueError otherwise, e.g. when 0 or a negative value slips in.","triggerScenarios":"Calling lax.conv_general_dilated(..., feature_group_count=0) or passing a computed group count that evaluates to 0 (e.g. groups - 1, or integer division that yields 0).","commonSituations":"Translating PyTorch Conv2d(groups=N) to lax and computing feature_group_count incorrectly; using DepthwiseConv-like configs where groups=0 instead of groups=in_channels.","solutions":["Set feature_group_count to a positive int (1 for standard conv, in_channels for depthwise)","Compute as max(1, groups) if derived from user input","For depthwise conv, set feature_group_count equal to input channels and rhs feature dims accordingly"],"exampleFix":"// before\nlax.conv_general_dilated(x, k, (1,1), 'SAME', feature_group_count=groups-1)\n// after\nlax.conv_general_dilated(x, k, (1,1), 'SAME', feature_group_count=max(1, groups))","handlingStrategy":"validation","validationCode":"assert feature_group_count > 0, feature_group_count","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap computed group counts with max(1, n)","Model-build-time assert on all group parameters"],"tags":["jax","lax","convolution","feature-group-count"],"backgroundTag":"invalid-parameter-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}