Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow reading and saving (save_object()) csv draws with DuckDB to avoid memory explosion #1041

Open
stemangiola opened this issue Nov 20, 2024 · 1 comment
Labels
feature New feature or request

Comments

@stemangiola
Copy link

stemangiola commented Nov 20, 2024

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

@stemangiola stemangiola added the feature New feature or request label Nov 20, 2024
@jgabry
Copy link
Member

jgabry commented Nov 20, 2024

We're definitely interested in ways to use less memory. I haven't used DuckDB but it seems promising. Right now a lot of the contributors to cmdstanr are pretty busy, but if someone else is interested and has time to work on this please let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants