stan-dev / math

The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
750 stars 189 forks source link

Unused variables in Algebra solver causing problems #992

Closed bbbales2 closed 4 years ago

bbbales2 commented 6 years ago

Description

There was an instance on Discourse of a user having problems with a model where they did not use all the parameters that they passed into the Algebra solver.

Full description here: http://discourse.mc-stan.org/t/algebra-solver-has-a-side-effect-on-log-probability/5130/5

I don't think it should matter. If a parameter is unused by the algebra solver, the algebra solver shouldn't touch its adjoints and everything should be fine.

We should try to reproduce the basic error and confirm if it happens or not.

Current Math Version

v2.18.0

bbbales2 commented 4 years ago

I tried to reproduce an error from unused parameters in the algebra solver but failed to get one. I was just padding zeros before/after the parameter arguments for the code here: https://github.com/stan-dev/stancon_talks/blob/master/2018/Contributed-Talks/08_margossian/model/SteadyStateODE.stan. Closing this.