Open stylewarning opened 5 years ago
qvm tests are skipped locally. How can I test an implementation of shared memory?
qvm tests are skipped locally. How can I test an implementation of shared memory?
Do you mean the shared memory tests are skipped locally? If yes, they are skipped on non-unix operating systems (i.e. Windows): shared memory is not implemented on those systems. So if you want to use shared memory, you will need to use some unix-based OS.
I'm using unix (macOS). I guess a better question is: How can I test the functionality of my implementation for this?
@34ndju You must start the QVM in shared memory mode:
qvm -S --shared shared-mem001 --qubits 4
for instance.
Edit: added a name to the --shared
option.
@34ndju You must start the QVM in shared memory mode:
qvm -S --shared --qubits 4
for instance.
When I try to start the QVM with that sentence I obtain the following error:
! ! ! Condition raised: The value
T
is not of type
SEQUENCE
You have to specify a string for the shared memory name argument. Look at qvm -h
@34ndju You must start the QVM in shared memory mode:
qvm -S --shared --qubits 4
for instance.
When I try to start the QVM with that sentence I obtain the following error:
! ! ! Condition raised: The value T is not of type SEQUENCE
Sorry, my bad. As @34ndju said, a string needs to be specified. I edited my comment accordingly.
You have to specify a string for the shared memory name argument. Look at qvm -h
@34ndju You must start the QVM in shared memory mode:
qvm -S --shared --qubits 4
for instance.
When I try to start the QVM with that sentence I obtain the following error:
! ! ! Condition raised: The value T is not of type SEQUENCE
Sorry, my bad. As @34ndju said, a string needs to be specified. I edited my comment accordingly.
Thank you guys. I am trying to make it work, I am now obtaining the following error when I execute the program:
python shared_qvm.py shared-mem001
Traceback (most recent call last):
File "shared_qvm.py", line 48, in <module>
wf = retrieve_wavefunction(name)
File "shared_qvm.py", line 31, in retrieve_wavefunction
length, offset = query_length_offset(name)
File "shared_qvm.py", line 25, in query_length_offset
s.sendall("?")
TypeError: a bytes-like object is required, not 'str'
And in the QVM terminal I obtain the following:
Fatal SOCKET-ERROR:
Socket error in "sendto": 32 (Broken pipe)
Python3 sockets require you to encode prior to sendall() https://stackoverflow.com/questions/33003498/typeerror-a-bytes-like-object-is-required-not-str, and the error in the QVM terminal is likely because your crashing in the Python program is causing a SIGPIPE. Try to encode.
Shared memory mode allows lots of great benefits for high-performance users of the QVM.
It allows the wavefunction to be shared across several processes in parallel.
It allows incremental computation of the wavefunction with successive calls to
.run
and friends.It gives NumPy access to the wavefunction.
It allows manual state preparation/initialization.
Shared memory mode is and has been supported by the QVM (
--shared
) for quite some time, but it's not available in pyQuil since we've only recently released the SDK. The proposal is to add this to pyQuil, probably as a part of wavefunction simulator, but maybe elsewhere.The following script is a PoC, but is outdated against current pyQuil and is Python 2. It prepares a 4q wavefunction in the W-state, and then inverts the bitstrings with X gates.