# Checkpointing with CmdStanPy

**URL:** <https://discourse.mc-stan.org/t/checkpointing-with-cmdstanpy/18189>\
**Category:** General\
**Created:** [September 24, 2020, 4:26pm UTC](https://discourse.mc-stan.org/t/checkpointing-with-cmdstanpy/18189 "2020-09-24T16:26:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nerpa](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@nerpa](https://discourse.mc-stan.org/u/nerpa)\
**Post date:** [September 24, 2020, 4:26pm UTC](https://discourse.mc-stan.org/t/checkpointing-with-cmdstanpy/18189/1 "2020-09-24T16:26:20Z")

</div>

Hello all,

Following the thread on checkpointing with Stan, is there any tutorial that was created on this? My wall time limit is 24 hrs and the full model takes a few days to sample (using `reduce_sum` with 90 cores).

> [@Current state of checkpointing in Stan](https://discourse.mc-stan.org/t/current-state-of-checkpointing-in-stan/12348/7):
>
> I think this can be done with PyStan and CmdStan (+CmdStanPy +CmdStanR).
> 
> I think it would be good idea to have some kind of tutorial showing all of these steps.

Thanks!

---

<div class="post-metadata">

**Author:** ![ahartikainen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ahartikainen/32/321_2.png) [@ahartikainen](https://discourse.mc-stan.org/u/ahartikainen)\
**Post date:** [September 24, 2020, 4:58pm UTC](https://discourse.mc-stan.org/t/checkpointing-with-cmdstanpy/18189/2 "2020-09-24T16:58:53Z")

</div>

Hi, I’m not sure if there are any official tutorial

Here is one example with PyStan + ArviZ

> <https://github.com/ahartikainen/fit_check_fit_loop/blob/master/MoreSamples_round1/increase_draws_in_steps.ipynb>

And also here

> **[HMC: Euclidian Metric — PyStan 2.19.1.1 documentation](https://pystan.readthedocs.io/en/latest/hmc_euclidian_metric.html)**

Both of these assume that warmup can be done in 1 step (1 run).

---

<div class="post-metadata">

**Author:** ![nerpa](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@nerpa](https://discourse.mc-stan.org/u/nerpa)\
**Post date:** [September 24, 2020, 5:21pm UTC](https://discourse.mc-stan.org/t/checkpointing-with-cmdstanpy/18189/3 "2020-09-24T17:21:07Z")

</div>

Thanks! I wish there could me such a nice example with CmdStanPy as well!  
What would be the `inv_metric` equivalent from the `cmdstan` csv output file?  
Is `last_position` simply the final value of the `cmdstan` output file for each parameter?

Thanks!
