Skip to content

Newton optimizer produces NaN parameters for a target with a flat direction, no error raised #3425

Open

Description

@sims1253

make_negative_definite_and_solve divides by fabs(eigenvalues[i]) without checking for zeros (division at line 24). For a parameter absent from the target, the Hessian is zero and the step is 0/0:

// model whose log_prob ignores its single parameter, returns 0.5
stan::optimization::newton_step<flat_model, false>(model, params_r, params_i);
// f0 = 0.5, params_r[0] = -nan

The caller loop accepts NaN (while (f1 < f0) is false for NaN) and the service returns error_codes::OK without a finiteness check, so the run reports success with NaN parameters. Probably related to #3306.

Environment:

  • Ubuntu 22.04.5 LTS (WSL2, kernel 6.18.33.2-microsoft-standard-WSL2), x86_64
  • stan-dev/stan develop @ 8ad5c98 (stan::math develop @ d20b238b9c)
  • g++ 11.4.0 (Ubuntu 22.04), -std=c++17

Activity

  1. shahd-elgouhary commented on Sep 14, 2026

    @shahd-elgouhary

    Can I take this issue, please?

  2. WardBrian commented on Sep 14, 2026

    @WardBrian
    Member

    Hi @shahd-elgouhary - a patch is already in progress for this issue in #3429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions