Sample from multivariate normal distribution in batch mode?

48 views
Skip to first unread message

Carlos

unread,
Dec 3, 2023, 2:31:04 AM12/3/23
to ArrayFire Users
Kind regards,

I am currently utilizing ArrayFire in a simulation, and a part of the algorithm requires sampling from a multivariate normal distribution with mean M_i and covariance matrix S_i. Each sample has its own mean and covariance. To generate multivariate samples, I am using the Cholesky decomposition; however, it cannot be used in batch mode.

My algorithm requires generating millions of samples from small multivariate normals (7 to 10 dimensions).  Is there any alternative to make it faster?

I have extracted and attached the part of the code that gives the error, thanks in advance.

Error message: 
terminate called after throwing an instance of 'af::exception'
  what():  ArrayFire Exception (Invalid batch configuration:207):
In function af_cholesky
In file src/api/c/cholesky.cpp:41
cholesky can not be used in batch mode
 0# af_cholesky in /home/carlos/ArrayFire-3.9.0-Linux/lib64/libafcuda.so.3
 1# af::cholesky(af::array&, af::array const&, bool) in /home/carlos/ArrayFire-3.9.0-Linux/lib64/libafcuda.so.3
 2# 0x000055D0A9886579 in ./model
 3# 0x00007F43E5445CD0 in /usr/lib/libc.so.6
 4# __libc_start_main in /usr/lib/libc.so.6
 5# 0x000055D0A9886A65 in ./model


af::info:
ArrayFire v3.9.0 (CUDA, 64-bit Linux, build b59a1ae53)
Platform: CUDA Runtime 12.2, Driver: 535.129.03
[0] NVIDIA GeForce RTX 3060, 12011 MB, CUDA Compute 8.6

error_cholesky.cpp

Umar Arshad

unread,
Dec 20, 2023, 1:04:53 PM12/20/23
to ArrayFire Users
Hi Carlos,

The like you mentioned the batch functionality is not yet implemented for Cholesky. That is something we would like to add but we don't have a timeline for this feature Additionally your matrices are pretty small so I don't h think you will see a significant speedup with a GPU even with the batch functionallity.

Umar Arshad

Carlos

unread,
Dec 20, 2023, 6:58:24 PM12/20/23
to ArrayFire Users
Thanks for your answerer, Umar Arshad. 

It appears that I'm quite confused. Just to clarify, is there no benefit in utilizing matrix multiplication? For instance, if I intend to perform matrix multiplication in batch mode with an array A of dimensions {7, 7, 1000000} and an array B of dimensions {7, 7, 1000000}, would there not be a substantial improvement when compared to using a GPU vs CPU?

Thanks.
Reply all
Reply to author
Forward
0 new messages