-
Notifications
You must be signed in to change notification settings - Fork 9
Use qibo as a backend for vegasflow #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
dfd534b to
a459d85
Compare
|
In the log below, the first two runs are just uniform sampling and the second two the quantum device. The first just a plain monte carlo and the second going through the vegas algorithm. 1e5 events x2 dim in ~20 minutes, which is okish for using it as a backend I'd say @scarrazza (in this case the integrand is trivial, in a more complicated case I'd expect the integrand cost to take over) The results seems to be compatible with the initial sampling for all but the first run. It might be a fluctuation but I've run this test twice and the first run (iteration 0 of the 3rd run in the log above) was also more off than what the error would suggest. |
| self._quantum_sampler.connect() | ||
| quantum_rnds_raw = self._quantum_sampler.random((n_events, self.n_dim)) | ||
| self._quantum_sampler.disconnect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of connecting and disconnecting every time, why don't you keep the connection in the object? (and just disconnect on delete)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not claiming that is going to be the main performance bottleneck - but it's certainly some overhead (if it can be avoided).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because while I was testing I got several times an error along the lines of "someone else is using the device" which I thought maybe it was @stravos11 testing so I thought it was better to close it asap to avoid making his stuff error out in the same way.
(indeed, in the first commit I do as you suggest)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was not me, so it is either a different kind of error that we would need to address if it appears often, or someone else tried to use at the same time, but I don't think anyone other than us and @scarrazza would. Personally, I have another qrng that I connect directly to my computer for debugging so I avoid using the one in the qrccluster.
Also, I don't think connect() and disconnect() will have any effect on others. Based on a quick experiment I did, if someone else tries to access numbers while you are sampling, your connection will automatically drop (with an error) and their job will start. So basically the last one always wins. Also, I think connect() and disconnect() have no effect on the qrng device itself, they just create/destroy the Serial object in your Python runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, then I'll redo what I was doing before and paste the error. By disconecting inmediately after use like now i didn't see the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I actually thought that could be the case, but I was unsure about the setup. It may be that you're actually trying reconnecting multiple times somehow (e.g., instantiating the object multiple times).
In case you still experience the error, would you post it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think
connect()anddisconnect()have no effect on the qrng device itself, they just create/destroy theSerialobject in your Python runtime.
@stavros11 while on the device it may have no effect (not so expert in serial interfaces...), for sure it has an effect on the OS, since it has at least to open a file descriptor for the communication. Then, this will be handled by the given fs, and potentially boil down to a tiny and likely negligible operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on a quick experiment I did, if someone else tries to access numbers while you are sampling, your connection will automatically drop (with an error) and their job will start. So basically the last one always wins.
In case you still experience the error, would you post it?
I ran a long test yesterday evening and didn't experience the error again. I think I might have really clashed with you or someone else who tried to use it?
In any case, I can "force" the error by just login in twice to the node and running the same script in both, one of them will error out with:
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
(the crash happened in the one that ran second fwiw)
|
@scarlehoff the drivers for the qrng are available now in qibolab v0.2.3. |
At the moment it just uses qiboteam/qibolab#1138 to generate the random numbers which then are casted to tensorflow, which at that point is used basically as numpy.
As it is now Vegas could inherit from it already and use the qrng device.