{"record":{"id":"f519bf99cdf879ab","repo":"jax-ml/jax","slug":"must-have-search-dim-0-got-k","errorCode":null,"errorMessage":"must have search dim > 0, got {k}","messagePattern":"must have search dim > 0, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/sparse/linalg.py","lineNumber":253,"sourceCode":"    state, diagnostics = jax.lax.scan(\n        lambda state, _: body(state), state, xs=None, length=m)\n  else:\n    state = jax.lax.while_loop(cond, body, state)\n    diagnostics = None\n  i, X, _P, _R, _converged, theta = state\n\n  if debug:\n    assert diagnostics is not None\n    return theta[0, :], X, i, diagnostics\n  return theta[0, :], X, i\n\n\ndef _check_inputs(A, X):\n  n, k = X.shape\n  dt = X.dtype\n\n  if k == 0:\n    raise ValueError(f'must have search dim > 0, got {k}')\n\n  if k * 5 >= n:\n    raise ValueError(f'expected search dim * 5 < matrix dim (got {k * 5}, {n})')\n\n  test_output = A(jnp.zeros((n, 1), dtype=X.dtype))\n\n  if test_output.dtype != dt:\n    raise ValueError(\n        f'A, X must have same dtypes (were {test_output.dtype}, {dt})')\n\n  if test_output.shape != (n, 1):\n    s = test_output.shape\n    raise ValueError(f'A must be ({n}, {n}) matrix A, got output {s}')\n\n\ndef _mm(a, b, precision=jax.lax.Precision.HIGHEST):\n  return jax.lax.dot(a, b, precision=(precision, precision))\n","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/sparse/linalg.py#L235-L271","documentation":"Input validation for sparse LOBPCG (locally optimal block preconditioned conjugate gradient): the search block X must have a positive number of columns k (eigenvectors sought). A zero-width block cannot be used to start the iteration.","triggerScenarios":"Calling jax.experimental.sparse.linalg.lobpcg_standard with X of shape (n, 0), e.g. because the number of requested eigenpairs was computed as 0.","commonSituations":"Passing k=0 from a config; deriving k from data (e.g. k = rank estimate that evaluates to 0) inside a hyperparameter sweep.","solutions":["Ensure the number of requested eigenpairs k >= 1","Check upstream computation that produced X's width before calling lobpcg_standard"],"exampleFix":"// before\nX = jnp.zeros((n, 0))\ntheta, U, iters = lobpcg_standard(A, X)\n// after\nX = jnp.zeros((n, 5))\ntheta, U, iters = lobpcg_standard(A, X)","handlingStrategy":"validation","validationCode":"n, k = X.shape\nif k < 1:\n    raise ValueError(f'need at least one eigenpair, got k={k}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate k > 0 before calling lobpcg_standard","Compute k from rank estimates with max(k, 1)"],"tags":["jax","sparse","lobpcg","eigensolver","validation"],"backgroundTag":"eigensolver-invalid-block-size","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}