{"record":{"id":"4a90ada7a159790f","repo":"jax-ml/jax","slug":"conv-general-dilated-rhs-output-feature-dimension","errorCode":null,"errorMessage":"conv_general_dilated rhs output feature dimension size must be a multiple of feature_group_count, but {} is not a multiple of {}.","messagePattern":"conv_general_dilated rhs output feature dimension size must be a multiple of feature_group_count, but (.+?) is not a multiple of (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/lax/convolution.py","lineNumber":419,"sourceCode":"    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\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","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/lax/convolution.py#L401-L437","documentation":"In grouped convolutions the rhs (kernel) output-feature dimension must be a multiple of feature_group_count so outputs can be split evenly across groups. The shape rule checks rhs out-features % feature_group_count and raises ValueError naming both values.","triggerScenarios":"Grouped conv with kernel output channels not divisible by groups, e.g. groups=4 with a kernel producing 6 output channels.","commonSituations":"Choosing output channels via a width multiplier that breaks divisibility by groups; ports from PyTorch where out_channels is already per-multiple of groups but rounding differs.","solutions":["Make out_channels divisible by feature_group_count (round up/down to nearest multiple)","For depthwise conv set out_channels = in_channels * multiplier so divisibility holds","Validate at model-build time: assert cout % groups == 0"],"exampleFix":"// before\nlax.conv_general_dilated(x, k_cout6, (1,1), 'SAME', feature_group_count=4)\n// after\nk_cout8 = ...  # 8 % 4 == 0\nlax.conv_general_dilated(x, k_cout8, (1,1), 'SAME', feature_group_count=4)","handlingStrategy":"validation","validationCode":"assert kernel.shape[rhs_out_feature_axis] % feature_group_count == 0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Round out_channels to a multiple of groups","assert cout % groups == 0 at layer construction"],"tags":["jax","lax","convolution","feature-group-count","kernel-shape"],"backgroundTag":"group-count-not-divisible","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}