stan-dev / stan-dev/cmdstanr

on-disk/lazy draw backend for large fits

Open
#1,041 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
R
Stars
160
Forks
69
Avg merge
1d 19h
Merged PRs (30d)
15

Description

For large models (~13K paramemeters) the procedure

library(magrittr)
temp_rds_file <- tempfile(fileext = ".rds")
cmdstanr_fit$save_object(file = temp_rds_file) 
standalone_fit <- readRDS(temp_rds_file)

Takes an incredible amount of memory.

When loaded into memory, the cmdstanr_fit is around ~8Gb, and the operations pick at 54Gb.

This could be solved by handling ".csv" draws on-disk using DuckDB technology (toggling it with a parameter?)

Here an example of csv handling by DuckDB.

https://stackoverflow.com/questions/77797976/working-with-large-csv-file-using-duckdb-or-arrow-in-r

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the save_object/readRDS workflow described in the issue and measuring its memory use for a large fit. Review the linked DuckDB CSV-handling example and determine the scope of an optional on-disk draw backend. Done should mean large fits can use on-disk CSV draws with substantially lower memory use.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.