jax-ml/jax · error · ValueError

for select='i', select_range must be specified.

Error message

for select='i', select_range must be specified.

What it means

When eigh_tridiagonal is called with select='i' (select eigenvalues by index range), you must supply select_range=(lo, hi) specifying which eigenvalue indices to return. Without it, ValueError is raised.

Source

Thrown at jax/_src/scipy/linalg.py:1835

  pivmin = safemin * jnp.maximum(1, jnp.amax(beta_sq))
  alpha0_perturbation = jnp.square(finfo.eps * beta_abs[0])
  abs_tol = finfo.eps * t_norm
  if tol is not None:
    abs_tol = jnp.maximum(tol, abs_tol)

  # In the worst case, when the absolute tolerance is eps*lambda_est_max and
  # lambda_est_max = -lambda_est_min, we have to take as many bisection steps
  # as there are bits in the mantissa plus 1.
  # The proof is left as an exercise to the reader.
  max_it = finfo.nmant + 1

  # Determine the indices of the desired eigenvalues, based on select and
  # select_range.
  if select == 'a':
    target_counts = jnp.arange(n, dtype=np.int32)
  elif select == 'i':
    if select_range is None:
      raise ValueError("for select='i', select_range must be specified.")
    if select_range[0] > select_range[1]:
      raise ValueError('Got empty index range in select_range.')
    target_counts = jnp.arange(select_range[0], select_range[1] + 1, dtype=np.int32)
  elif select == 'v':
    # TODO(phawkins): requires dynamic shape support.
    raise NotImplementedError("eigh_tridiagonal(..., select='v') is not "
                              "implemented")
  else:
    raise ValueError("'select must have a value in {'a', 'i', 'v'}.")

  # Run binary search for all desired eigenvalues in parallel, starting from
  # the interval lightly wider than the estimated
  # [lambda_est_min, lambda_est_max].
  fudge = 2.1  # We widen starting interval the Gershgorin interval a bit.
  norm_slack = jnp.array(n, alpha.dtype) * fudge * finfo.eps * t_norm
  lower = lambda_est_min - norm_slack - 2 * fudge * pivmin
  upper = lambda_est_max + norm_slack + fudge * pivmin

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Pass select_range=(lo, hi) inclusive, e.g. select='i', select_range=(0, k-1) for the lowest k eigenvalues
  2. Or use the default select='a' and slice the full result if dynamic shapes are problematic under jit

Example fix

// before
w = jax.scipy.linalg.eigh_tridiagonal(d, e, select='i', eigvals_only=True)
// after
w = jax.scipy.linalg.eigh_tridiagonal(d, e, select='i', select_range=(0, 4), eigvals_only=True)
Defensive patterns

Strategy: validation

Validate before calling

if select == 'i': assert select_range is not None, 'select_range required for select=i'

Type guard

null

Prevention

When it happens

Trigger: Calling jax.scipy.linalg.eigh_tridiagonal(d, e, select='i') with select_range left at its default None.

Common situations: Porting scipy.linalg.eigh_tridiagonal calls where select_range was always provided; conditionally setting select but forgetting to pass the matching range.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27). Data as JSON: /api/errors/614a6c911d8038cc. Report an issue: GitHub.