{"record":{"id":"15d409a4c530db78","repo":"keras-team/keras","slug":"could-not-determine-row-column-split","errorCode":null,"errorMessage":"Could not determine row/column split.","messagePattern":"Could not determine row/column split\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/core/einsum_dense.py","lineNumber":690,"sourceCode":"            columns = kernel_shape[1]\n        elif len(kernel_shape) == 3:\n            shape = list(self.original_kernel_shape)\n            d_model_dim_index = shape.index(max(shape))\n\n            if d_model_dim_index == 0:  # QKV projection case\n                in_features, heads, head_dim = shape\n                rows, columns = (\n                    in_features,\n                    heads * head_dim,\n                )\n            elif d_model_dim_index in [1, 2]:  # Attention Output case\n                heads, head_dim, out_features = shape\n                rows, columns = (\n                    heads * head_dim,\n                    out_features,\n                )\n            else:\n                raise ValueError(\"Could not determine row/column split.\")\n\n        group_size = gptq_core.get_group_size_for_layer(self, config)\n        n_groups = 1 if group_size == -1 else math.ceil(rows / group_size)\n\n        self.gptq_unpacked_column_size = columns\n\n        weight_bits = gptq_core.get_weight_bits_for_layer(self, config)\n        # 4-bit weights pack two values per byte; 2-bit weights pack four.\n        # Other bit-widths (e.g. 3, 8) are stored one value per byte.\n        if weight_bits == 4:\n            kernel_columns = (columns + 1) // 2\n        elif weight_bits == 2:\n            kernel_columns = (columns + 3) // 4\n        else:\n            kernel_columns = columns\n\n        self._set_quantization_info()\n","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/core/einsum_dense.py#L672-L708","documentation":"During GPTQ quantized_build, EinsumDense._gptq_build derives a (rows, columns) split from the kernel shape. It handles 2D kernels directly and 3D kernels whose layout decomposes into (heads, head_dim, out_features) via the equation; when the einsum equation or shape does not expose a usable split, it raises this ValueError because the group-size math (rows / group_size) needs concrete dimensions.","triggerScenarios":"Quantizing an EinsumDense whose kernel is higher-rank or 3D but whose einsum equation does not let Keras infer heads/head_dim/out_features (custom or unusual equations), under a quantization config whose layer structure covers this layer.","commonSituations":"Custom attention/MLP projection equations that do not match the expected pattern; applying model.quantize(...) too broadly so it covers an exotic EinsumDense; output_dim given as a shape tuple the splitter cannot decompose.","solutions":["Restructure the layer to a standard 2D kernel ('ab,bc->ac') or a recognized 3D attention layout.","Exclude this layer from the quantization structure via filters so _gptq_build never runs on it.","Check the equation and output_dim: ensure the kernel resolves to (in_features, out_features) or (heads, head_dim, out_features)."],"exampleFix":"# before\nlayer = keras.layers.EinsumDense('aijk,jk->aik', output_dim=(None, 32))  # unrecognizable layout\nmodel.quantize(cfg)  # ValueError: Could not determine row/column split.\n\n# after\nmodel.quantize(cfg, filters=[l.name for l in model.layers if l is not layer])\n# or refactor the layer to 'ab,bc->ac'","handlingStrategy":"validation","validationCode":"shape = tuple(layer.kernel.shape) if layer.built else None\nif shape is None or len(shape) > 3:\n    raise RuntimeError('GPTQ cannot split this kernel; exclude layer from quantization')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep EinsumDense equations in standard 2D or attention-style 3D form.","Use quantization filters to exclude exotic layers from GPTQ."],"tags":["keras","gptq","quantization","einsum-dense","kernel-shape"],"backgroundTag":"quantization-unsupported-shape","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}