Parallel computation applications of UQLab in MATLAB

Hi UQworld,

I’m trying to sequentially update my metamodel, using UQLab, for instance the Kriging metamodel. And I want to use the parallel comptating capability of MATLAB, to accelerate the process. However, I found that the code in UQLab seems not supported the parallel computing well. The code can be used in series computing sometimes fails in parall computing.

Could anyone give me some suggetsion? Or could the UQLab developers could solve this issue, on the parallel computing capability? It would be much more efficient for the modeling if UQLab can support this capability.

Hi @GPLai,

Perhaps you could be more concrete about what you’re trying to do? Which part of UQLab you’re trying to parallelize? And what did you do so far that didn’t work? An example would be helpful.

Thanks!

Dear damarginal,

Thanks for your reply. I’m trying to parallelize the meta-modeling process, that is, the regression process.

I attach four matlab code file herein. And I test the parallel process of two meta-model methods——Kriging and PCKriging. I can succeed the parallel computing of Kriging meta-modeling, but fail for the PCKriging meta-modeling.

Thanks

Regression_Kriging.m (786 Bytes) Regression_PCK.m (888 Bytes) Test_Kriging.m (985 Bytes) Test_PCK.m (978 Bytes)

In addition, when selecting the optimization method for Kriging regression, I used the ‘GA’ method. And I noticed tha in matlab the GA method can be also parallelized, but I didn’t found how to configure the setup in uqlab to realize it.

Hi @GPLai,

thanks for the more complete description of your problem.

I’ve had a look at your PCK script (Regression_PCK.m). To use it under a parfor loop you need to explicitly specify the INPUT object you created to the configuration option of the PCK metamodel. So:

function MyPCKriging_Gaussian= Regression_PCK(x,y)
...
myInput = uq_createInput(IOpts,'-private');
...
MetaOpts.Input = myInput;
...
MyPCKriging_Gaussian = uq_createModel(MetaOpts, '-private');

end

Note that you need to create the INPUT object inside the function as a private object to avoid UQLab trying to attach the object to the current UQLab session. In the parfor setting, this seems to create a problem (not sure why; maybe a race condition?).

In the serial setting, creating the INPUT objects and adding it to the UQLab session happen one after the other so there’s no chance of conflict. At the end of the for loop, a total of 8 additional INPUT objects have been created (uq_listInputs to check). You don’t even need to specify this INPUT object to the configuration option in the case of serial for loop because UQLab automatically getting the current INPUT object (the lastly created one by default) in the UQLab session and assign it to the option (this only works if you don’t use the '-private' flag). In your case of Kriging, there’s no need to deal with an INPUT object, so there’s no problem there.

Alternatively, you can create an isolated UQLab session for each of the MATLAB parallel workers by first calling uqlab('-nosplash') in Regression_PCK.m. This way you can use your old script as-is (i.e., no explicit INPUT specification on the configuration option but remove the 'private' flag on the INPUT object).

Now about the parallel GA of MATLAB. Currently, the option to activate the parallel option is not open to user. So you cannot access this option via the usual configuration option of UQLab. There’s a backdoor solution to this if you wish to use parallel GA; you can edit the function uq_Kriging_initialize_optimizer.m and look for the relevant line for setting up the GA (around line 74) and add a new line: 'UseParallel', true to the list of options. I don’t know what’s the performance gain of using the parallel GA to optimize the hyperparameters of Kriging model, however. I’d happy to know what you find out!

I hope this helps!

1 Like

Thanks very much. Your method is great! :grinning: it does work for my problem. I can parrallelize the PCKriging metamodeling process now. And I’ll try the parall GA method latter, and give the feedback for its performance herein.