Skip to content

Commit 3dc7d42

Browse files
committed
Do not recompute model logpt graph in every step of assign_step_methods
1 parent 8e0f95a commit 3dc7d42

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pymc/sampling.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,14 @@ def assign_step_methods(model, step=None, methods=STEP_METHODS, step_kwargs=None
210210
# Use competence classmethods to select step methods for remaining
211211
# variables
212212
selected_steps = defaultdict(list)
213+
model_logpt = model.logpt()
213214
for var in model.value_vars:
214215
if var not in assigned_vars:
215216
# determine if a gradient can be computed
216217
has_gradient = var.dtype not in discrete_types
217218
if has_gradient:
218219
try:
219-
tg.grad(model.logpt(), var)
220+
tg.grad(model_logpt, var)
220221
except (NotImplementedError, tg.NullTypeGradError):
221222
has_gradient = False
222223
# select the best method

0 commit comments

Comments
 (0)