stan-dev / stan-dev/stan

Move from int to long int?

Open
#3,277 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

i/o
Dominant language
C++
Stars
2.8k
Forks
388
Avg merge
2d 17h
Merged PRs (30d)
15

Description

Summary:

I'm not sure where to post this as it's a Stan wide thing. Currently int values are just basic C int types with values from +/-2,147,483,647. Recently @bob-carpenter had a model with 1M parameters and it had me thinking that it's more realistic that we start having users try larger data sets in the future. For reference, a 10 column matrix of doubles with rows of length max int would be about 172 GB (8 * 2,147,483,647 * 10). Single machines are capable now of having 1TB of memory. While I think we are a few years away from having to worry about this it's something we should think about a little.

I think there's a few options for us

  1. Have a stan::index alias that we use throughout all the repos. We can set this to long int, unsigned int, or whatever we want. (Eigen::Index is long int by default)
  2. Add a long int to the language and have all the code that accepts integers be templated or use auto to deduce the int type. This is more work but lets users keep using int types without worry any loss in speed or memory size from larger integral types.

I'm personally fine with both. The only thing I feel strongly about is that we should keep using a signed type as the default for any index type

Current Version:

v2.34.1

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

The issue names no files, tests, or entry points. Start by surveying how integer and index types are used across the Stan repositories, then compare the proposed stan::index alias with adding a long int to the language. Done would require an agreed design and coordinated implementation scope, which the issue does not define.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.