Skip to content

MathMixMatFun.add and MathMixMatFun.subtract tests seem to fail randomly? #1453

Closed

Description

@SteveBronder

Description

After #1424 we've had a couple PRs which look fine fail the MPI unit tests (but pass the GPU branch?)

Ex:

#1445 #1446 #1429

Not sure what's going on?

If we can find a quick patch for #1424 or understand why that's happening then cool and good otherwise let's do the revert and revert-revert PR

Current Version:

v3.0.0

Activity

  1. SteveBronder commented on Nov 11, 2019

    @SteveBronder
    CollaboratorAuthor

    Also the tests pass locally for me. Not sure if they are setting something off in the MPI that means we need a flag somewhere

  2. bob-carpenter commented on Nov 12, 2019

    @bob-carpenter
    Member

    I don't understand what's being proposed here. Did you want to revert #1424 for some reason? I couldn't tell from #1445 what's going wrong.

  3. SteveBronder commented on Nov 12, 2019

    @SteveBronder
    CollaboratorAuthor

    I'm looking into what's going on right now. Not sure if it's some weird interaction between something and MPI since the tests on the GPU node pass fine

  4. SteveBronder commented on Nov 12, 2019

    @SteveBronder
    CollaboratorAuthor

    Alright idk y but breaking them up into individual tests fixed it for one of the PRs. Gonna close this. @rok-cesnovar if you have time / think the matrix_cl<var> PR can get in tmrw we can just leave the fix in there otherwise I can slam out a quick PR that just has those fixed up

  5. bob-carpenter commented on Nov 13, 2019

    @bob-carpenter
    Member
  6. SteveBronder commented on Nov 13, 2019

    @SteveBronder
    CollaboratorAuthor

    I'm not sure either, something something curing the symptom and not the wound but we can just deal with those if they pop up as issues

  7. rok-cesnovar commented on Nov 28, 2019

    @rok-cesnovar
    Member

    Develop has just now failed with a similar error (see https://jenkins.mc-stan.org/blue/organizations/jenkins/Math%20Pipeline/detail/develop/404/pipeline/142)

    I will look into this tonight.

  8. bob-carpenter commented on Nov 28, 2019

    @bob-carpenter
    Member

    The failure is this:

    [ RUN      ] MathMixMatFun.add_vec_mat
    ./test/unit/math/expect_near_rel.hpp:39: Failure
    The difference between x1 and x2 is 0.0010334642265417964, which exceeds tol, where
    x1 evaluates to -0.0010334642265417964,
    x2 evaluates to 0, and
    tol evaluates to 0.001.
    expect_near_rel_finite(-0.0010334642265417964, 0, absolute tolerance = 0.001); absolute diff = 0.0010334642265417964    in: expect_near_rel; require items x1(i) = x2(i): hessian() Hessian
    ...
    

    First, the failure's within acceptable bounds. I've had to lower precision on a lot of finite diff Hessian tests to 1e-2. So if I'd gotten this locally, I'd have just lowered tolerances.

    The test (see below) doesn't have any randomness. That means arithmetic is changing on different runs. The test that's failing here is this one:

    TEST(MathMixMatFun, add_vec_mat) {
      auto f = [](const auto& x, const auto& y) { return stan::math::add(x, y); };
    
      Eigen::VectorXd v5(5);
      v5 << 1, 2, 3, 4, 5;
      Eigen::VectorXd v5b(5);
      v5 << 2, 3, 4, 5, 6;
      Eigen::VectorXd rv5(5);
      v5 << 1, 2, 3, 4, 5;
      Eigen::VectorXd rv5b(5);
      v5 << 2, 3, 4, 5, 6;
      stan::test::expect_ad(f, v5, v5b);
      stan::test::expect_ad(f, rv5, rv5b);
    }
    

    The expect_ad code isn't using any kind of multi-threading or introducing any statics anywhere. I suspect it may be running with different compiler configs or different hardware config, both of which can change details of arithmetic precision.

    The easiest way to fix these is to include:

    stan::test::ad_tolerances tols;   // sets up with defaults
    tols.hessian_hessian_ = 1e-2;  // increase acceptable Hessian finite diff error for rev
    tols.hessian_fvar_hessian_ = 1e-2;  // " for fwd
    ...
    expect_ad(tols, ...);
    

    I added the forward mode because this report also shows up. The key is the hessian_fvar() Hessian line. That indicates that a call to the functional hessian_fvar() failed when computing the Hessian.

    expect_near_rel_finite(-0.0010334642265417964, 0, absolute tolerance = 0.001); absolute diff = 0.0010334642265417964    in: expect_near_rel; require items x1(i) = x2(i): hessian_fvar() Hessian
    

    The errors then follow that nomenclature in lower case to make it easy to update the tests without looking at the tolerances code (only took a few painful attempts to line up messages and constants before I did that).

    Were other tests failing in different situations? It might make sense to just lower Hessian tolerance to 1e-2 globally, or even 5e-3, because we get lots of failures right around 1e-3.

  9. rok-cesnovar commented on Nov 30, 2019

    @rok-cesnovar
    Member

    There were 7 merges to develop and no tests failed here so I am closing this. Thanks to @bob-carpenter for providing the solution.

    Develop did fail once with /usr/local/opt/llvm@6/bin/clang++: /usr/local/opt/llvm@6/bin/clang++: cannot execute binary file but I am assuming that is hopefully one time Jenkins issue.

  10. 3 remaining items

  11. bob-carpenter commented on Dec 3, 2019

    @bob-carpenter
    Member
  12. mcol commented on Dec 3, 2019

    @mcol
    Member

    I would start from only setting the tolerance for the subtract_vec_mat test at 0.005. Up to now I think only the add and subtract tests have been playing funny, so perhaps this is enough.

    On the other hand it would be interesting to see if it's possible to track down from the Jenkys or other backend logs if there is a unique instance of the Windows machines that is failing, and if so understand what is causing the failures (different compiler/hardware configurations?).

  13. rok-cesnovar commented on Dec 4, 2019

    @rok-cesnovar
    Member

    @serban-nicusor-toptal would you be able to tell me if these two runs of "Windows Headers & Unit" were run on different Windows machines?

    I know you told me once how to check this, but I forgot, sorry.

    Hopefully its different machines, that would make this somewhat more expected behavior.

  14. rok-cesnovar commented on Dec 4, 2019

    @rok-cesnovar
    Member

    I tried looking at the pipeline.log in Artifacts but not sure what was run where.

  15. serban-nicusor-toptal commented on Dec 4, 2019

    @serban-nicusor-toptal
    Contributor

    Both ran on the same machine

    Running on gelman-group-win2 in C:\Jenkins2\workspace\Math_Pipeline_PR-1351
    

    To find on what machine they run, go to Jenkins PR page in this case, click on run #10 then go to Console Output -> Full output now CTRL + F for Running on

  16. rok-cesnovar commented on Dec 4, 2019

    @rok-cesnovar
    Member

    Thank you!

    In that case it is something that needs further investigating. Will make a PR to fix the issue on develop and check if can reproduce this on Windows.

  17. bob-carpenter commented on Dec 5, 2019

    @bob-carpenter
    Member
  18. rok-cesnovar commented on Jan 5, 2020

    @rok-cesnovar
    Member

    I think we will finally squashed this one with 744fea1

    Turns out that we kept initializing the same variable while the rest were left uninitialized.

  19. mcol commented on Jan 5, 2020

    @mcol
    Member

    I ran valgrind on the test before the fix, and it did complain about uninitialised values. It's worth keeping it in mind for the next time we see some unexpected behaviour such as this. When dust settles we should try reverting #1469 and #1483.

  20. rok-cesnovar commented on Jan 5, 2020

    @rok-cesnovar
    Member

    I am going to revert back to the default tolerance, which will essentially revert those PRs. Good call @mcol.

  21. added this to the 3.0.0++ milestone on Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions