Stan develop broken - gp functions merge problem?

since latest merge, PR https://github.com/stan-dev/stan/pull/2749 is failing -

make/tests:98: recipe for target 'test/test-models/good/function-signatures/math/matrix/gp_regression_test.hpp-test' failed
make: *** [test/test-models/good/function-signatures/math/matrix/gp_regression_test.hpp-test] Error 1

@seantalts, @anon79882417 - please investigate

fresh clone of cmdstan, stan, stan_math confirms this:

make stan/src/test/test-models/good/function-signatures/math/matrix/gp_regression_test

fails:

In file included from src/cmdstan/main.cpp:1:
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/mat.hpp:12:
In file included from stan/lib/stan_math/stan/math/prim/mat.hpp:132:
/Users/mitzi/tmp/cmdstan/stan/lib/stan_math/stan/math/prim/mat/fun/gp_matern52_cov.hpp:203:37: error: invalid operands to binary expression ('typename
      apply_scalar_unary<sqrt_fun, double>::return_t' (aka 'double') and 'const std::__1::vector<stan::math::var, std::__1::allocator<stan::math::var> >')
  T_l neg_root_5_inv_l = -sqrt(5.0) / length_scale;
                         ~~~~~~~~~~ ^ ~~~~~~~~~~~~
/Users/mitzi/tmp/cmdstan/stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:119:12: note: candidate function not viable: no known conversion from 'const
      std::__1::vector<stan::math::var, std::__1::allocator<stan::math::var> >' to 'const stan::math::var' for 2nd argument
inline var operator/(double a, const var& b) {
           ^
/Users/mitzi/tmp/cmdstan/stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:87:12: note: candidate function not viable: no known conversion from 'const
      std::__1::vector<stan::math::var, std::__1::allocator<stan::math::var> >' to 'const stan::math::var' for 2nd argument
inline var operator/(const var& a, const var& b) {
           ^
/Users/mitzi/tmp/cmdstan/stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:102:12: note: candidate function not viable: no known conversion from 'const
      std::__1::vector<stan::math::var, std::__1::allocator<stan::math::var> >' to 'double' for 2nd argument
inline var operator/(const var& a, double b) {
           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/complex:669:1: note: candidate template ignored: could not match
      'complex<type-parameter-0-0>' against 'double'
operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/complex:714:1: note: candidate template ignored: could not match
      'complex<type-parameter-0-0>' against 'double'
operator/(const complex<_Tp>& __x, const _Tp& __y)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/complex:722:1: note: candidate template ignored: could not match
      'complex' against 'vector'
operator/(const _Tp& __x, const complex<_Tp>& __y)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/valarray:3773:1: note: candidate template ignored: substitution failure
      [with _Expr1 = double, _Expr2 = std::__1::vector<stan::math::var, std::__1::allocator<stan::math::var> >]: type 'double' cannot be used prior to '::' because it has
      no members
operator/(const _Expr1& __x, const _Expr2& __y)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/valarray:3788:1: note: candidate template ignored: substitution failure
      [with _Expr = double]: type 'double' cannot be used prior to '::' because it has no members
operator/(const _Expr& __x, const typename _Expr::value_type& __y)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/valarray:3804:1: note: candidate template ignored: requirement
      '__is_val_expr<vector<var, allocator<var> > >::value' was not satisfied [with _Expr = std::__1::vector<stan::math::var, std::__1::allocator<stan::math::var> >]
operator/(const typename _Expr::value_type& __x, const _Expr& __y)
^
8 errors generated.
make: *** [stan/src/test/test-models/good/function-signatures/math/matrix/gp_regression_test] Error 1

I’m on it, @seantalts can we revert this latest merge?

Yep. I’ll go ahead and revert this one.

Ok, I’ve done a fresh clone of develop versions of cmdstan, stan and stan/math.

I’m getting other errors: Some with template deduction and others where I re-used a function name as a variable name.

First, when I have these issues, this shouldn’t even compile at the Stan/math level. Is there perhaps a compiler flag I can add or something to cause this bug?

I’m still not able to re-create this error. I’m using Linux, and I’m thinking it’s a result of the OS and its respective compiler. Looks like it’s happening on Apple. Is there an Apple server I can SSH to so I can debug this?

Can you write out exactly what you’re doing? What git hashes are you using for each repo / submodule? And what Stan program? I can try to recreate it.

It won’t necessarily cause a compiler error in math if you don’t instantiate it. That’s why we ask for the instantiations in the math library even when it looks like it should work when inspecting the code. (non-compilable code is valid in templated code if it’s never instantiated)

Yeah, here’s all of the info to re-create, I’ve just cloned all the most recent develop branches:

cmdstan git hash: b82554a1b8f2829547871d3dc4b5c77892832ec4
stan git hash: f09ff8fb108a97a341617e820930b1bae18e7b24
stan_math git hash: edf99d8469566fa869d871efbd5bf6cd28c84832

and then I’m running the command: make stan/src/test/test-models/good/function-signatures/math/matrix/gp_regression_test which should fail in compilation, but for me it passes.

Thanks for taking a look at this.

Whoops, I’ve said something incorrect.

The stan commit hash you’ll want is:

598f20264380fea5ca0881b3fee2b20d0da0f0c4

1 Like

Thanks. Using those git hashes, I was able to recreate it. What branch are you working on for the Math library? Maybe I can throw together a unit test that breaks.

That would be huge, thanks.

I’m working off of my fork, on branch feature/issue-2736-add-gp-kernels-to-language, if you can’t push I can give you permission or copy paste a test case from here.

I can’t find that branch on your fork of the Math library.

Add this to test/unit/math/rev/mat/fun/gp_matern52_cov_test.cpp:


TEST(MathRev, fails_to_compile) {
  std::vector<Eigen::VectorXd> x;
  stan::math::var sigma;
  std::vector<stan::math::var> l;

  stan::math::gp_matern52_cov(x, sigma, l);
}

Here’s what my error message looks like:

$ ./runTests.py test/unit/math/rev/mat/fun/gp_matern52_cov_test.cpp
------------------------------------------------------------
make -j1 test/unit/math/rev/mat/fun/gp_matern52_cov_test
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare      -O3  -I . -I lib/eigen_3.3.3 -I lib/boost_1.69.0 -I lib/sundials_4.1.0/include -I lib/gtest_1.8.1/include -I lib/gtest_1.8.1     -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION    -DGTEST_USE_OWN_TR1_TUPLE  -c -MT test/unit/math/rev/mat/fun/gp_matern52_cov_test.o -MM -E -MG -MP -MF test/unit/math/rev/mat/fun/gp_matern52_cov_test.d test/unit/math/rev/mat/fun/gp_matern52_cov_test.cpp
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare      -O3  -I . -I lib/eigen_3.3.3 -I lib/boost_1.69.0 -I lib/sundials_4.1.0/include -I lib/gtest_1.8.1/include -I lib/gtest_1.8.1 -I lib/gtest_1.8.1/include -I lib/gtest_1.8.1      -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION    -DGTEST_USE_OWN_TR1_TUPLE -DGTEST_USE_OWN_TR1_TUPLE  -c -o test/unit/math/rev/mat/fun/gp_matern52_cov_test.o test/unit/math/rev/mat/fun/gp_matern52_cov_test.cpp
In file included from test/unit/math/rev/mat/fun/gp_matern52_cov_test.cpp:2:
In file included from ./stan/math/rev/mat.hpp:12:
In file included from ./stan/math/prim/mat.hpp:147:
./stan/math/prim/mat/fun/gp_matern52_cov.hpp:141:39: error: no viable conversion from 'stan::math::var' to
      'typename return_type<double>::type' (aka 'double')
      typename return_type<T_x>::type sq_distance
                                      ^
test/unit/math/rev/mat/fun/gp_matern52_cov_test.cpp:89:15: note: in instantiation of function template specialization
      'stan::math::gp_matern52_cov<double, stan::math::var, stan::math::var>' requested here
  stan::math::gp_matern52_cov(x, sigma, l);
              ^
1 error generated.
make: *** [test/unit/math/rev/mat/fun/gp_matern52_cov_test.o] Error 1
make -j1 test/unit/math/rev/mat/fun/gp_matern52_cov_test failed
exit now (04/17/19 22:09:00 EDT)

Thanks for taking the time to do this.

You’re welcome. By the way, I didn’t check all the instantiations… just the first one that triggered an error. It looked like there were going to be more.

The easiest thing to do, I think, is to update the Stan language so these additional instantiations are never generated. Then fix the Math library, then go back to the full ARD. But… there are other ways to do this too.

If you want to know how I tracked this down, let me know and I’ll walk you through how I navigated through this.

Yeah, that would be helpful. I’m still not getting the same compilation errors, and they still seem different from Mitzi’s. Could be something silly I’m doing?

I’m flexible, so if you have a few minutes at any time just let me know