jax-ml/jax · error · ValueError

Method {method} not recognized

Error message

Method {method} not recognized

What it means

jax.scipy.optimize.minimize only ships a small set of methods (BFGS and L-BFGS and a few others handled above the raise); any unrecognized method string falls through to this ValueError.

Source

Thrown at jax/_src/scipy/optimize/minimize.py:133

                           hess_inv=results.H_k,
                           nfev=results.nfev,
                           njev=results.ngev,
                           nit=results.k)

  if method.lower() == 'l-bfgs-experimental-do-not-rely-on-this':
    results = _minimize_lbfgs(fun_with_args, x0, **options)
    success = results.converged & jnp.logical_not(results.failed)
    return OptimizeResults(x=results.x_k,
                           success=success,
                           status=results.status,
                           fun=results.f_k,
                           jac=results.g_k,
                           hess_inv=None,
                           nfev=results.nfev,
                           njev=results.ngev,
                           nit=results.k)

  raise ValueError(f"Method {method} not recognized")

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Use a supported method such as 'BFGS' or 'L-BFGS'
  2. If you need other algorithms, use jaxopt/optax optimizers instead
  3. Check the method string spelling/case against the dispatch branches

Example fix

# before
res = minimize(loss, x0, method='Nelder-Mead')
# after
import optax
# or
res = minimize(loss, x0, method='BFGS')
Defensive patterns

Strategy: validation

Validate before calling

assert method.lower() in ('bfgs', 'l-bfgs', 'l-bfgs-experimental-do-not-rely-on-this'), method

Type guard

def method_supported(m: str) -> bool: return m.lower() in ('bfgs', 'l-bfgs')

Prevention

When it happens

Trigger: Passing method='Nelder-Mead', method='CG', method='Powell', or a typo like 'lbfgs ' (note: match is on exact strings per-branch, commonly lowercase).

Common situations: Porting scipy.optimize scripts expecting the full scipy method menu; jax supports only a subset.

Related errors


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