# RL Model- extremely slow gradient evalution

**URL:** <https://discourse.mc-stan.org/t/rl-model-extremely-slow-gradient-evalution/15926>\
**Category:** Modeling\
**Tags:** performance, reinforcement-learning\
**Created:** [June 14, 2020, 11:51am UTC](https://discourse.mc-stan.org/t/rl-model-extremely-slow-gradient-evalution/15926 "2020-06-14T11:51:30Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![mike-lawrence](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mike-lawrence/32/59_2.png) [@mike-lawrence](https://discourse.mc-stan.org/u/mike-lawrence)\
**Post date:** [June 18, 2020, 7:04pm UTC](https://discourse.mc-stan.org/t/rl-model-extremely-slow-gradient-evalution/15926/6 "2020-06-18T19:04:42Z")

</div>

Hm, I definitely don’t have any expertise in this realm specifically, so while I’ve looked at the code, it’s not immediately obvious to me what’s going on. So I’ll simply interject my standard recommendation to look for redundancy in the data input to the model (esp. design matrices), which usually means that there are redundant computations being done that can be avoided by identifying unique entries and indexing [as shown here](https://discourse.mc-stan.org/t/case-study-preview-speeding-up-stan-by-reducing-redundant-computation/14228). Since it’s a binomial outcome, you should look at whether there’s any chunks of data for which you can predict that `deltaV` is constant (you don’t need to know what the constant value actually will be, just that it will be the same value for all the elements in the chunk), in which case you can speed things up substantially by using [sufficient statistics](https://mc-stan.org/docs/2_23/stan-users-guide/exploiting-sufficient-statistics.html).

---

_[View the full topic](https://discourse.mc-stan.org/t/rl-model-extremely-slow-gradient-evalution/15926)._
