{"record":{"id":"5a4d1a1ec75129c6","repo":"jax-ml/jax","slug":"the-second-argument-to-householder-product-must-no","errorCode":null,"errorMessage":"The second argument to householder_product must not have more rows than the minimum of the first argument's rows and columns.","messagePattern":"The second argument to householder_product must not have more rows than the minimum of the first argument's rows and columns\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/lax/linalg.py","lineNumber":1429,"sourceCode":"\n\nhessenberg_p = linalg_primitive(\n    _hessenberg_dtype_rule, (_float | _complex,), (2,), _hessenberg_shape_rule,\n    \"hessenberg\", multiple_results=True)\nmlir.register_lowering(hessenberg_p, _hessenberg_cpu_lowering, platform=\"cpu\")\n\n\n# Householder product\n\ndef _householder_product_shape_rule(a_shape, taus_shape, **_):\n  m, n = a_shape\n  if m < n:\n    raise ValueError(\n        \"The first argument to householder_product must have at least as many \"\n        f\"rows as columns, got shape {a_shape}\")\n  k = taus_shape[0]\n  if k > core.min_dim(m, n):\n    raise ValueError(\n        \"The second argument to householder_product must not have more rows \"\n        \"than the minimum of the first argument's rows and columns.\")\n  return a_shape\n\n\ndef _householder_product_lowering(ctx, a, taus):\n  aval_out, = ctx.avals_out\n  if not is_constant_shape(aval_out.shape):\n    result_shapes = [\n        mlir.eval_dynamic_shape_as_tensor(ctx, aval_out.shape)]\n  else:\n    result_shapes = None\n  flat_res_types, _ = mlir.ir_tree_registry.flatten(\n      mlir.aval_to_ir_types(ctx.module_context, aval_out))\n  op = mlir.custom_call(\n      \"ProductOfElementaryHouseholderReflectors\",\n      result_types=flat_res_types,\n      operands=[a, taus],","sourceCodeStart":1411,"sourceCodeEnd":1447,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/lax/linalg.py#L1411-L1447","documentation":"jax/_src/lax/linalg.py:1429 in _householder_product_shape_rule. The taus vector (Householder scalars) must have length k <= min(m, n) of the reflector matrix a, since at most min(m, n) reflectors exist. Passing a longer taus (e.g. full-length diagonal or extra scalars) raises this ValueError.","triggerScenarios":"Calling jax.lax.linalg.householder_product(a, taus) where taus.shape[0] > min(a.shape[0], a.shape[1]); e.g. taking taus from hessenberg (length n-1) but passing an n-length slice, or concatenating tau arrays across batches incorrectly.","commonSituations":"Manually assembling reflector data instead of using the paired outputs of geqrf/hessenberg; batching where tau vectors from different matrices were padded to the max length.","solutions":["Trim taus to k = min(m, n): taus = taus[:min(a.shape[0], a.shape[1])]","Use the exact tau output returned by the factorization routine that produced a","When batching with padding, mask/trim tau to each matrix's reflector count"],"exampleFix":"// before\nq = jax.lax.linalg.householder_product(a, taus)  # taus longer than min(m, n)\n// after\nk = min(a.shape[0], a.shape[1])\nq = jax.lax.linalg.householder_product(a, taus[:k])","handlingStrategy":"validation","validationCode":"k = min(a.shape[0], a.shape[1])\ntaus = taus[:k]","typeGuard":"def valid_taus(a: jax.Array, taus: jax.Array) -> bool:\n    return taus.shape[-1] <= min(a.shape[-2], a.shape[-1])","tryCatchPattern":null,"preventionTips":["Use tau arrays exactly as returned by geqrf/hessenberg"],"tags":["jax","linalg","householder","shape-validation"],"backgroundTag":"invalid-matrix-dimensions","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}