QuESTlink icon indicating copy to clipboard operation
QuESTlink copied to clipboard

[feature request] support parallelism facilities by default

Open lm1909 opened this issue 4 years ago • 1 comments

It would be great if QuESTlink would support the Mathematica parallelisation facilities (e.g. ParallelTable etc.) by default. Currently, this results in errors of e.g. the form questlinkparallelism

I think this would necessitate that each kernel has its own QuEST backend, I hacked a solution together:

Parallel`Developer`$InitCode =
 Hold[
  Import["path/QuESTlink.m"];CreateLocalQuESTEnv["path/quest_link"];
 ]

via the solution proposed in this stackexchange answer. However, as mentioned there, $InitCode is undocumented and thus probably not suitable for implementing in QuESTlink directly, though the answerer mentions it appears to be quite stable.

I feel this would be very useful though, e.g. I often ran an algorithm using QuESTlink repeatedly with different parameters for comparison, and it was very comfortable to use e.g. ParallelTable for that.

lm1909 avatar Jun 24 '21 18:06 lm1909

Hi there, Please forgive the absolutely incredible delay! This is a nice idea, although there isn't much more one can do besides setting ParallelDeveloper$InitCode as you do above (except worse/hackier things inside each Parallel function). Further, it seems parallelisation of this granularity is only worthwhile for very small systems when the exponentially growing costs of simulating a single statevector at a time haven't yet dominated. For larger systems, it is better to dedicate all threads to modify the same statevector (achieving better cache behaviour and minimising context switching) at one time. I think your solution for unusually small systems is the only way to go.

TysonRayJones avatar Nov 07 '22 21:11 TysonRayJones