Skip to content

STAN_THREADS in make/local not respected due to capitalisation conflict #765

@jaburgoyne

Description

@jaburgoyne

Describe the bug

If threading is enabled globally by way of STAN_THREADS=true in make/local (as opposed to locally via cpp_options = list(stan_threads = TRUE) in a call to model$compile()), cmdstanr does not respect the setting. Although model$cpp_options is TRUE for the key STAN_THREADS, assert_valid_threads() only checks for stan_threads in lowercase.

Although threading is perhaps the most common use case, the same bug would apply to STAN_OPENCL and any other C++ option. To fix the bug, CmdStanModel needs to standardise on all-caps or lowercase for its internal cpp_options representation. It seems to me that lowercase would be the most consistent (and thus model_compile_info() should use tolower() instead of toupper() here), but in case this has further-reaching consequences than I can see, I’m making an issue instead of a pull request.

To Reproduce

Set STAN_THREADS=true in make/local, compile a model, and then try to run model$sample() with threads_per_chain set to some integer greater than 1.

Expected behavior

The model should sample using multi-threading instead of complaining (erroneously) that the model has not been compiled with threading enabled.

Operating system

Although this should be platform-agnostic, I am running macOS 13.3.1 on an Apple M1 architecture.

CmdStanR version number

2.32.1

Additional context

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions