Feature request: support for vectorized parameters in httpstan

As of version 4.5.0, httpstan’s log_prob endpoint does not support models which define vectors of parameters. My team is interested in integrating Stan with a web application we are developing, and sadly this limitation is a blocking issue for us since many of the models we would like to work with have fairly high-dimension parameters and make use of Stan’s vector type. In general, I think that support for more parameter data types in the log_prob endpoint would be a widely-useful feature for httpstan.

1 Like


Could you show example that fails?

Hi @ahartikainen, yes for sure. As noted here, httpstan’s log_prob method cannot handle cases where you have a Stan model defining parameters such as:

parameters {
  vector[n] theta; // <-- can't pass a value for this parameter
  real sigma;

It currently only handles parameters of type real (related JSON schema).

1 Like

It works with all Stan parameter types, but you need to unpack them to a list of numbers, because this is what Stan C++ uses. See pystan (httpstan) functions for this (constrain / unconstrain)

1 Like

Oh awesome, thanks for the pointer @ahartikainen. Is this flattening of parameters documented somewhere? I dug around a bit but couldn’t find anything. I’m also wondering how this is applied to two-dimensional data structures like matrices.

Basically numpy arrays are ravelled in “columnwise” order (‘F’/fortran order).

This is probably said somewhere in C++ source.

1 Like

Okay great, I’ll dig around in the source a bit more to see if I can find some additional documentation, but in general I think this should help us continue our work. Thanks for your help, @ahartikainen!